linux-next: manual merge of the workqueues tree with the tip tree
Subsystems (9)
Hi Tejun,
Today's linux-next merge of the workqueues tree got a conflict in kernel/sched.c between commit eae0c9dfb534cb3449888b9601228efa6480fdb5 ("sched: Fix and clean up rate-limit newidle code") from the tip tree and commit 710c15b748f5ce9c573cc047f419cf007a677a9a ("sched: refactor try_to_wake_up() and implement try_to_wake_up_local()") from the workqueues tree.
I did the following fixup which should be checked ... I can carry this fix (if it is suitable).
However, I have gone back to a previous version of the workqueues tree for another issue (build problem for an interaction with the sound tree), so this is not in linux-next today.
Signature · 78 lines
Cheers, Stephen Rothwell [email protected] diff --cc kernel/sched.c index 686be36,e488e07..0000000 --- a/kernel/sched.c +++ b/kernel/sched.c @@@ -2323,7 -2336,58 +2335,69 @@@ void task_oncpu_function_call(struct ta preempt_enable(); } - /*** + static inline void ttwu_activate(struct task_struct *p, struct rq *rq, + bool is_sync, bool is_migrate, bool is_local) + { + schedstat_inc(p, se.nr_wakeups); + if (is_sync) + schedstat_inc(p, se.nr_wakeups_sync); + if (is_migrate) + schedstat_inc(p, se.nr_wakeups_migrate); + if (is_local) + schedstat_inc(p, se.nr_wakeups_local); + else + schedstat_inc(p, se.nr_wakeups_remote); + + activate_task(rq, p, 1); + + /* + * Only attribute actual wakeups done by this task. + */ + if (!in_interrupt()) { + struct sched_entity *se = ¤t->se; + u64 sample = se->sum_exec_runtime; + + if (se->last_wakeup) + sample -= se->last_wakeup; + else + sample -= se->start_runtime; + update_avg(&se->avg_wakeup, sample); + + se->last_wakeup = se->sum_exec_runtime; + } + } + + static inline void ttwu_woken_up(struct task_struct *p, struct rq *rq, + int wake_flags, bool success) + { + trace_sched_wakeup(rq, p, success); + check_preempt_curr(rq, p, wake_flags); + + p->state = TASK_RUNNING; + #ifdef CONFIG_SMP + if (p->sched_class->task_wake_up) + p->sched_class->task_wake_up(rq, p); ++ ++ if (unlikely(rq->idle_stamp)) { ++ u64 delta = rq->clock - rq->idle_stamp; ++ u64 max = 2*sysctl_sched_migration_cost; ++ ++ if (delta > max) ++ rq->avg_idle = max; ++ else ++ update_avg(&rq->avg_idle, delta); ++ rq->idle_stamp = 0; ++ } + #endif + /* + * Wake up is complete, fire wake up notifier. This allows + * try_to_wake_up_local() to be called from wake up notifiers. + */ + if (success) + fire_sched_notifier(p, wakeup); + } + + /** * try_to_wake_up - wake up a thread * @p: the to-be-woken-up thread * @state: the mask of task states that can be woken
Quoted 8 lines · Stephen Rothwell
Hi Tejun,
Today's linux-next merge of the workqueues tree got a conflict in
kernel/sched.cbetween commiteae0c9dfb534cb3449888b9601228efa6480fdb5("sched: Fix and clean up rate-limit newidle code") from the tip tree and commit710c15b748f5ce9c573cc047f419cf007a677a9a("sched: refactortry_to_wake_up()and implementtry_to_wake_up_local()") from the workqueues tree.
Tejun,
Please submit scheduler patches to the scheduler tree. Such level of refactoring of a critical scheduler component needs to go through the regular scheduler channels. This is a frequently modified piece of code and conflicts are likely in the future.
Thanks,
Ingo
Quoted 4 lines · Ingo Molnar
Please submit scheduler patches to the scheduler tree. Such level of refactoring of a critical scheduler component needs to go through the regular scheduler channels. This is a frequently modified piece of code and conflicts are likely in the future.
Sure, which sched/* branch should I base these patches on? Alternatively, pulling the following branch into one of sched/* should do the trick too.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-sched
Thanks.
Signature · 1 line
tejun
Quoted 7 lines · Tejun Heo
Quoted 4 lines · Ingo Molnar
Please submit scheduler patches to the scheduler tree. Such level of refactoring of a critical scheduler component needs to go through the regular scheduler channels. This is a frequently modified piece of code and conflicts are likely in the future.
Sure, which sched/* branch should I base these patches on?
You could send the patch you rely on standalone (it seems to be a single patch) and we can look at applying it to the scheduler tree. That reduces the conflicts on an ongoing basis. Please Cc: PeterZ and Mike Galbraith as well.
Thanks,
Ingo
Hello, Ingo.
Quoted 6 lines · Ingo Molnar
Quoted 1 line
Sure, which sched/* branch should I base these patches on?
You could send the patch you rely on standalone (it seems to be a single patch) and we can look at applying it to the scheduler tree. That reduces the conflicts on an ongoing basis. Please Cc: PeterZ and Mike Galbraith as well.
The tree contains four scheduler patches.
0001-sched-rename-preempt_notifier-to-sched_notifier-and-.patch 0002-sched-update-sched_notifier-and-add-wakeup-sleep-not.patch 0003-sched-implement-sched_notifier_wake_up_process.patch 0004-sched-implement-force_cpus_allowed.patch
1, 2 and 4 are somewhat spread throughout sched.c so it would be better if they all are routed through sched tree. Currently the wq#for-sched contains the followings on top of linus#master.
* Adds debugobj support to workqueue.
* Pulls in sched/urgent to receive the scheduler fix.
* Adds the above four patches.
If pulling in from the existing branch is an option, I'd prefer that. If not, please let me know. I'll send the above four patches against sched/urgent.
Thanks.
Signature · 1 line
tejun
Quoted 23 lines · Tejun Heo
Hello, Ingo.
Quoted 6 lines · Ingo Molnar
Quoted 1 line
Sure, which sched/* branch should I base these patches on?
You could send the patch you rely on standalone (it seems to be a single patch) and we can look at applying it to the scheduler tree. That reduces the conflicts on an ongoing basis. Please Cc: PeterZ and Mike Galbraith as well.
The tree contains four scheduler patches.
0001-sched-rename-preempt_notifier-to-sched_notifier-and-.patch 0002-sched-update-sched_notifier-and-add-wakeup-sleep-not.patch 0003-sched-implement-sched_notifier_wake_up_process.patch 0004-sched-implement-force_cpus_allowed.patch
1, 2 and 4 are somewhat spread throughout
sched.cso it would be better if they all are routed through sched tree. Currently the wq#for-sched contains the followings on top of linus#master.* Adds debugobj support to workqueue.
Quoted 7 lines
* Pulls in sched/urgent to receive the scheduler fix.
* Adds the above four patches.
If pulling in from the existing branch is an option, I'd prefer that. If not, please let me know. I'll send the above four patches against sched/urgent.
I've merged sched/urgent into sched/core and pushed it out - mind basing any sched.c patches on top of that and send a series of scheduler-only patches?
Thanks,
Ingo
PATCH 1/4 sched: rename preempt_notifier to sched_notifier and always enable it
Rename preempt_notifier to sched_notifier, move it from preempt.h to sched.h, drop sched_ prefixes from ops names and make sched_notifier always enabled.
This is to prepare for adding more notification hooks. This patch doesn't make any functional changes.
--- arch/ia64/kvm/Kconfig | 1 - arch/powerpc/kvm/Kconfig | 1 - arch/s390/kvm/Kconfig | 1 - arch/x86/kvm/Kconfig | 1 - include/linux/kvm_host.h | 4 +-- include/linux/preempt.h | 43 ------------------------------- include/linux/sched.h | 44 ++++++++++++++++++++++++++++--- init/Kconfig | 4 --- kernel/sched.c | 64 +++++++++++++++------------------------------- virt/kvm/kvm_main.c | 26 ++++++++---------- 10 files changed, 74 insertions(+), 115 deletions(-)
arch/ia64/kvm/Kconfig +0 -1
@@ -22,7 +22,6 @@ config KVM depends on HAVE_KVM && MODULES && EXPERIMENTAL # for device assignment: depends on PCI - select PREEMPT_NOTIFIERS select ANON_INODES select HAVE_KVM_IRQCHIP select KVM_APIC_ARCHITECTURE
arch/powerpc/kvm/Kconfig +0 -1
@@ -18,7 +18,6 @@ if VIRTUALIZATION config KVM bool - select PREEMPT_NOTIFIERS select ANON_INODES config KVM_440
arch/s390/kvm/Kconfig +0 -1
@@ -18,7 +18,6 @@ if VIRTUALIZATION config KVM tristate "Kernel-based Virtual Machine (KVM) support" depends on HAVE_KVM && EXPERIMENTAL - select PREEMPT_NOTIFIERS select ANON_INODES select S390_SWITCH_AMODE ---help---
arch/x86/kvm/Kconfig +0 -1
@@ -22,7 +22,6 @@ config KVM depends on HAVE_KVM # for device assignment: depends on PCI - select PREEMPT_NOTIFIERS select MMU_NOTIFIER select ANON_INODES select HAVE_KVM_IRQCHIP
include/linux/kvm_host.h +1 -3
@@ -74,9 +74,7 @@ void kvm_io_bus_unregister_dev(struct kvm *kvm, struct kvm_io_bus *bus,struct kvm_vcpu {struct kvm *kvm; -#ifdef CONFIG_PREEMPT_NOTIFIERS -struct preempt_notifier preempt_notifier; -#endif +struct sched_notifier sched_notifier;int vcpu_id;struct mutex mutex;int cpu;
include/linux/preempt.h +0 -43
47 lines not on this page · raw message
include/linux/sched.h +40 -4
56 lines not on this page · raw message
init/Kconfig +0 -4
@@ -1206,7 +1206,3 @@ config STOP_MACHINE Need stop_machine() primitive. source "block/Kconfig" - -config PREEMPT_NOTIFIERS - bool -
kernel/sched.c +21 -43
118 lines not on this page · raw message
virt/kvm/kvm_main.c +12 -14
@@ -79,7 +79,7 @@ static cpumask_var_t cpus_hardware_enabled;struct kmem_cache *kvm_vcpu_cache;EXPORT_SYMBOL_GPL (kvm_vcpu_cache); -static __read_mostly struct preempt_ops kvm_preempt_ops; +static __read_mostly struct sched_notifier_ops kvm_sched_notifier_ops;struct dentry *kvm_debugfs_dir;
@@ -713,7 +713,7 @@ void vcpu_load(struct kvm_vcpu *vcpu)mutex_lock (&vcpu->mutex); cpu =get_cpu (); -preempt_notifier_register (&vcpu->preempt_notifier); +sched_notifier_register (&vcpu->sched_notifier);kvm_arch_vcpu_load (vcpu, cpu);put_cpu (); }
@@ -722,7 +722,7 @@ void vcpu_put(struct kvm_vcpu *vcpu) {preempt_disable ();kvm_arch_vcpu_put (vcpu); -preempt_notifier_unregister (&vcpu->preempt_notifier); +sched_notifier_unregister (&vcpu->sched_notifier);preempt_enable ();mutex_unlock (&vcpu->mutex); }
@@ -1772,7 +1772,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)if (IS_ERR (vcpu))return PTR_ERR (vcpu); -preempt_notifier_init (&vcpu->preempt_notifier, &kvm_preempt_ops); +sched_notifier_init (&vcpu->sched_notifier, &kvm_sched_notifier_ops); r =kvm_arch_vcpu_setup (vcpu);if (r)
@@ -2690,23 +2690,21 @@ static struct sys_device kvm_sysdev = {struct page *bad_page;pfn_t bad_pfn; -static inline -struct kvm_vcpu *preempt_notifier_to_vcpu (struct preempt_notifier *pn) +static inline struct kvm_vcpu *sched_notifier_to_vcpu (struct sched_notifier *sn) { - return container_of(pn, struct kvm_vcpu, preempt_notifier); + return container_of(sn, struct kvm_vcpu, sched_notifier); } -static void kvm_sched_in (struct preempt_notifier *pn,int cpu) +static void kvm_sched_in (struct sched_notifier *sn,int cpu) { -struct kvm_vcpu *vcpu =preempt_notifier_to_vcpu (pn); +struct kvm_vcpu *vcpu =sched_notifier_to_vcpu (sn);kvm_arch_vcpu_load (vcpu, cpu); } -static void kvm_sched_out (struct preempt_notifier *pn, -struct task_struct *next) +static void kvm_sched_out (struct sched_notifier *sn,struct task_struct *next) { -struct kvm_vcpu *vcpu =preempt_notifier_to_vcpu (pn); +struct kvm_vcpu *vcpu =sched_notifier_to_vcpu (sn);kvm_arch_vcpu_put (vcpu); }
@@ -2780,8 +2778,8 @@ int kvm_init(void *opaque, unsigned int vcpu_size, goto out_free; } - kvm_preempt_ops.sched_in = kvm_sched_in; - kvm_preempt_ops.sched_out = kvm_sched_out; + kvm_sched_notifier_ops.in = kvm_sched_in; + kvm_sched_notifier_ops.out = kvm_sched_out;kvm_init_debug ();
Signature · 1 line
1.6.5.3
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 6 lines · Tejun Heo
Rename
preempt_notifiertosched_notifier, move it frompreempt.htosched.h, dropsched_prefixes from ops names and makesched_notifieralways enabled.This is to prepare for adding more notification hooks. This patch doesn't make any functional changes.
The sched notifiers and the various event notifiers we have in the same codepaths should really be unified into a single callback framework.
We have these _5_ callbacks:
...
perf_event_task_sched_out(prev, next, cpu);
...
fire_sched_out_notifiers(prev, next);
...
trace_sched_switch(rq, prev, next);
...
perf_event_task_sched_in(current, cpu_of(rq));
fire_sched_in_notifiers(current);...
That could be done with just two callbacks - one for sched-out, one for sched-in.
The best way to do that would be to use two TRACE_EVENT() callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)
This requires some work but needs to be done.
Ingo
Peter Zijlstra
maintainerRe: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 25 lines · Ingo Molnar
Quoted 6 lines · Tejun Heo
Rename
preempt_notifiertosched_notifier, move it frompreempt.htosched.h, dropsched_prefixes from ops names and makesched_notifieralways enabled.This is to prepare for adding more notification hooks. This patch doesn't make any functional changes.
The sched notifiers and the various event notifiers we have in the same codepaths should really be unified into a single callback framework.
We have these _5_ callbacks:
....
perf_event_task_sched_out(prev, next, cpu); .... fire_sched_out_notifiers(prev, next); .... trace_sched_switch(rq, prev, next); .... perf_event_task_sched_in(current, cpu_of(rq)); fire_sched_in_notifiers(current);....
Quoted 8 lines
That could be done with just two callbacks - one for sched-out, one for sched-in.
The best way to do that would be to use two
TRACE_EVENT()callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)This requires some work but needs to be done.
Ugh,.. it also makes TRACE_EVENT unconditional.
That really wants a separate option.. What we could do is take regular notifier lists and extend them to auto-generate a tracepoint when the trace stuff is enabled or something.
Peter Zijlstra
maintainerRe: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 33 lines · Peter Zijlstra
Quoted 32 lines · Ingo Molnar
Quoted 6 lines · Tejun Heo
Rename
preempt_notifiertosched_notifier, move it frompreempt.htosched.h, dropsched_prefixes from ops names and makesched_notifieralways enabled.This is to prepare for adding more notification hooks. This patch doesn't make any functional changes.
The sched notifiers and the various event notifiers we have in the same codepaths should really be unified into a single callback framework.
We have these _5_ callbacks:
....
perf_event_task_sched_out(prev, next, cpu); .... fire_sched_out_notifiers(prev, next); .... trace_sched_switch(rq, prev, next); .... perf_event_task_sched_in(current, cpu_of(rq)); fire_sched_in_notifiers(current);....
That could be done with just two callbacks - one for sched-out, one for sched-in.
The best way to do that would be to use two
TRACE_EVENT()callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)
Quoted 7 lines
Quoted 1 line
This requires some work but needs to be done.
Ugh,.. it also makes
TRACE_EVENTunconditional.That really wants a separate option.. What we could do is take regular notifier lists and extend them to auto-generate a tracepoint when the trace stuff is enabled or something.
Also, there is this thing about direct and indirect function calls.
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 34 lines · Peter Zijlstra
Quoted 33 lines · Peter Zijlstra
Quoted 32 lines · Ingo Molnar
Quoted 6 lines · Tejun Heo
Rename
preempt_notifiertosched_notifier, move it frompreempt.htosched.h, dropsched_prefixes from ops names and makesched_notifieralways enabled.This is to prepare for adding more notification hooks. This patch doesn't make any functional changes.
The sched notifiers and the various event notifiers we have in the same codepaths should really be unified into a single callback framework.
We have these _5_ callbacks:
....
perf_event_task_sched_out(prev, next, cpu); .... fire_sched_out_notifiers(prev, next); .... trace_sched_switch(rq, prev, next); .... perf_event_task_sched_in(current, cpu_of(rq)); fire_sched_in_notifiers(current);....
That could be done with just two callbacks - one for sched-out, one for sched-in.
The best way to do that would be to use two
TRACE_EVENT()callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
This requires some work but needs to be done.
Ugh,.. it also makes
TRACE_EVENTunconditional.That really wants a separate option.. What we could do is take regular notifier lists and extend them to auto-generate a tracepoint when the trace stuff is enabled or something.
I wouldnt mind some form of TRACE_EVENT_CALLBACK() thing whose callback facility is always available, even if CONFIG_PERF_EVENTS and CONFIG_TRACING is disabled.
It might grow out of notifier.h - albeit i suspect the shorter path would be to grow it from TRACE_EVENT().
( The various pagefault notifiers in arch/x86/mm/fault.c could use this
facility too. )
What we definitely dont want is the proliferation of callbacks.
Quoted 1 line
Also, there is this thing about direct and indirect function calls.
Yeah. The norm would be for those points to be disabled and have near zero overhead. If it has callbacks registered it should be light-weight.
Ingo
Peter Zijlstra
maintainerRe: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 4 lines · Ingo Molnar
I wouldnt mind some form of
TRACE_EVENT_CALLBACK()thing whose callback facility is always available, even ifCONFIG_PERF_EVENTSandCONFIG_TRACINGis disabled.
CALLBACK_EVENT() would be my preferred name, and shouldn't live anywhere near the regular tracing bits, the tracing bits could simply add another callback in it when enabled.
Quoted 7 lines
It might grow out of
notifier.h- albeit i suspect the shorter path would be to grow it fromTRACE_EVENT().( The various pagefault notifiers in
arch/x86/mm/fault.ccould use this
facility too. )What we definitely dont want is the proliferation of callbacks.
Sure, a first approach would be to find something that can cover both these extended preempt notifiers and the mmu notifier stuff, clearly notifier.h isn't cutting it anymore, and rolling these things yourself has obvious disadvantages like not being to add generic bits without having to touch all of them.
The big downside from TRACE_EVENT() like things is the implementation, its a horrid macro mess. They're nice enough when you don't have to touch the implementation, but rather painful when you do have to.
But I guess there's just no real alternative..
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Hello, Peter, Ingo.
Quoted 3 lines · Peter Zijlstra
CALLBACK_EVENT()would be my preferred name, and shouldn't live anywhere near the regular tracing bits, the tracing bits could simply add another callback in it when enabled.
I haven't looked at the mm code but if the scheduler callback requirement isn't gonna explode big time soon and we know which functions are the candidate callbacks at build time, I think this can be done pretty efficiently with an ulong enable mask per task and fixed function dispatch such that no callback case just goes through one likely() conditional test at the tracing point and callback cases are dispatched using conditional direct jump.
The thing is that I've been sitting on these workqueue patches for months now and I really want them in stable tree at this point. So, how about putting the current simplistic notifier code into a sched/ branch which is not pushed to Linus and then after pushing the workqueue patches, I'll work on the notifiers branch before pushing the whole thing to Linus. Although the scheduler notifier changes necessary for c-m-workqueue adds more notifiers, it's just extension of an existing facility and pretty isolated change from other workqueue changes.
How does that sound?
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 7 lines · Tejun Heo
Hello, Peter, Ingo.
Quoted 3 lines · Peter Zijlstra
CALLBACK_EVENT()would be my preferred name, and shouldn't live anywhere near the regular tracing bits, the tracing bits could simply add another callback in it when enabled.
Quoted 7 lines
I haven't looked at the mm code but if the scheduler callback requirement isn't gonna explode big time soon and we know which functions are the candidate callbacks at build time, I think this can be done pretty efficiently with an ulong enable mask per task and fixed function dispatch such that no callback case just goes through one
likely()conditional test at the tracing point and callback cases are dispatched using conditional direct jump.
Yes - and that's what the tracepoints infrastructure is about.
Btw., longer term it will be faster than a mask check and a default-untaken conditional: there's ongoign work to offer runtime instruction patching features for tracing callbacks. There's the jump patching optimization and also the immediate values patching optimization.
We've got old-style notifiers for regular callbacks, we've got new-style tracepoints which are callbacks and event source descriptors - and what i'm asking for is to have _one_ callback mechanism, and to use that in the scheduler. 5 callbacks using 3 different facilities is excessive - i'd like to see just two callbacks using one facility.
Ingo
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Hello,
Quoted 5 lines · Ingo Molnar
Btw., longer term it will be faster than a mask check and a default-untaken conditional: there's ongoign work to offer runtime instruction patching features for tracing callbacks. There's the jump patching optimization and also the immediate values patching optimization.
Scheduler callbacks won't benefit much from it. There will always be workqueues and thus conditional branch will always be necessary.
Quoted 5 lines
We've got old-style notifiers for regular callbacks, we've got new-style tracepoints which are callbacks and event source descriptors - and what i'm asking for is to have _one_ callback mechanism, and to use that in the scheduler. 5 callbacks using 3 different facilities is excessive - i'd like to see just two callbacks using one facility.
The patches in question don't really change anything in in/out paths. It only adds wake up and sleep callbacks to the existing notifier mechanism. Sure, let's unify all of them and make them prettier and more efficient but I don't think we need to hold up workqueue changes for that, right? We can do those in separate steps and have workqueue changes tested in at least linux-next.
I'll re-post four scheduler patches which reorganize preempt notifier but make no functional changes and another one to add wakeup and sleep. The first four can go into sched/core and the last one in a separate branch. That way, conflicts will be minimal yet upstream won't see any functional difference from the current code. Later when notifier frameworks is reworked, we can merge them all up and send them upstream. How does it sound?
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 11 lines · Tejun Heo
Hello,
Quoted 5 lines · Ingo Molnar
Btw., longer term it will be faster than a mask check and a default-untaken conditional: there's ongoign work to offer runtime instruction patching features for tracing callbacks. There's the jump patching optimization and also the immediate values patching optimization.
Scheduler callbacks won't benefit much from it. There will always be workqueues and thus conditional branch will always be necessary.
Other code will benefit from it though, such as the page fault callbacks i already mentioned.
My position on this is rather clear: i want no new callbacks and no changes to callbacks in the scheduler until this situation is cleaned up. Five callback sites are _way_ too much - so if you want to add callbacks or change them, please clean it up and improve it first.
Ingo
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Hello,
Quoted 7 lines · Ingo Molnar
Other code will benefit from it though, such as the page fault callbacks i already mentioned.
My position on this is rather clear: i want no new callbacks and no changes to callbacks in the scheduler until this situation is cleaned up. Five callback sites are _way_ too much - so if you want to add callbacks or change them, please clean it up and improve it first.
Even changes which cause no functional differences? It's just logistics at that point and I'll only be pushing the actual changes (addition of wakeup/sleep callbacks) to linux-next so that different stages of workqueue changes can receive some amount of testing. If you don't want that in sched development tree, I can maintain a temporary branch for linux-next testing but I really can't see what will be the benefit of doing things that way.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 6 lines · Tejun Heo
Hello,
Quoted 3 lines · Ingo Molnar
Other code will benefit from it though, such as the page fault callbacks i already mentioned.
Quoted 6 lines
Quoted 4 lines
My position on this is rather clear: i want no new callbacks and no changes to callbacks in the scheduler until this situation is cleaned up. Five callback sites are _way_ too much - so if you want to add callbacks or change them, please clean it up and improve it first.
Even changes which cause no functional differences? [...]
Such as enabling preempt notifiers unconditionally? That's a functional change - it turns a so-far optional callback into an essentially mandatory one.
Ingo
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 10 lines · Ingo Molnar
Quoted 6 lines
Quoted 4 lines
My position on this is rather clear: i want no new callbacks and no changes to callbacks in the scheduler until this situation is cleaned up. Five callback sites are _way_ too much - so if you want to add callbacks or change them, please clean it up and improve it first.
Even changes which cause no functional differences? [...]
Such as enabling preempt notifiers unconditionally? That's a functional change - it turns a so-far optional callback into an essentially mandatory one.
No, I'm not gonna do that. Just patches to reorganize code so that unnecessary conflicts won't occur. There will be NO functional changes.
Signature · 1 line
tejun
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 8 lines · Tejun Heo
Quoted 7 lines · Ingo Molnar
Quoted 6 lines
Quoted 4 lines
My position on this is rather clear: i want no new callbacks and no changes to callbacks in the scheduler until this situation is cleaned up. Five callback sites are _way_ too much - so if you want to add callbacks or change them, please clean it up and improve it first.
Even changes which cause no functional differences? [...]
Quoted 7 lines
Quoted 3 lines
Such as enabling preempt notifiers unconditionally? That's a functional change - it turns a so-far optional callback into an essentially mandatory one.
No, I'm not gonna do that. Just patches to reorganize code so that unnecessary conflicts won't occur. There will be NO functional changes.
Not without the other changes - which you want to do too, right? Please send all sched.c modifications via the scheduler tree. Going via other trees is fine when there's agreement by the maintainers - but this is one of the rare cases where that's not the case.
Ingo
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Hello,
Quoted 5 lines · Ingo Molnar
Quoted 3 lines
No, I'm not gonna do that. Just patches to reorganize code so that unnecessary conflicts won't occur. There will be NO functional changes.
Not without the other changes - which you want to do too, right?
The extra things I want can stay in a devel branch until notifiers get cleaned up and it will only be a few patches which aren't very likely to cause conflicts when it gets exported for linux-next or other testing branches.
Quoted 3 lines
Please send all
sched.cmodifications via the scheduler tree. Going via other trees is fine when there's agreement by the maintainers - but this is one of the rare cases where that's not the case.
Yeah, sure. So, two patchsets. One for sched/core doing pure reorganization without any functional changes. The other for sched/notifier (or whatever name you would prefer) which is purely for development and testing and will not be pushed to Linus unless it receives notifier framework cleanup. wq#for-next will pull from sched/notifier and be exported to linux-next but it will never be submitted to Linus until sched/notifier is cleaned up. Am I understanding it correctly?
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 4 lines · Tejun Heo
Quoted 3 lines
Please send all
sched.cmodifications via the scheduler tree. Going via other trees is fine when there's agreement by the maintainers - but this is one of the rare cases where that's not the case.
Quoted 8 lines
Yeah, sure. So, two patchsets. One for sched/core doing pure reorganization without any functional changes. The other for sched/notifier (or whatever name you would prefer) which is purely for development and testing and will not be pushed to Linus unless it receives notifier framework cleanup. wq#for-next will pull from sched/notifier and be exported to linux-next but it will never be submitted to Linus until sched/notifier is cleaned up. Am I understanding it correctly?
Yeah, that would be fine.
Ingo
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
In reply to Ingo MolnarHello, Ingo.
Quoted 8 lines · Ingo Molnar
That could be done with just two callbacks - one for sched-out, one for sched-in.
The best way to do that would be to use two
TRACE_EVENT()callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)This requires some work but needs to be done.
Thought about that but trace events and scheduler callbacks have very different trigger enable/disable conditions. I couldn't think of a way to do both in reasonably efficient manner. Although they both are notification mechanisms, they do have pretty different requirements and I'm not quite sure whether unifying them is a good idea. Of course if you have an idea to do both efficiently, no reason not to do it.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
In reply to Ingo MolnarQuoted 14 lines · Ingo Molnar
The sched notifiers and the various event notifiers we have in the same codepaths should really be unified into a single callback framework.
We have these _5_ callbacks:
...
perf_event_task_sched_out(prev, next, cpu); ... fire_sched_out_notifiers(prev, next); ... trace_sched_switch(rq, prev, next); ... perf_event_task_sched_in(current, cpu_of(rq)); fire_sched_in_notifiers(current);
Quoted 8 lines
...
That could be done with just two callbacks - one for sched-out, one for sched-in.
The best way to do that would be to use two
TRACE_EVENT()callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)
I'd rather 5 explicit direct function calls than two direct calls and five indirect function calls, actually...
Paul.
Re: [PATCH 1/4 tip/sched/core] sched: rename preempt_notifier to sched_notifier and always enable it
Quoted 21 lines · Paul Mackerras
Quoted 19 lines · Ingo Molnar
The sched notifiers and the various event notifiers we have in the same codepaths should really be unified into a single callback framework.
We have these _5_ callbacks:
...
perf_event_task_sched_out(prev, next, cpu); ... fire_sched_out_notifiers(prev, next); ... trace_sched_switch(rq, prev, next); ... perf_event_task_sched_in(current, cpu_of(rq)); fire_sched_in_notifiers(current);...
That could be done with just two callbacks - one for sched-out, one for sched-in.
Quoted 6 lines
Quoted 3 lines
The best way to do that would be to use two
TRACE_EVENT()callbacks, make them unconditional and register to them. (with wrappers to make it all convenient to use)I'd rather 5 explicit direct function calls than two direct calls and five indirect function calls, actually...
Those five callbacks are typically disabled on a regular Linux system. So i'd rather have two sites with some NOPs in them. (no branches, no calls)
Ingo
PATCH 2/4 sched: update sched_notifier and add wakeup/sleep notifications
In reply to Ingo MolnarUpdate sched_notifier such that
* in and out ops are symmetric in the parameter they take.
* Use single fire_sched_notifier() macro instead of separate function for each op.
* Allow NULL ops.
* Add wakeup and sleep notifications.
--- include/linux/sched.h | 20 +++++++++++++------- kernel/sched.c | 41 ++++++++++++++++++----------------------- virt/kvm/kvm_main.c | 4 ++-- 3 files changed, 33 insertions(+), 32 deletions(-)
include/linux/sched.h +13 -7
@@ -1214,15 +1214,21 @@ struct sched_notifier;/** * sched_notifier_ops - notifiers called for scheduling events -* @in: we're about to be rescheduled: -* notifier: struct sched_notifier for the task being scheduled -* cpu: cpu we're scheduled on -* @out: we've just been preempted -* notifier: struct sched_notifier for the task being preempted -* next: the task that's kicking us out +* @wakeup: we're waking up +* notifier: struct sched_notifier for the task being woken up +* @sleep: we're going to bed +* notifier: struct sched_notifier for the task sleeping +* @in: we're now running on the cpu +* notifier: struct sched_notifier for the task being scheduled in +* prev: the task which ran before us +* @out: we're leaving the cpu +* notifier: struct sched_notifier for the task being scheduled out +* next: the task which will run after us */ struct sched_notifier_ops { -void (*in)(struct sched_notifier *notifier,int cpu); +void (*wakeup)(struct sched_notifier *notifier); +void (*sleep)(struct sched_notifier *notifier); +void (*in)(struct sched_notifier *notifier,struct task_struct *prev);void (*out)(struct sched_notifier *notifier,struct task_struct *next); };
kernel/sched.c +18 -23
79 lines not on this page · raw message
virt/kvm/kvm_main.c +2 -2
@@ -2695,11 +2695,11 @@ static inline struct kvm_vcpu *sched_notifier_to_vcpu(struct sched_notifier *sn) return container_of(sn, struct kvm_vcpu, sched_notifier); } -static void kvm_sched_in (struct sched_notifier *sn,int cpu) +static void kvm_sched_in (struct sched_notifier *sn,struct task_struct *prev) {struct kvm_vcpu *vcpu =sched_notifier_to_vcpu (sn); -kvm_arch_vcpu_load (vcpu, cpu); +kvm_arch_vcpu_load (vcpu,smp_processor_id ()); }static void kvm_sched_out (struct sched_notifier *sn,struct task_struct *next)
Signature · 1 line
1.6.5.3
PATCH 3/4 sched: refactor try_to_wake_up() and implement try_to_wake_up_local()
In reply to Ingo MolnarFactor ttwu_activate() and ttwu_woken_up() out of try_to_wake_up() and use them to implement try_to_wake_up_local(). try_to_wake_up_local() is similar to try_to_wake_up() but it assumes the caller has this_rq() locked and the target task is bound to this_rq(). try_to_wake_up_local() can be called from wakeup and sleep scheduler notifiers.
The factoring out doesn't affect try_to_wake_up() much code-generation-wise. Depending on configuration options, it ends up generating the same object code as before or slightly different one due to different register assignment.
The refactoring and local wake up function implementation using refactored functions are based on Peter Zijlstra's suggestion.
--- include/linux/sched.h | 2 + kernel/sched.c | 166 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 120 insertions(+), 48 deletions(-)
include/linux/sched.h +2 -0
@@ -2057,6 +2057,8 @@ extern void release_uids(struct user_namespace *ns);extern void do_timer (unsigned long ticks); +extern bool try_to_wake_up_local (struct task_struct *p,unsigned int state, +int wake_flags);extern int wake_up_state (struct task_struct *tsk,unsigned int state);extern int wake_up_process (struct task_struct *tsk); extern void wake_up_new_task(struct task_struct *tsk,
kernel/sched.c +118 -48
201 lines not on this page · raw message
Signature · 1 line
1.6.5.3
PATCH 4/4 sched: implement force_cpus_allowed()
In reply to Ingo Molnarset_cpus_allowed_ptr() modifies the allowed cpu mask of a task. The function performs the following checks before applying new mask.
* Check whether PF_THREAD_BOUND is set. This is set for bound kthreads so that they can't be moved around.
* Check whether the target cpu is still marked active - cpu_active(). Active state is cleared early while downing a cpu.
This patch adds force_cpus_allowed() which bypasses the above two checks. The caller is responsible for guaranteeing that the destination cpu doesn't go down until force_cpus_allowed() finishes.
The first check is bypassed by factoring out actual migration part into __set_cpus_allowed() from set_cpus_allowed_ptr() and calling the inner function from force_cpus_allowed().
The second check is buried deep down in __migrate_task() which is executed by migration threads. @force parameter is added to __migrate_task(). As the only way to pass parameters from __set_cpus_allowed() is through migration_req, migration_req->force is added and the @force parameter is passed down to __migrate_task().
Please note the naming discrepancy between set_cpus_allowed_ptr() and the new functions. The _ptr suffix is from the days when cpumask api wasn't mature and future changes should drop it from set_cpus_allowed_ptr() too.
force_cpus_allowed() will be used for concurrency-managed workqueue.
--- include/linux/sched.h | 7 ++++ kernel/sched.c | 89 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 67 insertions(+), 29 deletions(-)
include/linux/sched.h +7 -0
@@ -1851,6 +1851,8 @@ static inline void rcu_copy_process(struct task_struct *p)#ifdef CONFIG_SMP extern int set_cpus_allowed_ptr (struct task_struct *p,const struct cpumask *new_mask); +extern int force_cpus_allowed (struct task_struct *p, +const struct cpumask *new_mask);#else static inline int set_cpus_allowed_ptr (struct task_struct *p,const struct cpumask *new_mask)
@@ -1859,6 +1861,11 @@ static inline int set_cpus_allowed_ptr(struct task_struct *p,return -EINVAL ; return 0; } +static inline int force_cpus_allowed (struct task_struct *p, +const struct cpumask *new_mask) +{ +return set_cpus_allowed_ptr (p, new_mask); +}#endif #ifndef CONFIG_CPUMASK_OFFSTACK
kernel/sched.c +60 -29
172 lines not on this page · raw message
Signature · 1 line
1.6.5.3