Received: by 10.192.165.148 with SMTP id m20csp405865imm; Fri, 20 Apr 2018 00:58:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/7Ld6aWOqXgiuSMBafeY2RibJVX1e/E49xuAwqCmevp3tICGhKsJ74ZAQAbJgeW7vCUwf/ X-Received: by 10.98.25.133 with SMTP id 127mr8789318pfz.131.1524211137865; Fri, 20 Apr 2018 00:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524211137; cv=none; d=google.com; s=arc-20160816; b=nB0XMQ+cyE9cQyWHlKNHMRbfxhdxrcObg3vgV3JRsWvtAMRAOr5z4FEJAAhgCr9Eab rYweMzvzMtShrcsQGdr/fVvuYqhBxLI0ObXt8lojdLhzURBdfI+HqUbNE7lm6EP2/jzg e2Wj7FD2lbfXIce7ZKDDmVX6zkhzUnMhfmMjwHblAngb6tJdksI+90VGy8zlVKsizRhs pHbN2YSJ2X1s1l7/SzXcRGVtQu3iFbSUwLJbj1QbIBL2pn38lr0NCtDRN0zjhpi901c/ +yhfASDfybF86UE/JJ/IdtT7zYlEkRF6FyoEGty2dNC49SStc0CWGrNzSJLwIC0S/SWA QWDQ== 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:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=ofoPcXwTL02cZDyUKIb1VNwT5J1rOWMx5P+QVM4RovE=; b=s7iNqKfYFHO5rbT3GJIy8v8ioLWkVG9RlDr/o3Ba0RNuKKJZVIqdH+RkFHHmJhkWEZ PHxlF5i674nQ7WCD+nA0VKdKMzam6iZ624pjCQYdA8HxNPDJgMynlM5tL9kzq7S39xlF VmuIJ2nxQVhmV2q71K5E1wNYm5o5OCBH+k5xN7hPm0ZxlQW1s7EPWV9tgeOXSEsXX8Ba 8qlnwR5DOT3j+cfmfGrSzDCjWPQSC5FJAQOnBZHCIHQ2wk9YKWP+eKsiI71V6GdNZjnD uqMUvoagpz9ok2W5nHHzkrb+mVferC46g9svUBY0GECUdayNvJc6hNdVIqe86IMsnkAz ukLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tPGdBCYW; 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 n11-v6si5085502pls.422.2018.04.20.00.58.43; Fri, 20 Apr 2018 00:58:57 -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=@infradead.org header.s=bombadil.20170209 header.b=tPGdBCYW; 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 S1753935AbeDTH5j (ORCPT + 99 others); Fri, 20 Apr 2018 03:57:39 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37344 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753620AbeDTH5i (ORCPT ); Fri, 20 Apr 2018 03:57:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ofoPcXwTL02cZDyUKIb1VNwT5J1rOWMx5P+QVM4RovE=; b=tPGdBCYWhpY4bxpyFs6B0/PGU pQ1TjmTmrkgNKUgQol8H9Ghepq7rAXL/kLz03hvhLdXpATwdMet4bxhlqmui9Uag/Xj7gyvK939Bn JjtdSF1Qq80rdphbUY07YfK7QzMKBU2A2MxuqATUyqHuBZoIhUPhVbw1MVbWg+fb89cY4ynGEtZ1Q kDHqLm78QKlW6xGZ3iv/aIoAqt8b1SoZbCGK/df6FmdGdZ22nS60X+QjfvrRabzd8xJ+F9rdwLzbc 2PZKz+IQ/ASc5Qn8z1DPGHjUXCJKlmhEWtxsOqXLFfZm/nF/wc+sNahoZCfZQdZN5aluDCE3W6+cb znnoxMmYw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9Qv0-0005MQ-Vu; Fri, 20 Apr 2018 07:57:19 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4FA5E2029B0F8; Fri, 20 Apr 2018 09:57:17 +0200 (CEST) Date: Fri, 20 Apr 2018 09:57:17 +0200 From: Peter Zijlstra To: Philipp Klocke Cc: lukas.bulwahn@gmail.com, kernelnewbies@kernelnewbies.org, llvmlinux@lists.linuxfoundation.org, sil2review@lists.osadl.org, der.herr@hofr.at, Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: Change sched_feat(x) in !CONFIG_SCHED_DEBUG case Message-ID: <20180420075717.GB4064@hirez.programming.kicks-ass.net> References: <20180416085426.24157-1-Phil_K97@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180416085426.24157-1-Phil_K97@gmx.de> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 10:54:26AM +0200, Philipp Klocke wrote: > This patch is motivated by the clang warning Wconstant-logical-operand, > issued when logically comparing a variable to a constant integer that is > neither 1 nor 0. It happens for sched_feat(x) when sysctl_sched_features > is constant, i.e., CONFIG_SCHED_DEBUG is not set. > > kernel/sched/fair.c:3927:14: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand] > if (initial && sched_feat(START_DEBIT)) > ^ ~~~~~~~~~~~~~~~~~~~~~~~ > kernel/sched/fair.c:3927:14: note: use '&' for a bitwise operation > if (initial && sched_feat(START_DEBIT)) > ^~ > & > kernel/sched/fair.c:3927:14: note: remove constant to silence this warning > if (initial && sched_feat(START_DEBIT)) > ~^~~~~~~~~~~~~~~~~~~~~~~~~~ > @@ -1305,7 +1305,11 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features = > 0; > #undef SCHED_FEAT > > +#ifdef CONFIG_SCHED_DEBUG > #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) > +#else > +#define sched_feat(x) ((sysctl_sched_features >> __SCHED_FEAT_##x) & 1UL) > +#endif So this is extra ugly, for no gain? WTH does clang complain about a constant? Can't you just disable that stupid warning? Also, if sysctl_sched_features is a constant, the both expressions _should_ really result in a constant and clang should still warn about it. I'm really not seeing why we'd want to do this. Just fix clang to not be stupid.