Received: by 10.213.65.68 with SMTP id h4csp3746383imn; Tue, 10 Apr 2018 04:10:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx49n8IoRasUmv3Gq2V8mMLNpvl5jrk+nDX6QZFt/Hri2JGdoxSexrkNNYO0dJvSOHoFNm+cO X-Received: by 10.98.69.217 with SMTP id n86mr2374266pfi.41.1523358615566; Tue, 10 Apr 2018 04:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523358615; cv=none; d=google.com; s=arc-20160816; b=kxRzHApgIKCWvjdwVZRTjN16Nj5E7Vk7yZ4aUDDC+nO3HGb7KTA3c765W2MVb/0ogs b/sWnhWx8jYlz4ex7lz9JsLYN4TTASjTIiX6luPaF3ZKYLxJAAvz19LgaTG5Xbsouo9M acnYwFbYXUkl3rxSDqZ5f8TnuLwt3AJaQQMt9QZpVY0oly7o9E4zeKrF8k3mwfme0v1s c+ROixPkPrh+u/OSkQA56K3wG8qLoSxET0x3E99KPzA5jzDW/silZAHynf8k88BKCUwr GccuhNPf5dzQk3Y+/zUXCFJj9FYptGgonCDhLphPCXEZ0AzWRq9Z3rFrC7Beohx4hKlw xz6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=0Lb+QElYtOdqb64ye5owi8825oI+LZVHmuFhIeVCMeA=; b=mS9GG+0pLTAKvmiAJKMmZ9w00jkTUFf7u+/sOWrfew7eRVUCqRdCyu2xVl/4NmF4P4 7w77j0goF40m2bzAzGbByEcx86rZJEKoL7d90aHki52rw1OD/gpgaYtYD96ahmrHtcsi mQbYJW7PHN8xKiQ9YApU4BhRbe/VkiqHscGhIQIbob4OPcu+3HI0HqTLZIrD3ES6F1fE sg/6SC+NN4shpUBIdx7U//DZ8OR/gAsSi/af04y8LvJ42JBsN1bwDonMwPLAio3FI0ch Ei6J+2SHArAHJKKfMPWR0w3iuutYxv03viSBDRqMoKSFUfhMgI3RqoanQ/fL8eIjwD0G 31yA== ARC-Authentication-Results: i=1; mx.google.com; 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 u206si1627270pgb.321.2018.04.10.04.09.37; Tue, 10 Apr 2018 04:10:15 -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; 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 S1752587AbeDJLGk (ORCPT + 99 others); Tue, 10 Apr 2018 07:06:40 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:53440 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751611AbeDJLGj (ORCPT ); Tue, 10 Apr 2018 07:06:39 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1f5r6Z-0007oh-6K; Tue, 10 Apr 2018 13:06:27 +0200 Date: Tue, 10 Apr 2018 13:06:26 +0200 (CEST) From: Thomas Gleixner To: yuankuiz@codeaurora.org cc: "Rafael J. Wysocki" , Linux PM , "Rafael J. Wysocki" , Frederic Weisbecker , Peter Zijlstra , Ingo Molnar , Len Brown , Linux Kernel Mailing List , linux-pm-owner@vger.kernel.org Subject: Re: [PATCH] time: tick-sched: use bool for tick_stopped In-Reply-To: Message-ID: References: <891d4f632fbff5052e11f2d0b6fac35d@codeaurora.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Apr 2018, yuankuiz@codeaurora.org wrote: > On 2018-04-10 05:10 PM, Thomas Gleixner wrote: > > On Tue, 10 Apr 2018, yuankuiz@codeaurora.org wrote: > > > On 2018-04-10 04:00 PM, Rafael J. Wysocki wrote: > > > > On Tue, Apr 10, 2018 at 9:33 AM, wrote: > > > > > From: John Zhao > > > > > > > > > > Variable tick_stopped returned by tick_nohz_tick_stopped > > > > > can have only true / false values. Since the return type > > > > > of the tick_nohz_tick_stopped is also bool, variable > > > > > tick_stopped nice to have data type as bool in place of unsigned int. > > > > > Moreover, the executed instructions cost could be minimal > > > > > without potiential data type conversion. > > > > > > > > > > Signed-off-by: John Zhao > > > > > --- > > > > > kernel/time/tick-sched.h | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/kernel/time/tick-sched.h b/kernel/time/tick-sched.h > > > > > index 6de959a..4d34309 100644 > > > > > --- a/kernel/time/tick-sched.h > > > > > +++ b/kernel/time/tick-sched.h > > > > > @@ -48,8 +48,8 @@ struct tick_sched { > > > > > unsigned long check_clocks; > > > > > enum tick_nohz_mode nohz_mode; > > > > > > > > > > + bool tick_stopped : 1; > > > > > unsigned int inidle : 1; > > > > > - unsigned int tick_stopped : 1; > > > > > unsigned int idle_active : 1; > > > > > unsigned int do_timer_last : 1; > > > > > unsigned int got_idle_tick : 1; > > > > > > > > I don't think this is a good idea at all. > > > > > > > > Please see https://lkml.org/lkml/2017/11/21/384 for example. > > > [ZJ] Thanks for this sharing. Looks like, this patch fall into the case of > > > "Maybe". > > > > This patch falls into the case 'pointless' because it adds extra storage > [ZJ] 1 bit vs 1 bit. no more. Groan. No. Care to look at the data structure? You create a new storage, which is incidentally merged into the other bitfield by the compiler at a different bit position, but there is no guarantee that a compiler does that. It's free to use distinct storage for that bool based bit. > > for no benefit at all. > [ZJ] tick_stopped is returned by the tick_nohz_tick_stopped() which is bool. > The benefit is no any potiential type conversion could be minded. A bit stays a bit. 'bool foo : 1;' or 'unsigned int foo : 1' has to be evaluated as a bit. So there is a type conversion from BIT to bool required because BIT != bool. By chance the evaluation can be done by evaluating the byte in which the bit is placed just because the compiler knows that the remaining bits are not used. There is no guarantee that this is done, it happens to be true for a particular compiler. But that does not make it any more interesting. It just makes the code harder to read and eventually leads to bigger storage. Thanks, tglx