Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: "zhen.ni" <zhen.ni@easystack.cn>, Ye Liu <ye.liu@linux.dev>,
	akpm@linux-foundation.org
Cc: surenb@google.com, mhocko@suse.com, jackmanb@google.com,
	hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v11 1/4] mm/page_owner: add print_mode filter
Date: Fri, 3 Jul 2026 10:51:16 +0200	[thread overview]
Message-ID: <16e9bcf6-3e7d-44e9-8b07-00a694c8e493@kernel.org> (raw)
In-Reply-To: <f7bd2660-374c-4b2f-a274-8fd46368abea@easystack.cn>

On 7/3/26 10:14, zhen.ni wrote:
> 
> 
> 在 2026/6/29 17:30, Vlastimil Babka (SUSE) 写道:
>> On 6/29/26 04:59, Ye Liu wrote:
>>>
>>> 在 2026/6/25 12:30, Zhen Ni 写道:
>>> Hi , Zhen
>>> The spinlock in struct page_owner_filter_state is unnecessary and adds significant overhead in the read path.
>>>                                                                                                      
>>> 1. Per-fd isolation: the state is allocated per open() and stored in file->private_data.
>>> There is no cross-fd contention possible.
>>> 2. Hot path cost: the lock is taken for every single page in read_page_owner() and
>>> print_page_owner(). A single read can traverse millions of pages, each paying
>>> spin_lock_irqsave/irqrestore — including interrupt disable — just to read a mode
>>> enum or check a nodemask. This is measurable overhead for no real benefit.
>>> 3. No practical race: nobody writes filter config to an fd while simultaneously reading from it.
>>>                                                                                                      
>>> Suggest dropping the lock entirely.
>>>                                                                                                      
>>> Just my take though — happy to follow whatever the other reviewers prefer here.
>> 
>> I agree. If someone is writing (updating filter) and reading (getting
>> page_owner output) at the same time from multiple threads, they might get
>> inconsistent results but that's getting what you ask for. Importantly it
>> can't cause any crash, AFAICS.
>> 
>> 
> 
> Hi Vlastimil, Ye,
> 
> Thanks for the review. I understand your concerns about the spinlock
> overhead in the read path.
> 
> The spinlock does have its use case: it prevents race conditions when
> multiple threads share the same file descriptor and call read() and
> write() concurrently. While we recommend users use the page_owner_filter
> tool, we cannot exclude the possibility that some users might directly
> share the fd across threads.

Yeah and they will then get inconsistent results even with the spinlock, we
don't have to prevent that.

> That said, I'm open to discussion on whether we need the spinlock. As
> Vlastimil noted, the issue isn't severe enough to cause crashes. My v8
> version didn't have the spinlock - I added it in response to review
> feedback.

It was in response to sashiko. Those suggestions are sometimes useful,
sometimes not. It's good to consider them, but critically, and not implement
blindly.

> So the question is really whether we want to protect multi-threaded fd 

We don't.

> sharing or not. Because, the overhead is small in non-contended cases 
> (single-threaded usage) since there are no competing lock holders.

The atomic operations are still expensive and unnecessary.

Thanks.

> Thanks,
> Zhen



  reply	other threads:[~2026-07-03  8:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25  4:30 [PATCH v11 0/4] mm/page_owner: add per-fd filter infrastructure for print_mode and NUMA filtering Zhen Ni
2026-06-25  4:30 ` [PATCH v11 1/4] mm/page_owner: add print_mode filter Zhen Ni
2026-06-25 18:26   ` Zi Yan
2026-06-25 19:20     ` Andrew Morton
2026-06-25 19:24       ` Zi Yan
2026-06-29  2:59   ` Ye Liu
2026-06-29  9:30     ` Vlastimil Babka (SUSE)
2026-07-03  8:14       ` zhen.ni
2026-07-03  8:51         ` Vlastimil Babka (SUSE) [this message]
2026-06-25  4:30 ` [PATCH v11 2/4] mm/page_owner: add NUMA node filter Zhen Ni
2026-06-25 18:37   ` Zi Yan
2026-06-26  8:20     ` zhen.ni
2026-06-25 19:27   ` Zi Yan
2026-06-25 20:04     ` Andrew Morton
2026-06-25  4:31 ` [PATCH v11 3/4] tools/mm: add page_owner_filter userspace tool Zhen Ni
2026-06-25  4:50   ` Andrew Morton
2026-06-29  8:31     ` zhen.ni
2026-06-25  4:31 ` [PATCH v11 4/4] mm/page_owner: document page_owner filter Zhen Ni
2026-06-25  4:55 ` [PATCH v11 0/4] mm/page_owner: add per-fd filter infrastructure for print_mode and NUMA filtering Andrew Morton
2026-06-25 12:57   ` zhen.ni
2026-06-25 18:22 ` Zi Yan

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=16e9bcf6-3e7d-44e9-8b07-00a694c8e493@kernel.org \
    --to=vbabka@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    --cc=ye.liu@linux.dev \
    --cc=zhen.ni@easystack.cn \
    --cc=ziy@nvidia.com \
    /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