Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2610891ybk; Mon, 18 May 2020 03:36:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAKwD/iNPEKFlK2geTjTu3MiOZRJ8uqIV/tiv5RDl0vc3+qspPuOYipiU4d9Mjd+x1dpxi X-Received: by 2002:aa7:d284:: with SMTP id w4mr12583896edq.223.1589798189157; Mon, 18 May 2020 03:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589798189; cv=none; d=google.com; s=arc-20160816; b=wKmCsfjonDV/aR7u88SMsR3S40PflqUrM/dzgQolSKfMsFKG/HScgXmG4hY/MD3a1O EExEfxarj4PVtlTECsUxT0HYgC6lw046NiOODGmjUWNwf5Ae0mmetYuuhR4DL/VFW5KD G8wXAAym//B0okM8ciGIdIdp/7n+pAT57EcLi/XraNMK1GTj4vHwio33/hUPYyV7XrLq 3bxa3TQCRy480XsSUrwo1bdDU1beR6Pa6rMqneWbsofFww4PEb952LK+97FvsjzJei7h Bbwkl7K9YWLZV48AHpSBsx35sIKph0281Tn31RVoR05ioda6aN5jiNXMRgVv8ZM0tE4t bm+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=zUxfFiKWFy1MXn+Nh7A7M2Y3Y0xDFHq8PTBjpItVL5w=; b=ieKLtWrSH9hXGN2D3caTEi8yOOCYZCmM7bWbqogrgSGicpUVOQyfVz4IMxR4zTjajR If0fnGkyMD5nl0lsruNBd7YsHjQZ3XEwI1ZZrrWCqThMMR9BQTmHqwvDLCBKfdUYP3j/ FjtxsDU/qbwsI9TU81l9clFwN8HJA6Y5VEb2j+M0WezQCCGPJ6LWKL27EnmGizWSJa+4 ltD8xZiYrTyMm8fj490+c9p6b6InHJkKOdfJGhhsfDasnuyl/XKjQuA0RgxxQ7C1xEag Jnh4zYgJIfDOtH3qpU4nwAe4V9mvyJvVrV1/mGYIyxtmt7vcPTUbfhKNNnYoMw0anAis 9kCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si5550838edx.18.2020.05.18.03.36.06; Mon, 18 May 2020 03:36:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgERKcH (ORCPT + 99 others); Mon, 18 May 2020 06:32:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:54562 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbgERKcG (ORCPT ); Mon, 18 May 2020 06:32:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 66A57AA4F; Mon, 18 May 2020 10:32:07 +0000 (UTC) Subject: Re: [PATCH v5 06/10] mmap locking API: convert nested write lock sites To: Michel Lespinasse , Andrew Morton , linux-mm Cc: LKML , Peter Zijlstra , Laurent Dufour , Matthew Wilcox , Liam Howlett , Jerome Glisse , Davidlohr Bueso , David Rientjes , Hugh Dickins , Ying Han , Jason Gunthorpe , Daniel Jordan References: <20200422001422.232330-1-walken@google.com> <20200422001422.232330-7-walken@google.com> From: Vlastimil Babka Message-ID: <6a23fcce-181b-01ad-4a83-ea24d07ac724@suse.cz> Date: Mon, 18 May 2020 12:32:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200422001422.232330-7-walken@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/22/20 2:14 AM, Michel Lespinasse wrote: > Add API for nested write locks and convert the few call sites doing that. > > Signed-off-by: Michel Lespinasse > Reviewed-by: Daniel Jordan Reviewed-by: Vlastimil Babka Perhaps we could even move SINGLE_DEPTH_NESTING into the wrapper? It's unlikely there will be a new user with a different subclass? > --- > arch/um/include/asm/mmu_context.h | 3 ++- > include/linux/mmap_lock.h | 5 +++++ > kernel/fork.c | 2 +- > 3 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h > index 62262c5c7785..17ddd4edf875 100644 > --- a/arch/um/include/asm/mmu_context.h > +++ b/arch/um/include/asm/mmu_context.h > @@ -8,6 +8,7 @@ > > #include > #include > +#include > > #include > > @@ -47,7 +48,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new) > * when the new ->mm is used for the first time. > */ > __switch_mm(&new->context.id); > - down_write_nested(&new->mmap_sem, 1); > + mmap_write_lock_nested(new, SINGLE_DEPTH_NESTING); > uml_setup_stubs(new); > mmap_write_unlock(new); > } > diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h > index 97ac53b66052..a757cb30ae77 100644 > --- a/include/linux/mmap_lock.h > +++ b/include/linux/mmap_lock.h > @@ -11,6 +11,11 @@ static inline void mmap_write_lock(struct mm_struct *mm) > down_write(&mm->mmap_sem); > } > > +static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass) > +{ > + down_write_nested(&mm->mmap_sem, subclass); > +} > + > static inline int mmap_write_lock_killable(struct mm_struct *mm) > { > return down_write_killable(&mm->mmap_sem); > diff --git a/kernel/fork.c b/kernel/fork.c > index 41d3f45c058e..a5d1d20ccba7 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -499,7 +499,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, > /* > * Not linked in yet - no deadlock potential: > */ > - down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING); > + mmap_write_lock_nested(mm, SINGLE_DEPTH_NESTING); > > /* No ordering required: file already has been exposed. */ > RCU_INIT_POINTER(mm->exe_file, get_mm_exe_file(oldmm)); >