From: Daniel Vetter <daniel@ffwll.ch>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
LKML <linux-kernel@vger.kernel.org>,
DRI Development <dri-devel@lists.freedesktop.org>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
Daniel Vetter <daniel.vetter@intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 11/12] sched: use for_each_if in topology.h
Date: Mon, 9 Jul 2018 17:52:04 +0200 [thread overview]
Message-ID: <20180709155204.GD3008@phenom.ffwll.local> (raw)
In-Reply-To: <20180709151258.GV2476@hirez.programming.kicks-ass.net>
On Mon, Jul 09, 2018 at 05:12:58PM +0200, Peter Zijlstra wrote:
> On Mon, Jul 09, 2018 at 05:00:07PM +0200, Daniel Vetter wrote:
> > On Mon, Jul 9, 2018 at 12:36 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> > > On Mon, Jul 09, 2018 at 10:36:49AM +0200, Daniel Vetter wrote:
>
> > >> #define for_each_node_with_cpus(node) \
> > >> for_each_online_node(node) \
> > >> - if (nr_cpus_node(node))
> > >> + for_each_if (nr_cpus_node(node))
> > >
> > > Not having gotten any of the other patches, I'm not really sure what
> > > this does and such, but improve readability it does not :/
> >
> > Patch 1 in this series, which I dumped onto lkml as a whole:
> >
> > https://lkml.org/lkml/2018/7/9/179
>
> Right, so while I don't object to being Cc'ed to the whole series, I do
> mind not being Cc'ed to at least the generic bits required to understand
> the patch I do have to look at.
>
> > Imo it does improve readability for the if (!cond) {} else pattern.
> > And (assuming my grep fu isn't too badly wrong) most places in the
> > kernel do use this pattern in for_each macros, so I guess its a real
> > thing. We've definitely hit it plenty in drm iterators (but we seem to
> > like if() checks in iterator macros maybe a bit too much).
> >
> > I'm happy to drop this patch tough if you deem it offensive.
>
> I'd just like to understand it better; what compiler complains about
> this and is the warning otherwise useful? These things don't seem
> mentioned in that initial patch either.
>
> IOW I suppose I'm asking for the justification of this churn. If it's
> really needed and useful so be it, but so far I'm not seeing any.
>
> At a while guess I'd say this is something new in gcc-8 (and while I
> have that installed on some machines, it doesn't seem to be the default,
> and so I've not actually seen its output). But is the warning actually
> useful, should we not just kill the warning like we tend to do some
> really silly ones.
for_each_something(foo)
if (foo->bla)
call_bla(foo);
else
call_default(foo);
Totally contrived, but this complains. Liberally sprinkling {} also shuts
up the compiler, but it's a bit confusing given that a plain for {;;} is
totally fine. And it's confusing since at first glance the compiler
complaining about nested if and ambigous else doesn't make sense since
clearly there's only 1 if there.
Wrt this being useful or not: We've had it for a while in drm, and Andy
and Yishen where rolling yet another open coded version of this on a patch
that flew past me on dri-devel. So I pointed them at the for_each_if() we
have and typed this series to move it to kernel.h.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2018-07-09 15:52 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 8:36 [PATCH 01/12] kernel.h: Add for_each_if() Daniel Vetter
2018-07-09 8:36 ` [PATCH 02/12] blk: use for_each_if Daniel Vetter
2018-07-11 16:40 ` Tejun Heo
2018-07-11 16:45 ` Tejun Heo
2018-07-11 18:30 ` Jens Axboe
2018-07-11 18:50 ` Daniel Vetter
2018-07-11 19:31 ` Jens Axboe
2018-07-11 20:06 ` Tejun Heo
2018-07-11 21:08 ` Daniel Vetter
2018-07-11 21:13 ` Jens Axboe
2018-07-12 6:41 ` Daniel Vetter
2018-07-12 6:45 ` Joe Perches
2018-07-12 13:54 ` Jens Axboe
2018-07-12 15:32 ` Joe Perches
2018-07-13 9:28 ` Vlastimil Babka
2018-07-09 8:36 ` [PATCH 03/12] cgroup: " Daniel Vetter
2018-07-11 16:46 ` Tejun Heo
2018-07-09 8:36 ` [PATCH 04/12] cpufreq: " Daniel Vetter
2018-07-09 9:28 ` Eric Engestrom
2018-07-09 16:11 ` [PATCH] " Daniel Vetter
2018-07-09 21:36 ` Rafael J. Wysocki
2018-07-09 8:36 ` [PATCH 05/12] dmar: Use for_each_If Daniel Vetter
2018-07-20 12:50 ` Joerg Roedel
2018-07-09 8:36 ` [PATCH 06/12] mm: use for_each_if Daniel Vetter
2018-07-09 18:00 ` Pavel Tatashin
2018-07-09 8:36 ` [PATCH 07/12] ide: " Daniel Vetter
2018-07-09 8:36 ` [PATCH 08/12] netdev: " Daniel Vetter
2018-07-09 8:36 ` [PATCH 09/12] nubus: " Daniel Vetter
2018-07-09 10:17 ` Finn Thain
2018-07-17 15:26 ` Geert Uytterhoeven
2018-07-09 8:36 ` [PATCH 10/12] pci: " Daniel Vetter
2018-07-09 22:48 ` Bjorn Helgaas
2018-07-09 8:36 ` [PATCH 11/12] sched: use for_each_if in topology.h Daniel Vetter
2018-07-09 10:36 ` Peter Zijlstra
2018-07-09 15:00 ` Daniel Vetter
2018-07-09 15:12 ` Peter Zijlstra
2018-07-09 15:52 ` Daniel Vetter [this message]
2018-07-09 16:03 ` Peter Zijlstra
2018-07-09 16:06 ` Daniel Vetter
2018-07-09 16:12 ` Mark Rutland
2018-07-09 17:55 ` [Intel-gfx] " Daniel Vetter
2018-07-11 16:51 ` Mark Rutland
2018-07-09 16:30 ` Peter Zijlstra
2018-07-09 8:36 ` [PATCH 12/12] usb: use for_each_if Daniel Vetter
2018-07-09 11:50 ` [PATCH 01/12] kernel.h: Add for_each_if() Andy Shevchenko
2018-07-09 16:25 ` [PATCH] " Daniel Vetter
2018-07-09 18:30 ` Andy Shevchenko
2018-07-09 23:30 ` Andrew Morton
2018-07-10 7:53 ` Daniel Vetter
2018-07-10 10:32 ` NeilBrown
2018-07-11 11:51 ` Daniel Vetter
2018-07-11 23:05 ` Andrew Morton
2018-07-12 6:39 ` Daniel Vetter
2018-07-13 23:37 ` NeilBrown
2018-07-13 23:42 ` Randy Dunlap
2018-07-16 8:11 ` Andy Shevchenko
2018-07-16 15:41 ` Randy Dunlap
2018-07-16 22:16 ` NeilBrown
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=20180709155204.GD3008@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=akpm@linux-foundation.org \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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).