From: Chen Yu <yu.c.chen@intel.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Tim Chen <tim.c.chen@intel.com>,
Mel Gorman <mgorman@techsingularity.net>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
"Gautham R . Shenoy" <gautham.shenoy@amd.com>,
Chen Yu <yu.chen.surf@gmail.com>, Aaron Lu <aaron.lu@intel.com>,
<linux-kernel@vger.kernel.org>, <void@manifault.com>,
Matt Fleming <matt@readmodwrite.com>
Subject: Re: [RFC PATCH 0/7] Optimization to reduce the cost of newidle balance
Date: Fri, 19 Jul 2024 01:01:25 +0800 [thread overview]
Message-ID: <ZplKZQYpqILia+aW@chenyu5-mobl2> (raw)
In-Reply-To: <29172279-ac5e-4860-921f-2905639dd8bf@amd.com>
Hi Prateek,
On 2024-07-18 at 14:58:30 +0530, K Prateek Nayak wrote:
> Hello Peter,
>
> On 7/17/2024 5:47 PM, Peter Zijlstra wrote:
> > On Thu, Jul 27, 2023 at 10:33:58PM +0800, Chen Yu wrote:
> > > Hi,
> > >
> > > This is the second version of the newidle balance optimization[1].
> > > It aims to reduce the cost of newidle balance which is found to
> > > occupy noticeable CPU cycles on some high-core count systems.
> > >
> > > For example, when running sqlite on Intel Sapphire Rapids, which has
> > > 2 x 56C/112T = 224 CPUs:
> > >
> > > 6.69% 0.09% sqlite3 [kernel.kallsyms] [k] newidle_balance
> > > 5.39% 4.71% sqlite3 [kernel.kallsyms] [k] update_sd_lb_stats
> > >
> > > To mitigate this cost, the optimization is inspired by the question
> > > raised by Tim:
> > > Do we always have to find the busiest group and pull from it? Would
> > > a relatively busy group be enough?
> >
> > So doesn't this basically boil down to recognising that new-idle might
> > not be the same as regular load-balancing -- we need any task, fast,
> > rather than we need to make equal load.
> >
> > David's shared runqueue patches did the same, they re-imagined this very
> > path.
> >
> > Now, David's thing went side-ways because of some regression that wasn't
> > further investigated.
>
> In case of SHARED_RUNQ, I suspected frequent wakeup-sleep pattern of
> hackbench at lower utilization seemed to raise some contention somewhere
> but perf profile with IBS showed nothing specific and I left it there.
>
> I revisited this again today and found this interesting data for perf
> bench sched messaging running with one group pinned to one LLC domain on
> my system:
>
> - NO_SHARED_RUNQ
>
> $ time ./perf bench sched messaging -p -t -l 100000 -g 1
> # Running 'sched/messaging' benchmark:
> # 20 sender and receiver threads per group
> # 1 groups == 40 threads run
> Total time: 3.972 [sec] (*)
> real 0m3.985s
> user 0m6.203s (*)
> sys 1m20.087s (*)
>
> $ sudo perf record -C 0-7,128-135 --off-cpu -- taskset -c 0-7,128-135 perf bench sched messaging -p -t -l 100000 -g 1
> $ sudo perf report --no-children
>
> Samples: 128 of event 'offcpu-time', Event count (approx.): 96,216,883,498 (*)
> Overhead Command Shared Object Symbol
> + 51.43% sched-messaging libc.so.6 [.] read
> + 44.94% sched-messaging libc.so.6 [.] __GI___libc_write
> + 3.60% sched-messaging libc.so.6 [.] __GI___futex_abstimed_wait_cancelable64
> 0.03% sched-messaging libc.so.6 [.] __poll
> 0.00% sched-messaging perf [.] sender
>
>
> - SHARED_RUNQ
>
> $ time taskset -c 0-7,128-135 perf bench sched messaging -p -t -l 100000 -g 1
> # Running 'sched/messaging' benchmark:
> # 20 sender and receiver threads per group
> # 1 groups == 40 threads run
> Total time: 48.171 [sec] (*)
> real 0m48.186s
> user 0m5.409s (*)
> sys 0m41.185s (*)
>
> $ sudo perf record -C 0-7,128-135 --off-cpu -- taskset -c 0-7,128-135 perf bench sched messaging -p -t -l 100000 -g 1
> $ sudo perf report --no-children
>
> Samples: 157 of event 'offcpu-time', Event count (approx.): 5,882,929,338,882 (*)
> Overhead Command Shared Object Symbol
> + 47.49% sched-messaging libc.so.6 [.] read
> + 46.33% sched-messaging libc.so.6 [.] __GI___libc_write
> + 2.40% sched-messaging libc.so.6 [.] __GI___futex_abstimed_wait_cancelable64
> + 1.08% snapd snapd [.] 0x000000000006caa3
> + 1.02% cron libc.so.6 [.] clock_nanosleep@GLIBC_2.2.5
> + 0.86% containerd containerd [.] runtime.futex.abi0
> + 0.82% containerd containerd [.] runtime/internal/syscall.Syscall6
>
>
> (*) The runtime has bloated massively but both "user" and "sys" time
> are down and the "offcpu-time" count goes up with SHARED_RUNQ.
>
> There seems to be a corner case that is not accounted for but I'm not
> sure where it lies currently. P.S. I tested this on a v6.8-rc4 kernel
> since that is what I initially tested the series on but I can see the
> same behavior when I rebased the changed on the current v6.10-rc5 based
> tip:sched/core.
>
> >
> > But it occurs to me this might be the same thing that Prateek chased
> > down here:
> >
> > https://lkml.kernel.org/r/20240710090210.41856-1-kprateek.nayak@amd.com
> >
> > Hmm ?
>
> Without the nohz_csd_func fix and the SM_IDLE fast-path (Patch 1 and 2),
> currently, the scheduler depends on the newidle_balance to pull tasks to
> an idle CPU. Vincent had pointed it out on the first RCF to tackle the
> problem that tried to do what SM_IDLE does but for fair class alone:
>
> https://lore.kernel.org/all/CAKfTPtC446Lo9CATPp7PExdkLhHQFoBuY-JMGC7agOHY4hs-Pw@mail.gmail.com/
>
> It shouldn't be too frequent but it could be the reason why
> newidle_balance() might jump up in traces, especially if it decides to
> scan a domain with large number of CPUs (NUMA1/NUMA2 in Matt's case,
> perhaps the PKG/NUMA in the case Chenyu was investigating initially).
>
Yes, this is my understanding too, I'll apply your patches and have a re-test.
thanks,
Chenyu
next prev parent reply other threads:[~2024-07-18 17:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 14:33 [RFC PATCH 0/7] Optimization to reduce the cost of newidle balance Chen Yu
2023-07-27 14:34 ` [RFC PATCH 1/7] sched/topology: Assign sd_share for all non NUMA sched domains Chen Yu
2023-07-27 14:34 ` [RFC PATCH 2/7] sched/topology: Introduce nr_groups in sched_domain to indicate the number of groups Chen Yu
2023-07-27 14:34 ` [RFC PATCH 3/7] sched/fair: Save a snapshot of sched domain total_load and total_capacity Chen Yu
2023-07-27 14:35 ` [RFC PATCH 4/7] sched/fair: Calculate the scan depth for idle balance based on system utilization Chen Yu
2023-08-25 6:02 ` Shrikanth Hegde
2023-08-30 15:30 ` Chen Yu
2023-07-27 14:35 ` [RFC PATCH 5/7] sched/fair: Adjust the busiest group scanning depth in idle load balance Chen Yu
2023-08-25 6:00 ` Shrikanth Hegde
2023-08-30 15:35 ` Chen Yu
2023-07-27 14:35 ` [RFC PATCH 6/7] sched/fair: Pull from a relatively busy group during newidle balance Chen Yu
2023-07-27 14:35 ` [RFC PATCH 7/7] sched/stats: Track the scan number of groups during load balance Chen Yu
2023-08-25 7:48 ` [RFC PATCH 0/7] Optimization to reduce the cost of newidle balance Shrikanth Hegde
2023-08-30 15:26 ` Chen Yu
2023-09-10 7:51 ` Shrikanth Hegde
2024-07-16 14:16 ` Matt Fleming
2024-07-17 3:52 ` Chen Yu
2024-07-17 15:31 ` Matt Fleming
2024-07-17 12:17 ` Peter Zijlstra
2024-07-18 9:28 ` K Prateek Nayak
2024-07-18 17:01 ` Chen Yu [this message]
2024-07-18 16:57 ` Chen Yu
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=ZplKZQYpqILia+aW@chenyu5-mobl2 \
--to=yu.c.chen@intel.com \
--cc=aaron.lu@intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=gautham.shenoy@amd.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@readmodwrite.com \
--cc=mgorman@techsingularity.net \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tim.c.chen@intel.com \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=yu.chen.surf@gmail.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 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.