lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <81F8212D-9C00-4AF2-8D04-79059283B47F@linux.dev>
Date: Sun, 11 Jan 2026 22:05:40 +0800
From: Yajun Deng <yajun.deng@...ux.dev>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: vbabka@...e.cz,
 surenb@...gle.com,
 mhocko@...e.com,
 jackmanb@...gle.com,
 hannes@...xchg.org,
 ziy@...dia.com,
 linux-mm@...ck.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/page_alloc: Avoid duplicate NR_FREE_PAGES updates in
 move_to_free_list()



> 2026年1月11日 08:10,Andrew Morton <akpm@...ux-foundation.org> 写道:
> 
> On Fri,  9 Jan 2026 18:51:21 +0800 Yajun Deng <yajun.deng@...ux.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.
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ