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 8EDAFC433EF for ; Thu, 17 Feb 2022 13:44:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE1F86B007B; Thu, 17 Feb 2022 08:44:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E912F6B007D; Thu, 17 Feb 2022 08:44:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D312C6B007E; Thu, 17 Feb 2022 08:44:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id C258D6B007B for ; Thu, 17 Feb 2022 08:44:19 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 827AF9677E for ; Thu, 17 Feb 2022 13:44:19 +0000 (UTC) X-FDA: 79152391038.17.0AF7E36 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf26.hostedemail.com (Postfix) with ESMTP id 92C30140008 for ; Thu, 17 Feb 2022 13:44:18 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JzwtH0zfSzZdNk; Thu, 17 Feb 2022 21:39:51 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Thu, 17 Feb 2022 21:44:14 +0800 Subject: Re: [PATCH] mm/mmu_notifiers: use helper function mmu_notifier_synchronize() To: Matthew Wilcox CC: , , References: <20220217110948.35477-1-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: Date: Thu, 17 Feb 2022 21:44:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Stat-Signature: y48e8xmkch8t5kwprj1ckwetjzwge9ao X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 92C30140008 Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1645105458-233158 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 2022/2/17 21:32, Matthew Wilcox wrote: > 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. > >From this point of view, this helper would disturb the understanding of the code. Many thanks for pointing this out. Sorry for my mindlessness. >> } >> >> 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. > > . >