All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	david@redhat.com, shakeel.butt@linux.dev,
	lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
	vbabka@suse.cz, rppt@kernel.org, surenb@google.com,
	donettom@linux.ibm.com, aboorvad@linux.ibm.com, sj@kernel.org,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: fix the inaccurate memory statistics issue for users
Date: Tue, 3 Jun 2025 16:48:08 +0200	[thread overview]
Message-ID: <aD8LKHfCca1wQ5pS@tiehlicka> (raw)
In-Reply-To: <7307bb7a-7c45-43f7-b073-acd9e1389000@linux.alibaba.com>

On Tue 03-06-25 22:22:46, Baolin Wang wrote:
> Let me try to clarify further.
> 
> The 'mm->rss_stat' is updated by using add_mm_counter(),
> dec/inc_mm_counter(), which are all wrappers around
> percpu_counter_add_batch(). In percpu_counter_add_batch(), there is percpu
> batch caching to avoid 'fbc->lock' contention. 

OK, this is exactly the line of argument I was looking for. If _all_
updates done in the kernel are using batching and therefore the lock is
only held every N (percpu_counter_batch) updates then a risk of locking
contention would be decreased. This is worth having a note in the
changelog.

> This patch changes task_mem()
> and task_statm() to get the accurate mm counters under the 'fbc->lock', but
> this will not exacerbate kernel 'mm->rss_stat' lock contention due to the
> the percpu batch caching of the mm counters.
> 
> You might argue that my test cases cannot demonstrate an actual lock
> contention, but they have already shown that there is no significant
> 'fbc->lock' contention when the kernel updates 'mm->rss_stat'.

I was arguing that `top -d 1' doesn't really represent a potential
adverse usage. These proc files are generally readable so I would be
expecting something like busy loop read while process tries to update
counters to see the worst case scenario. If that is barely visible then
we can conclude a normal use wouldn't even notice.

See my point?

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2025-06-03 14:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-24  1:59 [PATCH] mm: fix the inaccurate memory statistics issue for users Baolin Wang
2025-05-30  3:53 ` Andrew Morton
2025-05-30 13:39   ` Michal Hocko
2025-05-30 23:00     ` Andrew Morton
2025-06-03  8:08     ` Baolin Wang
2025-06-03  8:15       ` Michal Hocko
2025-06-03  8:32         ` Baolin Wang
2025-06-03 10:28           ` Michal Hocko
2025-06-03 14:22             ` Baolin Wang
2025-06-03 14:48               ` Michal Hocko [this message]
2025-06-03 17:29                 ` Shakeel Butt
2025-06-04 12:46                   ` Baolin Wang
2025-06-04 13:46                     ` Vlastimil Babka
2025-06-04 14:16                       ` Baolin Wang
2025-06-04 14:27                         ` Vlastimil Babka
2025-06-04 16:54                         ` Shakeel Butt
2025-06-05  0:48                           ` Baolin Wang
2025-06-05  6:32                             ` Michal Hocko

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=aD8LKHfCca1wQ5pS@tiehlicka \
    --to=mhocko@suse.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=aboorvad@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=donettom@linux.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=sj@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.