kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: Amit Kumar <free.amit.kumar@gmail.com>
Cc: linux-newbie@vger.kernel.org,
	Kernel Newbies <kernelnewbies@kernelnewbies.org>
Subject: Re: Unable to understand a piece of code
Date: Mon, 20 May 2019 11:23:51 +1000	[thread overview]
Message-ID: <20190520012351.GA13083@eros.localdomain> (raw)
In-Reply-To: <CAPTh4Ouvn=SiGnUGV5B7Drmp2-tVCMV=Z46+t-XL5rqPcTpF-g@mail.gmail.com>

On Mon, May 20, 2019 at 05:37:41AM +0530, Amit Kumar wrote:
> HI,
> 
> mm/slub.c: line 3973
> int __kmem_cache_shrink(struct kmem_cache *s)
> {
> int node;
> int i;
> struct kmem_cache_node *n;
> struct page *page;
> struct page *t;
> struct list_head discard;
> struct list_head promote[SHRINK_PROMOTE_MAX];
> unsigned long flags;
> int ret = 0;
> 
> flush_all(s);
> for_each_kmem_cache_node(s, node, n) {
> 
> How uninitialized variable node is being used in macro for_each_kmem_cache_node?
>
> node is a local variable with no extern and not initialized.
> 
> mm/slab.h: line 490
> #define for_each_kmem_cache_node(__s, __node, __n) \
> for (__node = 0; __node < nr_node_ids; __node++) \

This _is_ the initialization of node.  Macros are kinda funky, there
isn't much more to say about that other than perhaps read up some more
about how macros work in C and read a bunch more macros in the kernel
e.g. include/linux/list.h

Good luck,
Tobin.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2019-05-20  1:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20  0:07 Unable to understand a piece of code Amit Kumar
2019-05-20  1:23 ` Tobin C. Harding [this message]
2019-05-20  3:33   ` Amit Kumar
2019-05-22 17:57 ` Máté Eckl

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=20190520012351.GA13083@eros.localdomain \
    --to=me@tobin.cc \
    --cc=free.amit.kumar@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=linux-newbie@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).