Messages in this thread |  | | | Date | Mon, 16 Nov 2009 20:31:18 +0200 | | From | Avi Kivity <> | | Subject | Re: [PATCH 04/21] sched: implement scheduler notifiers |
| |
On 11/16/2009 07:15 PM, Tejun Heo wrote: > Implement scheduler notifiers. This is superset of preempt notifiers > which will be removed in favor of new notifiers. Four notifications > are defined - activated, deactivated, in and out. In and out are > identical to preempt notifiers. Activated and deactivated are called > when a task's readiness to run changes. The first three are always > called under rq lock. Out may not be called under rq lock depending > on architecture. > > The notifier block contains union of all four callbacks to avoid > defining separate interface for each. >
> + > +struct sched_notifier { > + struct hlist_node link; > + union { > + void (*activated)(struct sched_notifier *n, bool wakeup); > + void (*deactivated)(struct sched_notifier *n, bool sleep); > + void (*in)(struct sched_notifier *n, struct task_struct *prev); > + void (*out)(struct sched_notifier *n, struct task_struct *next); > + }; > +}; > + > > struct task_struct { > @@ -1237,6 +1268,8 @@ struct task_struct { > /* list of struct preempt_notifier: */ > struct hlist_head preempt_notifiers; > #endif > + /* sched notifiers */ > + struct hlist_head notifiers[SCHED_NR_NOTIFIERS]; > >
Four hlist_heads (64 bytes) is pretty heavy for this. I having all members present in sched_notifier (instead of a union) and calling a callback if it is not NULL. This reduces the overhead to 16 bytes at the expense of an extra check for sched_notifier users.
Besides this, is there any difference to preempt_notifiers? if not we can just add the new members and rename.
-- Do not meddle in the internals of kernels, for they are subtle and quick to panic.
|  |