From: Jan Kara Date: Mon, 24 Feb 2014 15:39:55 +0000 (+0100) Subject: smp: Iterate functions through llist_for_each_entry_safe() X-Git-Tag: firefly_0821_release~176^2~4189^2~17 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5fd77595ec62141fa71e575bdbf410e0192f87d0;p=firefly-linux-kernel-4.4.55.git smp: Iterate functions through llist_for_each_entry_safe() The IPI function llist iteration is open coded. Lets simplify this with using an llist iterator. Also we want to keep the iteration safe against possible csd.llist->next value reuse from the IPI handler. At least the block subsystem used to do such things so lets stay careful and use llist_for_each_entry_safe(). Signed-off-by: Jan Kara Cc: Andrew Morton Cc: Christoph Hellwig Cc: Ingo Molnar Cc: Jens Axboe Signed-off-by: Frederic Weisbecker Signed-off-by: Jens Axboe --- diff --git a/kernel/smp.c b/kernel/smp.c index ffee35bef179..e3852de042a6 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -151,7 +151,8 @@ static void generic_exec_single(int cpu, struct call_single_data *csd, int wait) */ void generic_smp_call_function_single_interrupt(void) { - struct llist_node *entry, *next; + struct llist_node *entry; + struct call_single_data *csd, *csd_next; /* * Shouldn't receive this interrupt on a cpu that is not yet online. @@ -161,16 +162,9 @@ void generic_smp_call_function_single_interrupt(void) entry = llist_del_all(&__get_cpu_var(call_single_queue)); entry = llist_reverse_order(entry); - while (entry) { - struct call_single_data *csd; - - next = entry->next; - - csd = llist_entry(entry, struct call_single_data, llist); + llist_for_each_entry_safe(csd, csd_next, entry, llist) { csd->func(csd->info); csd_unlock(csd); - - entry = next; } }