From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 603D7C47423 for ; Fri, 2 Oct 2020 09:18:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C472E21D24 for ; Fri, 2 Oct 2020 09:18:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AWF/8lP+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C472E21D24 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 106BD6B0068; Fri, 2 Oct 2020 05:18:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B701900002; Fri, 2 Oct 2020 05:18:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE7716B006E; Fri, 2 Oct 2020 05:18:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id C00426B0068 for ; Fri, 2 Oct 2020 05:18:03 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5C017180AD801 for ; Fri, 2 Oct 2020 09:18:03 +0000 (UTC) X-FDA: 77326433646.24.goat84_49103a8271a3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 3A99B1A4A0 for ; Fri, 2 Oct 2020 09:18:03 +0000 (UTC) X-HE-Tag: goat84_49103a8271a3 X-Filterd-Recvd-Size: 4566 Received: from mail-yb1-f193.google.com (mail-yb1-f193.google.com [209.85.219.193]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 09:18:02 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id k18so704113ybh.1 for ; Fri, 02 Oct 2020 02:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vsjo30pgyOUaef87RJlkVqPkl1WeoNmBll1hNfvAZmU=; b=AWF/8lP+/Nl6Tu9rGdxcSoT5C6Ym+2LAhrLg7DhdLj299c+5+DgEYG1RwNMFAivBh3 cwE0qGwo90rpYmZMcUnsdumVHlrX/iktoB7i6NT2WSF1SAWM9HgDvig+XioF1zvVK2dZ rdX7cyOR8HK1up6v5yAvbXSGe0SJOXA9e1hmHPo4mgwioCsFyBhyluNnPTczUWyEDWnm ofkNAu08t36N0yHkj+x4qtbUpzquXvmgzHgAWK2OJF3T8lwpT66aqAvyDNvHn8orMlc8 u0UcrIY3CgOxSvuVB+t6ONEsrKbU5QyM1FnlqKfOkInUYBYAvtMJ2bslSyHQpElmxpvG Zh4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vsjo30pgyOUaef87RJlkVqPkl1WeoNmBll1hNfvAZmU=; b=g0xUKOm04lhSvNiDVGBzAtvsS9IUwqCN/WqW3ilfYh3/iGI9y+dznGJXDyjOyKvbMa NOWhrbsLddnCuZBYhL+YHhr2hdw2es4tKc78F5G5nRKaudaHeWIsOE2sLfrNJxOtXXIN k5StvO6YqIEJ9RZlN8EEy14EdenkkYikWU85kuLfogJjYTrbFfmk55sn/de1zq5pLlan 9UBuWLbXwcQzpmxx71DT+vJ4Hm3fyg85PGHVhUu/FU012SS4tmniFQi/ln8uWUEgpiMk zP1uLA3V3Eppy3GMEefJ9eOih4OuivUwVyGGEplHAT7B1raCA/+aV2vTinOX3ccsS9E1 ZLRA== X-Gm-Message-State: AOAM5307snJEAsdP6WD7sdqyHDiGdi1bwVCWo5ndWEucIWq7sHd9bboL K7f/KVC02S2O2FXlIc3/YAHPWzFNmdskA9dRe4JzxQ== X-Google-Smtp-Source: ABdhPJyPBuvssqN/33F6eY14jTT+a+H/yPFD0+SG2k2GowbWLmh3q7LGH/7YYKEdpdnFAiVucEWGEP5B/qXvNQHe8zM= X-Received: by 2002:a25:5056:: with SMTP id e83mr1441462ybb.287.1601630281691; Fri, 02 Oct 2020 02:18:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Michel Lespinasse Date: Fri, 2 Oct 2020 02:17:49 -0700 Message-ID: Subject: Re: [PATCH 1/2] mmap locking API: Order lock of nascent mm outside lock of live mm To: Jann Horn Cc: Andrew Morton , linux-mm , LKML , "Eric W . Biederman" , Mauro Carvalho Chehab , Sakari Ailus , Jeff Dike , Richard Weinberger , Anton Ivanov , linux-um@lists.infradead.org, Jason Gunthorpe , John Hubbard Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 1, 2020 at 6:25 PM Jann Horn wrote: > Until now, the mmap lock of the nascent mm was ordered inside the mmap lock > of the old mm (in dup_mmap() and in UML's activate_mm()). > A following patch will change the exec path to very broadly lock the > nascent mm, but fine-grained locking should still work at the same time for > the new mm. > To do this in a way that lockdep is happy about, let's turn around the lock > ordering in both places that currently nest the locks. > Since SINGLE_DEPTH_NESTING is normally used for the inner nesting layer, > make up our own lock subclass MMAP_LOCK_SUBCLASS_NASCENT and use that > instead. > > The added locking calls in exec_mmap() are temporary; the following patch > will move the locking out of exec_mmap(). Thanks for doing this. This is probably a silly question, but I am not sure exactly where we lock the old MM while bprm is creating the new MM ? I am guessing this would be only in setup_arg_pages(), copying the args and environment from the old the the new MM ? If that is correct, then wouldn't it be sufficient to use mmap_write_lock_nested in setup_arg_pages() ? Or, is the issue that we'd prefer to have a killable version of it there ? Also FYI I was going to play with these patches a bit to help answer these questions on my own, but wasn't able to easily apply them as they came lightly mangled (whitespace issues) when I saved them.