linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kbuild@lists.01.org, Mel Gorman <mgorman@suse.de>,
	lkp@intel.com, kbuild-all@lists.01.org,
	Linux Memory Management List <linux-mm@kvack.org>,
	Nicolas Saenz Julienne <nsaenzju@redhat.com>
Subject: Re: [kbuild] [linux-next:master 7884/8197] mm/page_alloc.c:3813 rmqueue_pcplist() warn: inconsistent returns 'flags'.
Date: Thu, 7 Jul 2022 13:08:46 -0700	[thread overview]
Message-ID: <20220707130846.e3eb6b2f9f624a357c2c2ca5@linux-foundation.org> (raw)
In-Reply-To: <202207071103.r5a2F97A-lkp@intel.com>

On Thu, 7 Jul 2022 09:44:03 +0300 Dan Carpenter <dan.carpenter@oracle.com> 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@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> 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.



  reply	other threads:[~2022-07-07 20:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  6:44 Dan Carpenter
2022-07-07 20:08 ` Andrew Morton [this message]
2022-07-08 10:48 ` Mel Gorman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220707130846.e3eb6b2f9f624a357c2c2ca5@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mgorman@suse.de \
    --cc=nsaenzju@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox