[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <671bb5d165_10e592941e@dwillia2-xfh.jf.intel.com.notmuch>
Date: Fri, 25 Oct 2024 08:14:25 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Dan Williams
<dan.j.williams@...el.com>
CC: "Huang, Ying" <ying.huang@...el.com>, David Hildenbrand
<david@...hat.com>, Andrew Morton <akpm@...ux-foundation.org>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<linux-cxl@...r.kernel.org>, Davidlohr Bueso <dave@...olabs.net>, "Jonathan
Cameron" <jonathan.cameron@...wei.com>, Alistair Popple <apopple@...dia.com>,
Bjorn Helgaas <bhelgaas@...gle.com>, Baoquan He <bhe@...hat.com>, Dave Jiang
<dave.jiang@...el.com>, Alison Schofield <alison.schofield@...el.com>
Subject: Re: [RFC] resource: Avoid unnecessary resource tree walking in
__region_intersects()
Andy Shevchenko wrote:
[..]
> > > but if you want to stick with your variant some improvements can be done:
> > >
> > > #define for_each_resource_XXX(_root, _p) \
> > > for (typeof(_root) __root = (_root), __p = _p = __root->child; \
> > > __p && _p; _p = next_resource_XXX(__root, _p))
> > >
> > >
> > > 1) no need to have local variable in parentheses;
> > > 2) no need to have iterator in parentheses, otherwise it would be crazy code
> > > that has put something really wrong there and still expect the thing to work.
> >
> > Why not:
> >
> > #define for_each_resource_XXX(_root, _p) \
> > for (typeof(_root) __root = (_root), __p = _p = __root->child; \
> > _p; _p = next_resource_XXX(__root, _p))
> >
> > The __p is only to allow for _p to be initialized in the first statement
> > without causing a new "_p" shadow to be declared.
>
> If people think this would be better than the existing patterns, okay. fine.
I think this case is different than the existing patterns in that the
iterator variable needs to be initiatlized from a declared variable, and
as Ying said, my proposal is busted.
To your point though, lets add a comment on why this macro is a bit
different to avoid people like me making bad cleanup suggestions.
Powered by blists - more mailing lists