Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp689593imm; Mon, 9 Jul 2018 08:54:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdi0/c0lZG18cFkQ8aYCE+suCuzZMURQMym95DGbgGyxlD/he6qszdLZ6zWhTlczQyrAFE0 X-Received: by 2002:a62:4898:: with SMTP id q24-v6mr21591303pfi.58.1531151696858; Mon, 09 Jul 2018 08:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531151696; cv=none; d=google.com; s=arc-20160816; b=zJvdSdRSEk11pdckSTQmrBb8udZbxA/txs8V79d2zfnpuQ9nkhrzt/iTEov7dsC4ZA B2oJ1uR0ETcRUUQZbY43hLjz9il2YQp/pyiM8oG0hGCL3J2BsfSWN2xA07XtnX5TVSbr XDaFJ6VsgrX+zc6Z7khtUYeYngd/fZAHJiRnqPnXbk0h099Q8gbOxBkIRr/xAuF057o/ do9iLVFTxTzAzUClfvMhCOYDfW/97J2JNRgNPrMlPeoJiBlKFdfxYMmC55bK54z1rTd/ 0JCuWVGIjDdZPJI+Im33riMLI2oW+jZtjDUXZAv5218AHOYMKfpMrOyo2iYui59vdE9A rA5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=3k83YPOjMQc9TxIjIfULVIR2/Ixa1HISJxm3xzghrfM=; b=D6fHNiYcvPN6qMqAXke2b7k6I43HVpXzP35ntc/KIP11sfp0LXLssq0+C5Jfr+NRcV zWCZqMAQdIJg3msvs4czwbCFLd0Uj3V8tCvQnTyeQ4ZYE/p23gJSsmGYHgTH5mfrDBoc BQhqLDyUK8NvF8oUfmxTELor2CXMj7JZMCbcsYOeaKiT0a23Ivx5Ze9eeu8zFIxji3uw PyOhvNc0ZuU+eD0s61axXA+4TAhovn0YCQnELrJIwkVwjFmvIhBzgUFF/zXbwCI3WpiY nAb7LfxkHUnhfWo4B1tSCDo+utKMDQSrZ/v+1VINcYokA/vFSRY5tHe29Xgq/7BLws26 ug0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=jpSnKR6l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 25-v6si14575802pgk.438.2018.07.09.08.54.42; Mon, 09 Jul 2018 08:54:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=jpSnKR6l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932996AbeGIPwL (ORCPT + 99 others); Mon, 9 Jul 2018 11:52:11 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:45521 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933374AbeGIPwI (ORCPT ); Mon, 9 Jul 2018 11:52:08 -0400 Received: by mail-ed1-f67.google.com with SMTP id i20-v6so1296806eds.12 for ; Mon, 09 Jul 2018 08:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=3k83YPOjMQc9TxIjIfULVIR2/Ixa1HISJxm3xzghrfM=; b=jpSnKR6li/TUFqvkmBmpAwJWgsWc5EEPqjfExK7xowJ3bLuV2qyjfilcw1Ttqoturi u8R3uWamZCixl9RvMMS1QxEQRQKbUMwTDU46G9YIxerw8zdPFS02Sc5YuICY2fdvnV7u epfiACIA+5oaJIKaTAV/AGIZdhFLn1YvunDcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=3k83YPOjMQc9TxIjIfULVIR2/Ixa1HISJxm3xzghrfM=; b=JfrimtPtsz42bn0HTMcZT6ViT7vYFD+22vBsyruZDMIn++VBW1k7YBzkO2PH9EbSTN W+B8LwWL2DF8yeXK405qzYkgQEqdDDPUSQk0AHjheN2826ZK+rpOfyxNIufbzcWfIGa7 aHBECxHMY9BpCINMU5V3vsM7wi+5l1LFNDjpKR8n5HFgv/GozFtghVO1bY/d8EMrJuWb Ve+5q6vyLQzyzReiN/zKp93Qo/ol9JAtbzn9mbXuMXYwgKPm430hmsac8/L1bcav1nLO rOwBJp+UGKUA4hEYccfrlHlQHF4nbWIcqbkgWlefa8rXb3QGylPedIrPDXzCpG84mWN4 18Tw== X-Gm-Message-State: APt69E0Gsq1oAumh8PUPXqzNAFay56slm7QVUy8UOL1bHeJUqqejmFol O+m0aJMLNDWaIHZ1hV4/VXjphg== X-Received: by 2002:a50:8818:: with SMTP id b24-v6mr23706106edb.274.1531151527541; Mon, 09 Jul 2018 08:52:07 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5628:0:496f:7dc5:66d7:a057]) by smtp.gmail.com with ESMTPSA id u3-v6sm972949edo.44.2018.07.09.08.52.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 08:52:06 -0700 (PDT) Date: Mon, 9 Jul 2018 17:52:04 +0200 From: Daniel Vetter To: Peter Zijlstra Cc: Daniel Vetter , LKML , DRI Development , Intel Graphics Development , Daniel Vetter , Andrew Morton Subject: Re: [PATCH 11/12] sched: use for_each_if in topology.h Message-ID: <20180709155204.GD3008@phenom.ffwll.local> Mail-Followup-To: Peter Zijlstra , LKML , DRI Development , Intel Graphics Development , Daniel Vetter , Andrew Morton References: <20180709083650.23549-1-daniel.vetter@ffwll.ch> <20180709083650.23549-11-daniel.vetter@ffwll.ch> <20180709103656.GH2476@hirez.programming.kicks-ass.net> <20180709151258.GV2476@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180709151258.GV2476@hirez.programming.kicks-ass.net> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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