On 10/19/21 14:50, Matthew Wilcox (Oracle) wrote: > Leave interrupts disabled when we change which lru lock is held. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Assuming lockdep is fine with e.g.: spin_lock_irqsave(A); spin_unlock(A); spin_lock(B); spin_unlock_irqrestore(B); (with A and B of same class). > --- > include/linux/memcontrol.h | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 3096c9a0ee01..a6a90b00a22b 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -1524,16 +1524,22 @@ static inline bool page_matches_lruvec(struct page *page, struct lruvec *lruvec) > } > > /* Don't lock again iff page's lruvec locked */ > -static inline struct lruvec *relock_page_lruvec_irq(struct page *page, > +static inline struct lruvec *relock_page_lruvec(struct page *page, > struct lruvec *locked_lruvec) > { > - if (locked_lruvec) { > - if (page_matches_lruvec(page, locked_lruvec)) > - return locked_lruvec; > + if (page_matches_lruvec(page, locked_lruvec)) > + return locked_lruvec; > > - unlock_page_lruvec_irq(locked_lruvec); > - } > + unlock_page_lruvec(locked_lruvec); > + return lock_page_lruvec(page); > +} > > +/* Don't lock again iff page's lruvec locked */ > +static inline struct lruvec *relock_page_lruvec_irq(struct page *page, > + struct lruvec *locked_lruvec) > +{ > + if (locked_lruvec) > + return relock_page_lruvec(page, locked_lruvec); > return lock_page_lruvec_irq(page); > } > > @@ -1541,13 +1547,8 @@ static inline struct lruvec *relock_page_lruvec_irq(struct page *page, > static inline struct lruvec *relock_page_lruvec_irqsave(struct page *page, > struct lruvec *locked_lruvec, unsigned long *flags) > { > - if (locked_lruvec) { > - if (page_matches_lruvec(page, locked_lruvec)) > - return locked_lruvec; > - > - unlock_page_lruvec_irqrestore(locked_lruvec, *flags); > - } > - > + if (locked_lruvec) > + return relock_page_lruvec(page, locked_lruvec); > return lock_page_lruvec_irqsave(page, flags); > } > >