Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1720724 > unrolled thread
| Started by | Joel Fernandes <joelaf@google.com> |
|---|---|
| First post | 2017-08-27 03:10 +0200 |
| Last post | 2017-09-25 01:50 +0200 |
| Articles | 20 on this page of 24 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Joel Fernandes <joelaf@google.com> - 2017-08-27 03:10 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-27 07:50 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-27 08:10 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Joel Fernandes <joelaf@google.com> - 2017-08-27 08:40 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-27 09:20 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-27 20:10 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Joel Fernandes <joelaf@google.com> - 2017-08-28 07:30 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-28 08:20 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-28 08:50 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Joel Fernandes <joelaf@google.com> - 2017-08-28 18:30 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-28 19:20 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Joel Fernandes <joelaf@google.com> - 2017-08-27 08:30 +0200
Re: [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag Mike Galbraith <efault@gmx.de> - 2017-08-27 09:00 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Joel Fernandes <joelaf@google.com> - 2017-09-10 19:00 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Mike Galbraith <efault@gmx.de> - 2017-09-11 05:00 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Joel Fernandes <joelaf@google.com> - 2017-09-11 08:40 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Mike Galbraith <efault@gmx.de> - 2017-09-11 10:10 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Rik van Riel <riel@redhat.com> - 2017-09-14 18:00 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Mike Galbraith <efault@gmx.de> - 2017-09-15 06:10 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Joel Fernandes <joelaf@google.com> - 2017-09-17 08:50 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Mike Galbraith <efault@gmx.de> - 2017-09-17 18:50 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Joel Fernandes <joelaf@google.com> - 2017-09-17 23:50 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Mike Galbraith <efault@gmx.de> - 2017-09-18 07:40 +0200
Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression Joel Fernandes <joelaf@google.com> - 2017-09-25 01:50 +0200
Page 1 of 2 [1] 2 Next page →
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-08-27 03:10 +0200 |
| Subject | [PATCH RFC/RFT] sched/fair: Improve the behavior of sync flag |
| Message-ID | <uiUfn-nC-1@gated-at.bofh.it> |
Binder (Android's IPC mechanism) which uses sync wake ups during synchronous
transactions to the scheduler to indicate that the waker is about to sleep
soon. The current wake up path can improved when the sync flag is passed
resulting in higher binder performance. In this patch we more strongly wake up
the wakee on the waker's CPU if sync is passed based on a few other conditions
such as wake_cap, cpus allowed. wake_wide is checked only after the sync flag
check so that it doesn't mess up sync. Binder throughput tests see good
improvement improvement when waking up wakee (calling thread) on the waker's
CPU (called thread) with this flag. Some tests results are below:
On an 8-core ARM64 system, following is data from running
hwbinderThroughputTest with variable number of workers and services (the
workers are clients calling into the service threads and sleeps till the
service replies to them).
2 workers calling into 4 services:
Without patch: iterations per sec: 62757
With patch: iterations per sec: 75236 (+19.88%)
4 workers calling into 2 services:
Without patch: iterations per sec: 82379
With patch: iterations per sec: 85829 (+4.18%)
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Josef Bacik <jbacik@fb.com>
Cc: Juri Lelli <Juri.Lelli@arm.com>
Cc: Brendan Jackman <brendan.jackman@arm.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Joel Fernandes <joelaf@google.com>
---
Rik, as we discussed on IRC I am hoping that the lkp bot will also do its own
tests with this patch. I'm not sure if anything special needs to be in the
subject line to trigger the tests, if that's the case let me know and thanks!
kernel/sched/fair.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index eca6a57527f9..808571bc8ebe 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6276,10 +6276,19 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
int want_affine = 0;
int sync = wake_flags & WF_SYNC;
- if (sd_flag & SD_BALANCE_WAKE) {
+ if (sd_flag & SD_BALANCE_WAKE)
record_wakee(p);
- want_affine = !wake_wide(p) && !wake_cap(p, cpu, prev_cpu)
- && cpumask_test_cpu(cpu, &p->cpus_allowed);
+
+ if ((sd_flag & SD_BALANCE_WAKE) && !wake_cap(p, cpu, prev_cpu)
+ && cpumask_test_cpu(cpu, &p->cpus_allowed)) {
+ /*
+ * WF_SYNC indicates waker will goto sleep, incase waker is
+ * the only one running, select the waker's CPU to run wakee
+ */
+ if (sync && cpu_rq(cpu)->nr_running < 2)
+ return cpu;
+
+ want_affine = !wake_wide(p);
}
rcu_read_lock();
--
2.14.1.342.g6490525c54-goog
[toc] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-27 07:50 +0200 |
| Message-ID | <uiYCl-3nF-1@gated-at.bofh.it> |
| In reply to | #1720724 |
On Sat, 2017-08-26 at 18:02 -0700, Joel Fernandes wrote: > Binder (Android's IPC mechanism) which uses sync wake ups during synchronous > transactions to the scheduler to indicate that the waker is about to sleep > soon. The current wake up path can improved when the sync flag is passed > resulting in higher binder performance. In this patch we more strongly wake up > the wakee on the waker's CPU if sync is passed based on a few other conditions > such as wake_cap, cpus allowed. wake_wide is checked only after the sync flag > check so that it doesn't mess up sync. Binder throughput tests see good > improvement improvement when waking up wakee (calling thread) on the waker's > CPU (called thread) with this flag. Some tests results are below: Sync is not a contract, it's a hint. If you really want sync behavior, you need to create a contract signed in blood to signal that you really really are passing the baton. Sync wakeups make tons of sense when the waker really really has one and only one wakee, AND really really is going to sleep immediately, with zero overlap that can be converted to throughput by waking to an idle core. With no L2 misses to slow them down, pass the baton microbenchmarks that do no real work can generate impressive ping-pong numbers... but the real world tends to do more than just bat a byte around endlessly. The existing hint is not strong enough for your needs, it's current users may overlap with their wakee(s), change their minds about sleeping (be handed more work to do) etc etc. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-27 08:10 +0200 |
| Message-ID | <uiYVH-3JY-3@gated-at.bofh.it> |
| In reply to | #1720742 |
On Sun, 2017-08-27 at 07:44 +0200, Mike Galbraith wrote: > On Sat, 2017-08-26 at 18:02 -0700, Joel Fernandes wrote: > > Binder (Android's IPC mechanism) which uses sync wake ups during synchronous > > transactions to the scheduler to indicate that the waker is about to sleep > > soon. The current wake up path can improved when the sync flag is passed > > resulting in higher binder performance. In this patch we more strongly wake up > > the wakee on the waker's CPU if sync is passed based on a few other conditions > > such as wake_cap, cpus allowed. wake_wide is checked only after the sync flag > > check so that it doesn't mess up sync. Binder throughput tests see good > > improvement improvement when waking up wakee (calling thread) on the waker's > > CPU (called thread) with this flag. Some tests results are below: > > Sync is not a contract, it's a hint. If you really want sync behavior, > you need to create a contract signed in blood to signal that you really > really are passing the baton. P.S. to get the most bang for your synchronous buck, you want a preemptive wakeup.. but that butts heads with the fair engine. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-08-27 08:40 +0200 |
| Message-ID | <uiZoJ-3VU-3@gated-at.bofh.it> |
| In reply to | #1720747 |
Hi Mike, On Sat, Aug 26, 2017 at 11:08 PM, Mike Galbraith <efault@gmx.de> wrote: > On Sun, 2017-08-27 at 07:44 +0200, Mike Galbraith wrote: >> On Sat, 2017-08-26 at 18:02 -0700, Joel Fernandes wrote: >> > Binder (Android's IPC mechanism) which uses sync wake ups during synchronous >> > transactions to the scheduler to indicate that the waker is about to sleep >> > soon. The current wake up path can improved when the sync flag is passed >> > resulting in higher binder performance. In this patch we more strongly wake up >> > the wakee on the waker's CPU if sync is passed based on a few other conditions >> > such as wake_cap, cpus allowed. wake_wide is checked only after the sync flag >> > check so that it doesn't mess up sync. Binder throughput tests see good >> > improvement improvement when waking up wakee (calling thread) on the waker's >> > CPU (called thread) with this flag. Some tests results are below: >> >> Sync is not a contract, it's a hint. If you really want sync behavior, >> you need to create a contract signed in blood to signal that you really >> really are passing the baton. > > P.S. to get the most bang for your synchronous buck, you want a > preemptive wakeup.. but that butts heads with the fair engine. > By preemptive wake up I guess you mean the waker would give up its time slice and let the wakee use it? That's a cool idea but I agree it would be against the fair task behavior. Also about real world benchmarks, in Android we have usecases that show that the graphics performance and we have risk of frame drops if we don't use the sync flag so this is a real world need. Binder is the backbone of Android and for the benefit of these usecases, Android kernels make sync a contract (written in blood as you put it). thanks, -Joel > -Mike
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-27 09:20 +0200 |
| Message-ID | <uj01s-4qC-5@gated-at.bofh.it> |
| In reply to | #1720753 |
On Sat, 2017-08-26 at 23:39 -0700, Joel Fernandes wrote: > > > P.S. to get the most bang for your synchronous buck, you want a > > preemptive wakeup.. but that butts heads with the fair engine. > > > > By preemptive wake up I guess you mean the waker would give up its > time slice and let the wakee use it? That's a cool idea but I agree it > would be against the fair task behavior. No, I meant a preemption, that being the cheapest switch. Any mucking about with vruntime is a non-starter (NAK bait), making guaranteed preemption a non-starter. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-27 20:10 +0200 |
| Message-ID | <ujaat-2MR-5@gated-at.bofh.it> |
| In reply to | #1720753 |
On Sat, 2017-08-26 at 23:39 -0700, Joel Fernandes wrote: > > Also about real world benchmarks, in Android we have usecases that > show that the graphics performance and we have risk of frame drops if > we don't use the sync flag so this is a real world need. That likely has everything to do with cpufreq not realizing that your CPUs really are quite busy when scheduling cross core at fairly high frequency, and not clocking up properly. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-08-28 07:30 +0200 |
| Message-ID | <ujkMy-1pK-19@gated-at.bofh.it> |
| In reply to | #1720900 |
Hi Mike, On Sun, Aug 27, 2017 at 11:07 AM, Mike Galbraith <efault@gmx.de> wrote: > On Sat, 2017-08-26 at 23:39 -0700, Joel Fernandes wrote: >> >> Also about real world benchmarks, in Android we have usecases that >> show that the graphics performance and we have risk of frame drops if >> we don't use the sync flag so this is a real world need. > > That likely has everything to do with cpufreq not realizing that your > CPUs really are quite busy when scheduling cross core at fairly high > frequency, and not clocking up properly. > I'm glad you brought this point up. Since Android O, the userspace processes are much more split across procedure calls due to a feature called treble (which does this for security, modularity etc). Due to this, a lot of things that were happening within a process boundary happen now across process boundaries over the binder bus. Early on folks noticed that this caused performance issues without sync flag being used as a more strong hint. This can happen when there are 2 threads are in different frequency domains on different CPUs and are communicating over binder, due to this the combined load of both threads is divided between the individual CPUs and causes them to run at lower frequency. Where as if they are running together on the same CPUs, then they would run at a higher frequency and perform better as their combined load would run at a higher frequency. So a stronger sync actually helps this case if we're careful about using it when possible. thanks, -Joel > -Mike
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-28 08:20 +0200 |
| Message-ID | <ujlyW-1YD-17@gated-at.bofh.it> |
| In reply to | #1721030 |
On Sun, 2017-08-27 at 22:27 -0700, Joel Fernandes wrote: > Hi Mike, > > On Sun, Aug 27, 2017 at 11:07 AM, Mike Galbraith <efault@gmx.de> wrote: > > On Sat, 2017-08-26 at 23:39 -0700, Joel Fernandes wrote: > >> > >> Also about real world benchmarks, in Android we have usecases that > >> show that the graphics performance and we have risk of frame drops if > >> we don't use the sync flag so this is a real world need. > > > > That likely has everything to do with cpufreq not realizing that your > > CPUs really are quite busy when scheduling cross core at fairly high > > frequency, and not clocking up properly. > > > > I'm glad you brought this point up. Since Android O, the userspace > processes are much more split across procedure calls due to a feature > called treble (which does this for security, modularity etc). Due to > this, a lot of things that were happening within a process boundary > happen now across process boundaries over the binder bus. Early on > folks noticed that this caused performance issues without sync flag > being used as a more strong hint. This can happen when there are 2 > threads are in different frequency domains on different CPUs and are > communicating over binder, due to this the combined load of both > threads is divided between the individual CPUs and causes them to run > at lower frequency. Where as if they are running together on the same > CPUs, then they would run at a higher frequency and perform better as > their combined load would run at a higher frequency. So a stronger > sync actually helps this case if we're careful about using it when > possible. Sure, but isn't that really a cpufreq issue? We schedule cross core quite aggressively for obvious reasons. Now on mostly idle handheld devices, you may get better battery life by stacking tasks a bit more, in which case a sync-me-harder flag may be what you really want/need, but with modern CPUs, I'm kinda skeptical of that, would have to see cold hard numbers to become a believer. Iff deeper cstate etc for longer does make a big difference, I can imagine wakeup time migrate leftward if capacity exists as an "on battery" tactic. (though that thought also invokes some unpleasant bounce fest images) -Mike
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-28 08:50 +0200 |
| Message-ID | <ujm1Y-2ab-9@gated-at.bofh.it> |
| In reply to | #1721046 |
On Mon, 2017-08-28 at 08:10 +0200, Mike Galbraith wrote: > Iff deeper cstate etc for > longer does make a big difference, I can imagine wakeup time migrate > leftward if capacity exists as an "on battery" tactic. (though that > thought also invokes some unpleasant bounce fest images) (consolidate left would have to be LB global to avoid fight with self)
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-08-28 18:30 +0200 |
| Message-ID | <ujv5g-7QO-11@gated-at.bofh.it> |
| In reply to | #1721046 |
Hi Mike, On Sun, Aug 27, 2017 at 11:10 PM, Mike Galbraith <efault@gmx.de> wrote: > On Sun, 2017-08-27 at 22:27 -0700, Joel Fernandes wrote: >> Hi Mike, >> >> On Sun, Aug 27, 2017 at 11:07 AM, Mike Galbraith <efault@gmx.de> wrote: >> > On Sat, 2017-08-26 at 23:39 -0700, Joel Fernandes wrote: >> >> >> >> Also about real world benchmarks, in Android we have usecases that >> >> show that the graphics performance and we have risk of frame drops if >> >> we don't use the sync flag so this is a real world need. >> > >> > That likely has everything to do with cpufreq not realizing that your >> > CPUs really are quite busy when scheduling cross core at fairly high >> > frequency, and not clocking up properly. >> > >> >> I'm glad you brought this point up. Since Android O, the userspace >> processes are much more split across procedure calls due to a feature >> called treble (which does this for security, modularity etc). Due to >> this, a lot of things that were happening within a process boundary >> happen now across process boundaries over the binder bus. Early on >> folks noticed that this caused performance issues without sync flag >> being used as a more strong hint. This can happen when there are 2 >> threads are in different frequency domains on different CPUs and are >> communicating over binder, due to this the combined load of both >> threads is divided between the individual CPUs and causes them to run >> at lower frequency. Where as if they are running together on the same >> CPUs, then they would run at a higher frequency and perform better as >> their combined load would run at a higher frequency. So a stronger >> sync actually helps this case if we're careful about using it when >> possible. > > Sure, but isn't that really a cpufreq issue? We schedule cross core IMO its an issue with the scheduler not being aware of the relationship between groups of tasks doing work as a pipeline. Sync seems to me one way to communicate that. > quite aggressively for obvious reasons. Now on mostly idle handheld > devices, you may get better battery life by stacking tasks a bit more, > in which case a sync-me-harder flag may be what you really want/need, > but with modern CPUs, I'm kinda skeptical of that, would have to see > cold hard numbers to become a believer. Iff deeper cstate etc for If you can suggest any tests, I could run them on my Intel machine? By the way CPUs on handhelds are pretty modern these days ;-) > longer does make a big difference, I can imagine wakeup time migrate > leftward if capacity exists as an "on battery" tactic. (though that > thought also invokes some unpleasant bounce fest images) I'm assuming you mean that tasks are packed together more closely and scheduled on energy aware CPUs at wake up time. This is exactly what we do in the Energy aware scheduling (EAS) that ARM has been working on and is integrated into the Android kernels but its being done whether on battery or plugged in. Also instead of migrating leftward or a fixed diretion, it checks for what would the changes in energy be based on an "energy model" and the current utilization before deciding on whether to wake up on a different CPU. Its also not perfect and is an approximation but overall seems to provide good energy savings. thanks, -Joel > > -Mike
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-28 19:20 +0200 |
| Message-ID | <ujvRD-8lV-3@gated-at.bofh.it> |
| In reply to | #1721790 |
On Mon, 2017-08-28 at 09:20 -0700, Joel Fernandes wrote: > Hi Mike, > > On Sun, Aug 27, 2017 at 11:10 PM, Mike Galbraith <efault@gmx.de> wrote: > > On Sun, 2017-08-27 at 22:27 -0700, Joel Fernandes wrote: > >> Hi Mike, > >> > >> On Sun, Aug 27, 2017 at 11:07 AM, Mike Galbraith <efault@gmx.de> wrote: > >> > On Sat, 2017-08-26 at 23:39 -0700, Joel Fernandes wrote: > >> >> > >> >> Also about real world benchmarks, in Android we have usecases that > >> >> show that the graphics performance and we have risk of frame drops if > >> >> we don't use the sync flag so this is a real world need. > >> > > >> > That likely has everything to do with cpufreq not realizing that your > >> > CPUs really are quite busy when scheduling cross core at fairly high > >> > frequency, and not clocking up properly. > >> > > >> > >> I'm glad you brought this point up. Since Android O, the userspace > >> processes are much more split across procedure calls due to a feature > >> called treble (which does this for security, modularity etc). Due to > >> this, a lot of things that were happening within a process boundary > >> happen now across process boundaries over the binder bus. Early on > >> folks noticed that this caused performance issues without sync flag > >> being used as a more strong hint. This can happen when there are 2 > >> threads are in different frequency domains on different CPUs and are > >> communicating over binder, due to this the combined load of both > >> threads is divided between the individual CPUs and causes them to run > >> at lower frequency. Where as if they are running together on the same > >> CPUs, then they would run at a higher frequency and perform better as > >> their combined load would run at a higher frequency. So a stronger > >> sync actually helps this case if we're careful about using it when > >> possible. > > > > Sure, but isn't that really a cpufreq issue? We schedule cross core > > IMO its an issue with the scheduler not being aware of the > relationship between groups of tasks doing work as a pipeline. Sync > seems to me one way to communicate that. It's certainly simple, which is requirement #1. > > quite aggressively for obvious reasons. Now on mostly idle handheld > > devices, you may get better battery life by stacking tasks a bit more, > > in which case a sync-me-harder flag may be what you really want/need, > > but with modern CPUs, I'm kinda skeptical of that, would have to see > > cold hard numbers to become a believer. Iff deeper cstate etc for > > If you can suggest any tests, I could run them on my Intel machine? By > the way CPUs on handhelds are pretty modern these days ;-) Nah, that would be wasting your time doing what I could do myself. > > longer does make a big difference, I can imagine wakeup time migrate > > leftward if capacity exists as an "on battery" tactic. (though that > > thought also invokes some unpleasant bounce fest images) > > I'm assuming you mean that tasks are packed together more closely and > scheduled on energy aware CPUs at wake up time. This is exactly what > we do in the Energy aware scheduling (EAS) that ARM has been working > on and is integrated into the Android kernels but its being done > whether on battery or plugged in. Also instead of migrating leftward > or a fixed diretion, it checks for what would the changes in energy be > based on an "energy model" and the current utilization before deciding > on whether to wake up on a different CPU. Its also not perfect and is > an approximation but overall seems to provide good energy savings. OK, so you're already doing some packing. Personally, I still think that there's a bit of a disconnect between cpufreq and scheduler, but that aside, sync was invented for what you're trying to do. If you can improve it without wreckage, cool, generic improvement rocks, so good luck. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-08-27 08:30 +0200 |
| Message-ID | <uiZf3-3Rm-3@gated-at.bofh.it> |
| In reply to | #1720742 |
(Sorry my last reply was incorrectly formatted, resending..) Hi Mike, On Sat, Aug 26, 2017 at 10:44 PM, Mike Galbraith <efault@gmx.de> wrote: > On Sat, 2017-08-26 at 18:02 -0700, Joel Fernandes wrote: >> Binder (Android's IPC mechanism) which uses sync wake ups during synchronous >> transactions to the scheduler to indicate that the waker is about to sleep >> soon. The current wake up path can improved when the sync flag is passed >> resulting in higher binder performance. In this patch we more strongly wake up >> the wakee on the waker's CPU if sync is passed based on a few other conditions >> such as wake_cap, cpus allowed. wake_wide is checked only after the sync flag >> check so that it doesn't mess up sync. Binder throughput tests see good >> improvement improvement when waking up wakee (calling thread) on the waker's >> CPU (called thread) with this flag. Some tests results are below: > > Sync is not a contract, it's a hint. If you really want sync behavior, > you need to create a contract signed in blood to signal that you really > really are passing the baton. Yes that is the usecase of binder, we are really passing the baton when we pass sync. We also make binder to not pass sync if there's more work todo and more tasks to wake up. In all current and past products, we have been using sync has a hard contract as you said. Are you proposing addition of another flag to differentiate between the existing hint and the contract? I tried making sync be ignored if wake_wide = 1 as well but its not working well for our use cases and hurts performance. > Sync wakeups make tons of sense when the waker really really has one > and only one wakee, AND really really is going to sleep immediately, Yes that is the case of binder. If we're going to be doing more work and waking up others before going to sleep, we wouldn't pass sync. Binder is actually an RPC mechanism, where the calling thread and called thread are essentially a single entity but are split across process boundaries. By using thread pools, we increase the likelihood that there's a single thread available for each caller which will go back to sleep after replying. > with zero overlap that can be converted to throughput by waking to an > idle core. That's exactly why the micro benchmark too speeds up, from our observation the wake up of an idle core increases the latency (it probably also wastes power). thanks, -Joel
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-08-27 09:00 +0200 |
| Message-ID | <uiZI5-44i-1@gated-at.bofh.it> |
| In reply to | #1720742 |
On Sat, 2017-08-26 at 23:18 -0700, Joel Fernandes wrote: > > > Sync is not a contract, it's a hint. If you really want sync behavior, > > you need to create a contract signed in blood to signal that you really > > really are passing the baton. > > Yes that is the usecase of binder, we are really passing the baton > when we pass sync. We also make binder to not pass sync if there's > more work todo and more tasks to wake up. In all current and past > products, we have been using sync has a hard contract as you said. > Are you proposing addition of another flag to differentiate between > the existing hint and the contract? Yes, the alternative being to unilaterally (as you did) make the existing hint a contract, in which case you would get to deal with any fallout. You'd certainly get some "yay, you rock" mail, but you'd also get some "boo, you suck rocks" to go with it :) -Mike
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-09-10 19:00 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <uodKq-6F7-15@gated-at.bofh.it> |
| In reply to | #1720724 |
Hi,
On Sun, Sep 10, 2017 at 6:40 AM, kernel test robot
<xiaolong.ye@intel.com> wrote:
>
> Greeting,
>
> FYI, we noticed a -11.3% regression of netperf.Throughput_tps due to commit:
>
>
> commit: 6d46bd3d9705555382b83554b56a34f231d5d1dd ("sched/fair: Improve the behavior of sync flag")
> url: https://github.com/0day-ci/linux/commits/Joel-Fernandes/sched-fair-Improve-the-behavior-of-sync-flag/20170829-191129
>
Glad to see the bot tested this RFC/RFT patch. Anyone know what in the
netperf test triggers use of the sync flag?
thanks,
-Joel
[..]
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-09-11 05:00 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <uon73-4Ue-3@gated-at.bofh.it> |
| In reply to | #1730016 |
On Sun, 2017-09-10 at 09:53 -0700, Joel Fernandes wrote: > > Anyone know what in the netperf test triggers use of the sync flag? homer:..kernel/linux-master # git grep wake_up_interruptible_sync_poll net net/core/sock.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI | net/core/sock.c: wake_up_interruptible_sync_poll(&wq->wait, POLLOUT | net/sctp/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | net/smc/smc_rx.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI | net/tipc/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLOUT | net/tipc/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | net/unix/af_unix.c: wake_up_interruptible_sync_poll(&wq->wait, net/unix/af_unix.c: wake_up_interruptible_sync_poll(&u->peer_wait, The same as metric tons of other stuff. Once upon a time, we had avg_overlap to help decide whether to wake core affine or not, on top of the wake_affine() imbalance constraint, but instrumentation showed it to be too error prone, so it had to die. These days, an affine wakeup generally means cache affine, and the sync hint gives you a wee bit more chance of migration near to tasty hot data being approved. The sync hint was born back in the bad old days, when communicating tasks not sharing L2 may as well have been talking over two tin cans and a limp string. These days, things are oodles better, but truly synchronous stuff could still benefit from core affinity (up to hugely for very fast/light stuff) if it weren't for all the caveats that can lead to tossing concurrency opportunities out the window. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-09-11 08:40 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <uoqxX-7vR-3@gated-at.bofh.it> |
| In reply to | #1730136 |
Hi Mike,
Thanks a lot for sharing the history of this.
On Sun, Sep 10, 2017 at 7:55 PM, Mike Galbraith <efault@gmx.de> wrote:
> On Sun, 2017-09-10 at 09:53 -0700, Joel Fernandes wrote:
>>
>> Anyone know what in the netperf test triggers use of the sync flag?
>
> homer:..kernel/linux-master # git grep wake_up_interruptible_sync_poll net
> net/core/sock.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
> net/core/sock.c: wake_up_interruptible_sync_poll(&wq->wait, POLLOUT |
> net/sctp/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
> net/smc/smc_rx.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
> net/tipc/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLOUT |
> net/tipc/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
> net/unix/af_unix.c: wake_up_interruptible_sync_poll(&wq->wait,
> net/unix/af_unix.c: wake_up_interruptible_sync_poll(&u->peer_wait,
>
> The same as metric tons of other stuff.
>
> Once upon a time, we had avg_overlap to help decide whether to wake
> core affine or not, on top of the wake_affine() imbalance constraint,
> but instrumentation showed it to be too error prone, so it had to die.
> These days, an affine wakeup generally means cache affine, and the
> sync hint gives you a wee bit more chance of migration near to tasty
> hot data being approved.
>
> The sync hint was born back in the bad old days, when communicating
> tasks not sharing L2 may as well have been talking over two tin cans
> and a limp string. These days, things are oodles better, but truly
> synchronous stuff could still benefit from core affinity (up to hugely
> for very fast/light stuff) if it weren't for all the caveats that can
> lead to tossing concurrency opportunities out the window.
Cool, thanks. For this test I suspect its the other way? I think the
reason why regresses is that the 'nr_running < 2' check is too weak of
a check to prevent sync in all bad situations ('bad' being pulling a
task to a crowded CPU). Could we maybe be having a situation for this
test where if the blocked load a CPU is high (many tasks recently were
running on it and went to sleep), then the nr_running < 2 is a false
positive and in such a scenario we listened to the sync flag when we
shouldn't have?
To make the load check more meaningful, I am thinking if using
wake_affine()'s balance check is a better thing to do than the
'nr_running < 2' check I used in this patch. Then again, since commit
3fed382b46baac ("sched/numa: Implement NUMA node level wake_affine()",
wake_affine() doesn't do balance check for CPUs within a socket so
probably bringing back something like the *old* wake_affine that
checked load between different CPUs within a socket is needed to avoid
a potentially disastrous sync decision? The commit I refer to was
added with the reason that select_idle_sibling was selecting cores
anywhere within a socket, but with my patch we're more specifically
selecting the waker's CPU on passing the sync flag. Could you share
your thoughts about this?
I will run some tracing on this netperf test and try to understand the
undesirable behavior better as well,
thanks,
-Joel
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-09-11 10:10 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <uorX4-fL-17@gated-at.bofh.it> |
| In reply to | #1730160 |
On Sun, 2017-09-10 at 23:32 -0700, Joel Fernandes wrote:
> Hi Mike,
> Thanks a lot for sharing the history of this.
>
> On Sun, Sep 10, 2017 at 7:55 PM, Mike Galbraith <efault@gmx.de> wrote:
> > On Sun, 2017-09-10 at 09:53 -0700, Joel Fernandes wrote:
> >>
> >> Anyone know what in the netperf test triggers use of the sync flag?
> >
> > homer:..kernel/linux-master # git grep wake_up_interruptible_sync_poll net
> > net/core/sock.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
> > net/core/sock.c: wake_up_interruptible_sync_poll(&wq->wait, POLLOUT |
> > net/sctp/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
> > net/smc/smc_rx.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
> > net/tipc/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLOUT |
> > net/tipc/socket.c: wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
> > net/unix/af_unix.c: wake_up_interruptible_sync_poll(&wq->wait,
> > net/unix/af_unix.c: wake_up_interruptible_sync_poll(&u->peer_wait,
> >
> > The same as metric tons of other stuff.
> >
> > Once upon a time, we had avg_overlap to help decide whether to wake
> > core affine or not, on top of the wake_affine() imbalance constraint,
> > but instrumentation showed it to be too error prone, so it had to die.
> > These days, an affine wakeup generally means cache affine, and the
> > sync hint gives you a wee bit more chance of migration near to tasty
> > hot data being approved.
> >
> > The sync hint was born back in the bad old days, when communicating
> > tasks not sharing L2 may as well have been talking over two tin cans
> > and a limp string. These days, things are oodles better, but truly
> > synchronous stuff could still benefit from core affinity (up to hugely
> > for very fast/light stuff) if it weren't for all the caveats that can
> > lead to tossing concurrency opportunities out the window.
>
> Cool, thanks. For this test I suspect its the other way? I think the
> reason why regresses is that the 'nr_running < 2' check is too weak of
> a check to prevent sync in all bad situations ('bad' being pulling a
> task to a crowded CPU). Could we maybe be having a situation for this
> test where if the blocked load a CPU is high (many tasks recently were
> running on it and went to sleep), then the nr_running < 2 is a false
> positive and in such a scenario we listened to the sync flag when we
> shouldn't have?
nr_running has ~little to do with synchronous baton passing, or rather
with overlap being too small to overcome costs (L2 miss/cstate..). If
you run TCP_RR, pipe-test or ilk (tiny ball ping-pong), you should see
gorgeous numbers, and may find yourself thinking sync is a wonder
elixir for network-land, but 'taint necessarily so in the real world.
The only way to win the "Rob Peter to pay Paul" game is through the use
of knowledge, acquisition of which is expensive. Try resurrecting the
cheap avg_overlap, you'll love it.. for a little while.
> To make the load check more meaningful, I am thinking if using
> wake_affine()'s balance check is a better thing to do than the
> 'nr_running < 2' check I used in this patch. Then again, since commit
> 3fed382b46baac ("sched/numa: Implement NUMA node level wake_affine()",
> wake_affine() doesn't do balance check for CPUs within a socket so
> probably bringing back something like the *old* wake_affine that
> checked load between different CPUs within a socket is needed to avoid
> a potentially disastrous sync decision? The commit I refer to was
> added with the reason that select_idle_sibling was selecting cores
> anywhere within a socket, but with my patch we're more specifically
> selecting the waker's CPU on passing the sync flag. Could you share
> your thoughts about this?
Mucking about with wake_affine() in core affinity context would be a
step backward methinks. The sync hint has not meant CPU affine for
quite some time now.
If you can come up with a sync hint modification that is win/win,
super, but I suspect you'll find it a lot easier to create a new
'really really' flag or make your governor more responsive.
-Mike
[toc] | [prev] | [next] | [standalone]
| From | Rik van Riel <riel@redhat.com> |
|---|---|
| Date | 2017-09-14 18:00 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <upEIy-6V9-27@gated-at.bofh.it> |
| In reply to | #1730160 |
[Multipart message — attachments visible in raw view] — view raw
On Sun, 2017-09-10 at 23:32 -0700, Joel Fernandes wrote:
>
> To make the load check more meaningful, I am thinking if using
> wake_affine()'s balance check is a better thing to do than the
> 'nr_running < 2' check I used in this patch. Then again, since commit
> 3fed382b46baac ("sched/numa: Implement NUMA node level
> wake_affine()",
> wake_affine() doesn't do balance check for CPUs within a socket so
> probably bringing back something like the *old* wake_affine that
> checked load between different CPUs within a socket is needed to
> avoid
> a potentially disastrous sync decision?
This is because regardless of whether or not we did
an affine wakeup, the code called select_idle_sibling
within that socket, anyway.
In other words, the behavior for within-socket
wakeups was not substantially different with or
without an affine wakeup.
All that changed is which CPU select_idle_sibling
starts searching at, and that only if the woken
task's previous CPU is not idle.
> The commit I refer to was
> added with the reason that select_idle_sibling was selecting cores
> anywhere within a socket, but with my patch we're more specifically
> selecting the waker's CPU on passing the sync flag. Could you share
> your thoughts about this?
On systems with SMT, it may make more sense for
sync wakeups to look for idle threads of the same
core, than to have the woken task end up on the
same thread, and wait for the current task to stop
running.
"Strong sync" wakeups like you propose would also
change the semantics of wake_wide() and potentially
other bits of code...
--
All rights reversed
[toc] | [prev] | [next] | [standalone]
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Date | 2017-09-15 06:10 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <upQ6Z-67k-3@gated-at.bofh.it> |
| In reply to | #1732371 |
On Thu, 2017-09-14 at 11:56 -0400, Rik van Riel wrote: > > On systems with SMT, it may make more sense for > sync wakeups to look for idle threads of the same > core, than to have the woken task end up on the > same thread, and wait for the current task to stop > running. Depends. homer:/root # taskset -c 3 pipe-test 1.412185 usecs/loop -- avg 1.412185 1416.2 KHz homer:/root # taskset -c 2,3 pipe-test 2.298820 usecs/loop -- avg 2.298820 870.0 KHz homer:/root # taskset -c 3,7 pipe-test 1.899164 usecs/loop -- avg 1.899164 1053.1 KHz For pipe-test, having ~zero overlap as well as ~zero footprint, that's a good choice, but.. homer:/root # taskset -c 3 tbench.sh 1 10 2>&1|grep Throughput Throughput 844.04 MB/sec 1 clients 1 procs max_latency=0.042 ms homer:/root # taskset -c 2,3 tbench.sh 1 10 2>&1|grep Throughput Throughput 713.25 MB/sec 1 clients 1 procs max_latency=0.324 ms homer:/root # taskset -c 3,7 tbench.sh 1 10 2>&1|grep Throughput Throughput 512.866 MB/sec 1 clients 1 procs max_latency=0.454 ms ..for tbench, where my crusty ole Q6600 turns in a win by scheduling the pair on separate L2 sharing cores, for the more modern SMT equipped i4790, targeting shared L2 is the worst choice. Bigger issue is that while microbenchmark behavior is consistant, applications tend to process data and react to it (vs merely batting it about like playful kittens, cute, but not all that productive), likely mucking up any heuristic anyone invents with depressing regularity. -Mike
[toc] | [prev] | [next] | [standalone]
| From | Joel Fernandes <joelaf@google.com> |
|---|---|
| Date | 2017-09-17 08:50 +0200 |
| Subject | Re: [lkp-robot] [sched/fair] 6d46bd3d97: netperf.Throughput_tps -11.3% regression |
| Message-ID | <uqByV-4pk-1@gated-at.bofh.it> |
| In reply to | #1732371 |
Hi Rik,
On Thu, Sep 14, 2017 at 8:56 AM, Rik van Riel <riel@redhat.com> wrote:
> On Sun, 2017-09-10 at 23:32 -0700, Joel Fernandes wrote:
>>
>> To make the load check more meaningful, I am thinking if using
>> wake_affine()'s balance check is a better thing to do than the
>> 'nr_running < 2' check I used in this patch. Then again, since commit
>> 3fed382b46baac ("sched/numa: Implement NUMA node level
>> wake_affine()",
>> wake_affine() doesn't do balance check for CPUs within a socket so
>> probably bringing back something like the *old* wake_affine that
>> checked load between different CPUs within a socket is needed to
>> avoid
>> a potentially disastrous sync decision?
>
> This is because regardless of whether or not we did
> an affine wakeup, the code called select_idle_sibling
> within that socket, anyway.
>
> In other words, the behavior for within-socket
> wakeups was not substantially different with or
> without an affine wakeup.
>
> All that changed is which CPU select_idle_sibling
> starts searching at, and that only if the woken
> task's previous CPU is not idle.
Yes I understand. However with my 'strong sync' patch, such a
balancing check could be useful which is what I was trying to do in a
different way in my patch - but it could be that my way is not good
enough and potentially the old wake_affine check could help here - I
thought of spending some time next week after LPC travel to
reintroduce the old wake_affine and monitor this signal with some
tracing for the regressing netperf usecase.
>> The commit I refer to was
>> added with the reason that select_idle_sibling was selecting cores
>> anywhere within a socket, but with my patch we're more specifically
>> selecting the waker's CPU on passing the sync flag. Could you share
>> your thoughts about this?
>
> On systems with SMT, it may make more sense for
> sync wakeups to look for idle threads of the same
> core, than to have the woken task end up on the
> same thread, and wait for the current task to stop
> running.
I am ok with additionally doing an select_idle_smt for the SMT cases.
However Mike shows that it doesn't necessarily cause a performance
improvement. But if there is consensus on checking for idle SMT
threads, then I'm Ok with doing that.
>
> "Strong sync" wakeups like you propose would also
> change the semantics of wake_wide() and potentially
> other bits of code...
>
I understand, I am not very confident that wake_wide does the right
thing anyway. Atleast for Android, wake_wide doesn't seem to mirror
the most common usecase of display pipeline well. It seems that we
have cases where the 'flip count' is really high and causes wake_wide
all the time and sends us straight to the wake up slow path causing
regressions in Android benchmarks.
Atleast with the sync flag, the caller provides a meaningful
indication and I think making that flag stronger / more preferred than
wake_wide makes sense from that perspective since its not a signal
that's guessed, but is rather an input request.
thanks,
-Joel
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web