Skip to content

Commit

Permalink
smp: Iterate functions through llist_for_each_entry_safe()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jens Axboe <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
jankara authored and axboe committed Feb 24, 2014
1 parent 6d11339 commit 5fd7759
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 5fd7759

Please sign in to comment.