Commit 7abcb84f authored by I Hsin Cheng's avatar I Hsin Cheng Committed by Andrew Morton

lib/plist.c: enforce memory ordering in plist_check_list

There exists an iteration over a plist in plist_check_list(), and memory
dependency exists between variables "prev", "next" and "prev->next".  As
plist is used in the scheduling subsystem, we should guarantee the memory
ordering between multiple processors.

Using macro "WRITE_ONCE()" can help us to ensure the memory ordering as
it was stated in "Documentation/memory-barriers.txt".

Link: https://lkml.kernel.org/r/20240526140139.17220-1-richard120310@gmail.comSigned-off-by: default avatarI Hsin Cheng <richard120310@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 87beb669
......@@ -47,8 +47,8 @@ static void plist_check_list(struct list_head *top)
plist_check_prev_next(top, prev, next);
while (next != top) {
prev = next;
next = prev->next;
WRITE_ONCE(prev, next);
WRITE_ONCE(next, prev->next);
plist_check_prev_next(top, prev, next);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment