From: Miaohe Lin <linmiaohe@huawei.com>
To: Matthew Wilcox <willy@infradead.org>
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()
Date: Thu, 17 Feb 2022 21:44:13 +0800 [thread overview]
Message-ID: <b18c8067-6709-6589-b52a-0e38150fa322@huawei.com> (raw)
In-Reply-To: <Yg5OaP+4hclrUcB9@casper.infradead.org>
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.
>
> .
>
next prev parent reply other threads:[~2022-02-17 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 11:09 [PATCH] mm/mmu_notifiers: use helper function mmu_notifier_synchronize() Miaohe Lin
2022-02-17 13:32 ` Matthew Wilcox
2022-02-17 13:44 ` Miaohe Lin [this message]
2022-02-17 15:50 ` Jason Gunthorpe
2022-02-18 1:49 ` Miaohe Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b18c8067-6709-6589-b52a-0e38150fa322@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).