public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Yajun Deng <yajun.deng@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: vbabka@suse.cz, 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] mm/page_alloc: Avoid duplicate NR_FREE_PAGES updates in move_to_free_list()
Date: Sun, 11 Jan 2026 22:05:40 +0800	[thread overview]
Message-ID: <81F8212D-9C00-4AF2-8D04-79059283B47F@linux.dev> (raw)
In-Reply-To: <20260110161048.0aa9c7e32af3e690a671ef8d@linux-foundation.org>



> 2026年1月11日 08:10,Andrew Morton <akpm@linux-foundation.org> 写道:
> 
> On Fri,  9 Jan 2026 18:51:21 +0800 Yajun Deng <yajun.deng@linux.dev> wrote:
> 
>> In move_to_free_list(), when a page block changes its migration type,
>> we need to update free page counts for both the old and new types.
>> Originally, this was done by two calls to account_freepages(), which
>> updates NR_FREE_PAGES and also type-specific counters. However, this
>> causes NR_FREE_PAGES to be updated twice, while the net change is zero
>> in most cases.
>> 
>> This patch introduces a new function account_freepages_both() that
>> updates the statistics for both old and new migration types in one go.
>> It avoids the double update of NR_FREE_PAGES by computing the net change
>> only when the isolation status changes.
>> 
>> The optimization avoid duplicate NR_FREE_PAGES updates in
>> move_to_free_list().
> 
> Seems nice and LGTM.
> 
>> +static inline void account_freepages_both(struct zone *zone, int nr_pages,
>> +  int old_mt, int new_mt)
>> +{
>> + lockdep_assert_held(&zone->lock);
>> +
>> + bool old_isolated = is_migrate_isolate(old_mt);
>> + bool new_isolated = is_migrate_isolate(new_mt);
> 
> We do permit C99 definition ordering nowadays, but I do think our eyes
> and brains prefer the old-school style.
> 
> So here I'd personally prefer
> 
> bool old_isolated = is_migrate_isolate(old_mt);
> bool new_isolated = is_migrate_isolate(new_mt);
> 
> lockdep_assert_held(&zone->lock);
> 
> 
> Or simply remove the assertion - it doesn't look useful to me.  If we
> aren't holding zone->lock here then the kernel is so screwed up we
> should all just go home.
> 
> 
Okay, I’ll remove the assertion.

Thanks.
> 



      reply	other threads:[~2026-01-11 14:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 10:51 [PATCH] mm/page_alloc: Avoid duplicate NR_FREE_PAGES updates in move_to_free_list() Yajun Deng
2026-01-09 16:31 ` Joshua Hahn
2026-01-11 13:47   ` Yajun Deng
2026-01-11 14:24     ` Joshua Hahn
2026-01-11 14:49       ` Yajun Deng
2026-01-11  0:10 ` Andrew Morton
2026-01-11 14:05   ` Yajun Deng [this message]

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=81F8212D-9C00-4AF2-8D04-79059283B47F@linux.dev \
    --to=yajun.deng@linux.dev \
    --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=vbabka@suse.cz \
    --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