linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
	kbuild test robot <fengguang.wu@intel.com>,
	kbuild-all@01.org,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: mm/page_alloc.c:247:6: warning: unused variable 'nid'
Date: Tue, 7 Jul 2015 09:12:33 +0100	[thread overview]
Message-ID: <20150707081233.GK6812@suse.de> (raw)
In-Reply-To: <20150706150509.48abfb09376605d611ceadbe@linux-foundation.org>

On Mon, Jul 06, 2015 at 03:05:09PM -0700, Andrew Morton wrote:
> On Sat, 4 Jul 2015 21:10:08 +0300 "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
> 
> > On Sat, Jul 04, 2015 at 05:26:47PM +0800, kbuild test robot wrote:
> > > tree:   git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   14a6f1989dae9445d4532941bdd6bbad84f4c8da
> > > commit: 3b242c66ccbd60cf47ab0e8992119d9617548c23 x86: mm: enable deferred struct page initialisation on x86-64
> > > date:   3 days ago
> > > config: x86_64-randconfig-x006-201527 (attached as .config)
> > > reproduce:
> > >   git checkout 3b242c66ccbd60cf47ab0e8992119d9617548c23
> > >   # save the attached .config to linux build tree
> > >   make ARCH=x86_64 
> > > 
> > > All warnings (new ones prefixed by >>):
> > > 
> > >    mm/page_alloc.c: In function 'early_page_uninitialised':
> > > >> mm/page_alloc.c:247:6: warning: unused variable 'nid' [-Wunused-variable]
> > >      int nid = early_pfn_to_nid(pfn);
> > 
> > We can silence the warning with something like patch below. But I'm not
> > sure it worth it.
> > 
> > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> > index 754c25966a0a..746a6a7b0535 100644
> > --- a/include/linux/mmzone.h
> > +++ b/include/linux/mmzone.h
> > @@ -911,7 +911,7 @@ extern char numa_zonelist_order[];
> >  #ifndef CONFIG_NEED_MULTIPLE_NODES
> >  
> >  extern struct pglist_data contig_page_data;
> > -#define NODE_DATA(nid)         (&contig_page_data)
> > +#define NODE_DATA(nid)         ((void)nid, &contig_page_data)
> >  #define NODE_MEM_MAP(nid)      mem_map
> >  
> >  #else /* CONFIG_NEED_MULTIPLE_NODES */
> 
> Sigh.  Macros do suck.  If NODE_DATA was a regular old C function this
> warning wouldn't occur.  Problem is, we should then rename it to
> "node_data" and that would require 246 edits.
> 
> I suppose we could compromise and do 
> 
> 	static inline struct pglist_data *NODE_DATA(int nid)
> 
> ?

It might set a bad precedent. While I know there are counter examples,
I generally expect CAPITAL_NAMES to be macros of some description --
usually constants. This is a relatively harmless warning thats easy to
work around so how about this?

---8<---
mm, meminit: Suppress unused memory variable warning

The kbuild test robot reported the following

  tree:   git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
  head:   14a6f1989dae9445d4532941bdd6bbad84f4c8da
  commit: 3b242c66ccbd60cf47ab0e8992119d9617548c23 x86: mm: enable deferred struct page initialisation on x86-64
  date:   3 days ago
  config: x86_64-randconfig-x006-201527 (attached as .config)
  reproduce:
    git checkout 3b242c66ccbd60cf47ab0e8992119d9617548c23
    # save the attached .config to linux build tree
    make ARCH=x86_64

  All warnings (new ones prefixed by >>):

     mm/page_alloc.c: In function 'early_page_uninitialised':
  >> mm/page_alloc.c:247:6: warning: unused variable 'nid' [-Wunused-variable]
       int nid = early_pfn_to_nid(pfn);

It's due to the NODE_DATA macro ignoring the nid parameter on !NUMA
configurations. This patch avoids the warning by not declaring nid.

Signed-off-by: Mel Gorman <mgorman@suse.de>
---
 mm/page_alloc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 506eac8b38af..ac05e7ae399e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -246,9 +246,7 @@ static inline void reset_deferred_meminit(pg_data_t *pgdat)
 /* Returns true if the struct page for the pfn is uninitialised */
 static inline bool __meminit early_page_uninitialised(unsigned long pfn)
 {
-	int nid = early_pfn_to_nid(pfn);
-
-	if (pfn >= NODE_DATA(nid)->first_deferred_pfn)
+	if (pfn >= NODE_DATA(early_pfn_to_nid(pfn))->first_deferred_pfn)
 		return true;
 
 	return false;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2015-07-07  8:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-04  9:26 kbuild test robot
2015-07-04 18:10 ` Kirill A. Shutemov
2015-07-06 22:05   ` Andrew Morton
2015-07-07  8:12     ` Mel Gorman [this message]

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=20150707081233.GK6812@suse.de \
    --to=mgorman@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=kbuild-all@01.org \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    /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