Messages in this thread | | | Date | Fri, 24 Jul 2020 16:45:25 +0200 | From | Oleg Nesterov <> | Subject | Re: [RFC PATCH] mm: silence soft lockups from unlock_page |
| |
On 07/23, Linus Torvalds wrote: > > IOW, I think we should do something like this (this is on top of my > patch, since it has that wake_page_function() change in it, but notice > how we have the exact same issue in our traditional > autoremove_wake_function() usage).
...
> +static inline void list_del_init_careful(struct list_head *entry) > +{ > + __list_del_entry(entry); > + entry->prev = entry; > + smp_store_release(&entry->next, entry); > +} > + ... > static inline int list_empty_careful(const struct list_head *head) > { > - struct list_head *next = head->next; > + struct list_head *next = smp_load_acquire(&head->next); > return (next == head) && (next == head->prev); > }
This (and your previous email) answers my concerns about memory barriers.
IIUC, finish_wait() could even use this version of list_empty_careful(),
struct list_head *next = smp_load_acquire(&head->next); return (next == head) && !WARN_ON(next != head->prev);
iow, it doesn't really need to check next == head->prev as long as only list_del_init_careful() can remove it from list.
Thanks!
Oleg.
| |