Tasklets: Avoid duplicating __tasklet_{,hi_}schedule() code
PATCH 1/1 Tasklets: Avoid duplicating __tasklet_{,hi_}schedule() code
Hi all,
Avoid duplicating __tasklet_schedule() and __tasklet_hi_schedule() code in tasklet_action() and tasklet_hi_action() respectively.
---
This also saves a few bytes of image space:
text data bss dec hex filename 3632 12 324 3968 f80 softirq.o.before 3552 12 324 3888 f30 softirq.o.after
kernel/softirq.c +4 -10
@@ -414,11 +414,8 @@ static void tasklet_action(struct softirq_action *a)tasklet_unlock (t); } -local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t); } }
@@ -447,11 +444,8 @@ static void tasklet_hi_action(struct softirq_action *a)tasklet_unlock (t); } -local_irq_disable (); - t->next =__get_cpu_var (tasklet_hi_vec).list; -__get_cpu_var (tasklet_hi_vec).list = t; -__raise_softirq_irqoff (HI_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_hi_schedule (t); } }
Regards,
Signature · 3 lines
Ahmed S. Darwish Homepage: http://darwish.07.googlepages.com Blog: http://darwish-07.blogspot.com
kernel/softirq.c static void tasklet_action(struct softirq_action *a) · line 418
Quoted 7 lines · Ahmed S. Darwish
kernel/softirq.c +2
-5-local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t);
i think there's a subtle difference that you missed: this one does __raise_softirq_irqoff(), while __tasklet_schedule() does a raise_softirq_irqoff(). (note the lack of undescores)
the reason is to avoid infinitely self-activating tasklets.
Ingo
Quoted 15 lines · Ingo Molnar
kernel/softirq.c static void tasklet_action(struct softirq_action *a) · line 418
Quoted 7 lines · Ahmed S. Darwish
kernel/softirq.c +2
-5-local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t);i think there's a subtle difference that you missed: this one does
__raise_softirq_irqoff(), while__tasklet_schedule()does araise_softirq_irqoff(). (note the lack of undescores)
Quoted 2 lines
the reason is to avoid infinitely self-activating tasklets.
Indeed, thanks a lot for the explanation. (maybe it's time to check for new eyeglasses ;)).
Regards
Signature · 3 lines
Ahmed S. Darwish Homepage: http://darwish.07.googlepages.com Blog: http://darwish-07.blogspot.com
Quoted 12 lines · Ahmed S. Darwish
Quoted 12 lines
kernel/softirq.c static void tasklet_action(struct softirq_action *a) · line 418
Quoted 7 lines
kernel/softirq.c +2
-5-local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t);i think there's a subtle difference that you missed: this one does
__raise_softirq_irqoff(), while__tasklet_schedule()does araise_softirq_irqoff(). (note the lack of undescores)
Quoted 4 lines
Quoted 1 line
the reason is to avoid infinitely self-activating tasklets.
Indeed, thanks a lot for the explanation. (maybe it's time to check for new eyeglasses ;)).
nah, it's rather subtle and the code looked good to me at first but i remembered that there was some small detail here to watch out for.
i really dont like tasklets due to their many, arbitrary scheduling limitations, we should really use the "turn tasklets into kthreads" patch i posted last year.
Ingo
Quoted 20 lines · Ingo Molnar
Quoted 12 lines · Ahmed S. Darwish
Quoted 12 lines
kernel/softirq.c static void tasklet_action(struct softirq_action *a) · line 418
Quoted 7 lines
kernel/softirq.c +2
-5-local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t);i think there's a subtle difference that you missed: this one does
__raise_softirq_irqoff(), while__tasklet_schedule()does araise_softirq_irqoff(). (note the lack of undescores)Quoted 4 lines
Quoted 1 line
the reason is to avoid infinitely self-activating tasklets.
Indeed, thanks a lot for the explanation. (maybe it's time to check for new eyeglasses ;)).
Quoted 7 lines
nah, it's rather subtle and the code looked good to me at first but i remembered that there was some small detail here to watch out for.
i really dont like tasklets due to their many, arbitrary scheduling limitations, we should really use the "turn tasklets into kthreads" patch i posted last year.
While we are at it, there's a small question that is bothering me for a while (and I'm really thankful for help).
I keep reading that softirqs (and naturally, tasklets) got executed in interrupt context at the return from hardirq code path.
Checking entry_32.S, I find no mentioning of softirqs on the return path (beginning from ret_from_intr: to restore_all: )
The only invocation I'm able to find is from local_bh_enable() and from ksoftirqd/n threads (by calling do_softirq()). AFAIK, both invocations occur in a _nont-interrupt_ context (exception context).
So, where does the interrupt-context tasklets invocation really occur ?
Thanks
Signature · 3 lines
Ahmed S. Darwish Homepage: http://darwish.07.googlepages.com Blog: http://darwish-07.blogspot.com
Quoted 38 lines · Ahmed S. Darwish
Quoted 20 lines · Ingo Molnar
Quoted 8 lines · Ahmed S. Darwish
Quoted 8 lines
Quoted 7 lines
kernel/softirq.c +2
-5-local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t);Quoted 8 lines
Quoted 5 lines
i think there's a subtle difference that you missed: this one does
__raise_softirq_irqoff(), while__tasklet_schedule()does araise_softirq_irqoff(). (note the lack of undescores)the reason is to avoid infinitely self-activating tasklets.
Indeed, thanks a lot for the explanation. (maybe it's time to check for new eyeglasses ;)).
Quoted 7 lines
nah, it's rather subtle and the code looked good to me at first but i remembered that there was some small detail here to watch out for.
i really dont like tasklets due to their many, arbitrary scheduling limitations, we should really use the "turn tasklets into kthreads" patch i posted last year.
While we are at it, there's a small question that is bothering me for a while (and I'm really thankful for help).
I keep reading that softirqs (and naturally, tasklets) got executed in interrupt context at the return from hardirq code path.
Checking
entry_32.S, I find no mentioning of softirqs on the return path (beginning fromret_from_intr: torestore_all: )
Quoted 6 lines
The only invocation I'm able to find is from
local_bh_enable()and from ksoftirqd/n threads (by callingdo_softirq()). AFAIK, both invocations occur in a _nont-interrupt_ context (exception context).So, where does the interrupt-context tasklets invocation really occur ?
Look at irq_exit() in softirq.c.
The common sequence is ... -> do_IRQ() --> irq_exit() --> invoke_softirq()
Signature · 2 lines
Best regards, Dmitry Adamushko
Quoted 43 lines · Dmitry Adamushko
Quoted 42 lines · Ahmed S. Darwish
Quoted 20 lines · Ingo Molnar
Quoted 8 lines · Ahmed S. Darwish
Quoted 8 lines
Quoted 7 lines
kernel/softirq.c +2
-5-local_irq_disable (); - t->next =__get_cpu_var (tasklet_vec).list; -__get_cpu_var (tasklet_vec).list = t; -__raise_softirq_irqoff (TASKLET_SOFTIRQ ); -local_irq_enable (); +/* We were not lucky enough to run, reschedule. */ +__tasklet_schedule (t);Quoted 8 lines
Quoted 5 lines
i think there's a subtle difference that you missed: this one does
__raise_softirq_irqoff(), while__tasklet_schedule()does araise_softirq_irqoff(). (note the lack of undescores)the reason is to avoid infinitely self-activating tasklets.
Indeed, thanks a lot for the explanation. (maybe it's time to check for new eyeglasses ;)).
Quoted 7 lines
nah, it's rather subtle and the code looked good to me at first but i remembered that there was some small detail here to watch out for.
i really dont like tasklets due to their many, arbitrary scheduling limitations, we should really use the "turn tasklets into kthreads" patch i posted last year.
While we are at it, there's a small question that is bothering me for a while (and I'm really thankful for help).
I keep reading that softirqs (and naturally, tasklets) got executed in interrupt context at the return from hardirq code path.
Checking
entry_32.S, I find no mentioning of softirqs on the return path (beginning fromret_from_intr: torestore_all: )The only invocation I'm able to find is from
local_bh_enable()and from ksoftirqd/n threads (by callingdo_softirq()). AFAIK, both invocations occur in a _nont-interrupt_ context (exception context).
Quoted 8 lines
Quoted 2 lines
So, where does the interrupt-context tasklets invocation really occur ?
Look at
irq_exit()insoftirq.c.The common sequence is ... ->
do_IRQ()-->irq_exit()-->invoke_softirq()
Great, this was the last missing block in my understanding of softirqs :). Thank you.
[btw, your MUA broke the CC list]
Signature · 3 lines
Ahmed S. Darwish Homepage: http://darwish.07.googlepages.com Blog: http://darwish-07.blogspot.com