[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87plnl0wnk.fsf@yhuang6-desk2.ccr.corp.intel.com>
Date: Mon, 28 Oct 2024 10:49:19 +0800
From: "Huang, Ying" <ying.huang@...el.com>
To: Dan Williams <dan.j.williams@...el.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.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()
Dan Williams <dan.j.williams@...el.com> writes:
> 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.
Sure. Will do that.
--
Best Regards,
Huang, Ying
Powered by blists - more mailing lists