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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6E25C433F5 for ; Thu, 17 Feb 2022 13:32:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 578E16B0078; Thu, 17 Feb 2022 08:32:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 528496B007B; Thu, 17 Feb 2022 08:32:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419D96B007D; Thu, 17 Feb 2022 08:32:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 3386C6B0078 for ; Thu, 17 Feb 2022 08:32:30 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id ED2218249980 for ; Thu, 17 Feb 2022 13:32:29 +0000 (UTC) X-FDA: 79152361218.17.1AD3C65 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 78464100007 for ; Thu, 17 Feb 2022 13:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CZ8Mw6CSYsNw+QBWgSmOSeP2EMv4VEwmQANgBJD4siA=; b=vq9OWPBDhsEYSwxAwZq+df0bTz DcYCVy68zR0dOGH89lvvNA7BuaMu/iu9qOvr17tUKEJEFdjijP85e/rypQKgR/tXu2u770xuxXTHf xa7e9G+OkoD8Hxdk7lcx6CP1m23vRjtyY/JMppTO9XsdpTu6oKbWk0yzsrSKjOYintraFxySpzTpB zW+ody+buoavK4qgQP7LC2YM6xX5hkt+EPWj/zhKg0YZUvqNMF9VIJ2g53qz+ZeA4dsgFaN18usBC hLs5c7iTwK8WQqgbXZHdB7qSgu6CcJjts/zv/y/g40zBFWy3JDnXlUr9AhtjFM6i61JRiJVa57S15 paFJZAEQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKgtU-00FduW-8E; Thu, 17 Feb 2022 13:32:24 +0000 Date: Thu, 17 Feb 2022 13:32:24 +0000 From: Matthew Wilcox To: Miaohe Lin Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mmu_notifiers: use helper function mmu_notifier_synchronize() Message-ID: References: <20220217110948.35477-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220217110948.35477-1-linmiaohe@huawei.com> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 78464100007 X-Stat-Signature: cif46sp7zhf1q69xkhj84df48m4mohk6 X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vq9OWPBD; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1645104749-929918 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, Feb 17, 2022 at 07:09:48PM +0800, Miaohe Lin wrote: > Use helper function mmu_notifier_synchronize() to ensure all mmu_notifiers > are freed. Minor readability improvement. Is it though? > @@ -334,15 +334,15 @@ static void mn_hlist_release(struct mmu_notifier_subscriptions *subscriptions, > srcu_read_unlock(&srcu, id); > > /* > - * synchronize_srcu here prevents mmu_notifier_release from returning to > - * exit_mmap (which would proceed with freeing all pages in the mm) > - * until the ->release method returns, if it was invoked by > - * mmu_notifier_unregister. > + * mmu_notifier_synchronize here prevents mmu_notifier_release from > + * returning to exit_mmap (which would proceed with freeing all pages > + * in the mm) until the ->release method returns, if it was invoked > + * by mmu_notifier_unregister. > * > * The notifier_subscriptions can't go away from under us because > * one mm_count is held by exit_mmap. > */ > - synchronize_srcu(&srcu); > + mmu_notifier_synchronize(); We just read_unlocked the &srcu. Now I have to jump to the definition of mmu_notifier_synchronize() to find out that it's now waiting for the very same srcu. I think this abstraction makes the code harder to read, not easier. > } > > void __mmu_notifier_release(struct mm_struct *mm) > @@ -851,7 +851,7 @@ void mmu_notifier_unregister(struct mmu_notifier *subscription, > * Wait for any running method to finish, of course including > * ->release if it was run by mmu_notifier_release instead of us. > */ > - synchronize_srcu(&srcu); > + mmu_notifier_synchronize(); Same here.