On Thu, 7 Jul 2022 09:44:03 +0300 Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: 088b9c375534d905a4d337c78db3b3bfbb52c4a0 > commit: fdd1b94629bb5592abf40d0c7a572b58e4c0cadc [7884/8197] mm/page_alloc: protect PCP lists with a spinlock > config: i386-randconfig-m021 > compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot <lkp@xxxxxxxxx> > Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > > smatch warnings: > mm/page_alloc.c:3813 rmqueue_pcplist() warn: inconsistent returns 'flags'. > > vim +/flags +3813 mm/page_alloc.c > > 066b23935578d39 Mel Gorman 2017-02-24 3774 static struct page *rmqueue_pcplist(struct zone *preferred_zone, > 44042b4498728f4 Mel Gorman 2021-06-28 3775 struct zone *zone, unsigned int order, > 44042b4498728f4 Mel Gorman 2021-06-28 3776 gfp_t gfp_flags, int migratetype, > 44042b4498728f4 Mel Gorman 2021-06-28 3777 unsigned int alloc_flags) > 066b23935578d39 Mel Gorman 2017-02-24 3778 { > 066b23935578d39 Mel Gorman 2017-02-24 3779 struct per_cpu_pages *pcp; > 066b23935578d39 Mel Gorman 2017-02-24 3780 struct list_head *list; > 066b23935578d39 Mel Gorman 2017-02-24 3781 struct page *page; > d34b0733b452ca3 Mel Gorman 2017-04-20 3782 unsigned long flags; > fdd1b94629bb559 Mel Gorman 2022-06-24 3783 unsigned long __maybe_unused UP_flags; > 066b23935578d39 Mel Gorman 2017-02-24 3784 > dbbee9d5cd83f9d Mel Gorman 2021-06-28 3785 local_lock_irqsave(&pagesets.lock, flags); > 3b12e7e97938424 Mel Gorman 2021-06-28 3786 > fdd1b94629bb559 Mel Gorman 2022-06-24 3787 /* > fdd1b94629bb559 Mel Gorman 2022-06-24 3788 * spin_trylock may fail due to a parallel drain. In the future, the > fdd1b94629bb559 Mel Gorman 2022-06-24 3789 * trylock will also protect against IRQ reentrancy. > fdd1b94629bb559 Mel Gorman 2022-06-24 3790 */ > fdd1b94629bb559 Mel Gorman 2022-06-24 3791 pcp = this_cpu_ptr(zone->per_cpu_pageset); > fdd1b94629bb559 Mel Gorman 2022-06-24 3792 pcp_trylock_prepare(UP_flags); > fdd1b94629bb559 Mel Gorman 2022-06-24 3793 if (!spin_trylock(&pcp->lock)) { > fdd1b94629bb559 Mel Gorman 2022-06-24 3794 pcp_trylock_finish(UP_flags); > > Need to local_unlock_irqrestore(&pagesets.lock, flags); before return oops. Looks right. --- a/mm/page_alloc.c~mm-page_alloc-protect-pcp-lists-with-a-spinlock-fix +++ a/mm/page_alloc.c @@ -3792,6 +3792,7 @@ static struct page *rmqueue_pcplist(stru pcp_trylock_prepare(UP_flags); if (!spin_trylock(&pcp->lock)) { pcp_trylock_finish(UP_flags); + local_unlock_irqrestore(&pagesets.lock, flags); return NULL; } Do we really need the pcp_trylock_prepare/finish in there? local_lock_irqsave() already did that.