From: Qi Zheng <zhengqi.arch@bytedance.com>
To: Rik van Riel <riel@surriel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
David Hildenbrand <david@redhat.com>,
kernel test robot <oliver.sang@intel.com>,
oe-lkp@lists.linux.dev, lkp@intel.com,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
David Rientjes <rientjes@google.com>,
Hugh Dickins <hughd@google.com>, Jann Horn <jannh@google.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Matthew Wilcox <willy@infradead.org>,
Mel Gorman <mgorman@suse.de>, Muchun Song <muchun.song@linux.dev>,
Peter Xu <peterx@redhat.com>, Will Deacon <will@kernel.org>,
Zach O'Keefe <zokeefe@google.com>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [linus:master] [x86] 4817f70c25: stress-ng.mmapaddr.ops_per_sec 63.0% regression
Date: Wed, 29 Jan 2025 16:14:01 +0800 [thread overview]
Message-ID: <14159fb4-0c59-4653-9265-73f415e70063@bytedance.com> (raw)
In-Reply-To: <2212111cad3180948cf388a7e5c8689df0fdda08.camel@surriel.com>
Hi Rik,
On 2025/1/29 02:35, Rik van Riel wrote:
> On Wed, 2025-01-29 at 01:06 +0800, Qi Zheng wrote:
>>
>> I did reproduce the performance regression using the following test
>> program:
>>
>> stress-ng --timeout 60 --times --verify --metrics --no-rand-seed
>> --mmapaddr 64
>>
>> And its call stack is as follows:
>>
>> bpftrace -e 'k:_raw_spin_unlock_irqrestore {@[kstack,comm]=count();}
>> interval:s:1 {exit();}'
>>
>> @[
>> _raw_spin_unlock_irqrestore+5
>> free_one_page+85
>> rcu_do_batch+424
>> rcu_core+401
>> handle_softirqs+204
>> irq_exit_rcu+208
>
> That looks like the RCU freeing somehow bypassing the
> per-cpu-pages, and hitting the zone->lock at page free
> time, while regular freeing usually puts pages in the
> CPU-local free page cache, without the lock?
Take the following call stack as an example:
@[
_raw_spin_unlock_irqrestore+5
free_one_page+85
tlb_remove_table_rcu+140
rcu_do_batch+424
rcu_core+401
handle_softirqs+204
irq_exit_rcu+208
sysvec_apic_timer_interrupt+113
asm_sysvec_apic_timer_interrupt+26
_raw_spin_unlock_irqrestore+29
get_page_from_freelist+2014
__alloc_frozen_pages_noprof+364
alloc_pages_mpol+123
alloc_pages_noprof+14
get_free_pages_noprof+17
__x64_sys_mincore+141
do_syscall_64+98
entry_SYSCALL_64_after_hwframe+118
, stress-ng-mmapa]: 5301
It looks like the following happened:
get_page_from_freelist
--> rmqueue
--> rmqueue_pcplist
--> pcp_spin_trylock (hold the pcp lock)
__rmqueue_pcplist
--> rmqueue_bulk
--> spin_lock_irqsave(&zone->lock)
__rmqueue
spin_unlock_irqrestore(&zone->lock)
<run softirq at this time>
tlb_remove_table_rcu
--> free_frozen_pages
--> pcp = pcp_spin_trylock (failed!!!)
if (!pcp)
free_one_page
It seems that the pcp lock is held when doing tlb_remove_table_rcu(), so
trylock fails, then bypassing PCP and calling free_one_page() directly,
which leads to the hot spot of zone lock.
As for the regular freeing, since the freeing operation will not be
performed in the softirq, the above situation will not occur.
Right?
>
> I'm not quite sure why this would be happening, though.
>
> Maybe the RCU batches are too big for the PCPs to
> hold them?
>
> If that is the case, chances are more code paths are
> hitting that issue, and we should just fix it, rather
> than trying to bypass it.
>
> Maybe the reason is more simple than that?
>
> I have not found a place where it explicitly bypasses
> the PCPs, but who knows?
>
next prev parent reply other threads:[~2025-01-29 8:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 9:57 kernel test robot
2025-01-28 10:05 ` David Hildenbrand
2025-01-28 11:31 ` Peter Zijlstra
2025-01-28 11:39 ` David Hildenbrand
2025-01-28 13:28 ` Peter Zijlstra
2025-01-28 13:42 ` David Hildenbrand
2025-01-28 15:59 ` Qi Zheng
2025-01-28 17:06 ` Qi Zheng
2025-01-28 17:51 ` Qi Zheng
2025-01-28 18:35 ` Rik van Riel
2025-01-29 8:14 ` Qi Zheng [this message]
2025-01-29 15:23 ` Rik van Riel
2025-01-29 15:59 ` Rik van Riel
2025-01-29 16:12 ` Matthew Wilcox
2025-01-29 16:14 ` Rik van Riel
2025-01-29 16:36 ` Paul E. McKenney
2025-01-29 16:53 ` Rik van Riel
2025-01-29 17:33 ` Qi Zheng
2025-01-29 17:53 ` Qi Zheng
2025-01-29 19:19 ` Paul E. McKenney
2025-01-31 21:11 ` Rik van Riel
2025-02-01 3:44 ` Qi Zheng
2025-01-29 16:53 ` Frederic Weisbecker
2025-01-29 16:57 ` Rik van Riel
2025-01-29 17:23 ` Frederic Weisbecker
2025-01-29 17:28 ` Paul E. McKenney
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=14159fb4-0c59-4653-9265-73f415e70063@bytedance.com \
--to=zhengqi.arch@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=dan.carpenter@linaro.org \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=luto@kernel.org \
--cc=mgorman@suse.de \
--cc=muchun.song@linux.dev \
--cc=oe-lkp@lists.linux.dev \
--cc=oliver.sang@intel.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=rientjes@google.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=zokeefe@google.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
all inboxes | Powered by JetHome®