Received: by 10.192.165.156 with SMTP id m28csp395729imm; Mon, 16 Apr 2018 01:57:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+6Gexh8d9h5/3f0WzBI7j55zXTN2CBaIrjN/aGLyfFv/Lno2Gs6JM+eXRlt1spx6Rc5e3s X-Received: by 2002:a17:902:8a81:: with SMTP id p1-v6mr14981884plo.183.1523869076113; Mon, 16 Apr 2018 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523869076; cv=none; d=google.com; s=arc-20160816; b=cN85HRCj6tiMocqb0miIxsr4XfCMOvk3i3wNWb4ZR3htzCwbVkvfcXPZ3jkg0LX6lf sCmBsQacdCfAnUmXQK4aVUXPFouCkzANYtohANWC2NN5uRuSM7c6hmhTbtwEqj1OVGkI I0N2w3D19HKAtuwpHqQ1KY4Luts6ObRgU0niI29AsHJT8Dpzg6pU41ilL2ozLZzHkZJj Eobe/zui9vbZRnlzNeGQpMoRq2pJOSJ59t1AxbR3tUMQERYjeT4RzQoQpVgFGrPMl0lh ssr3oR7qBbzdwdUhotATeHJrrBaAKTZch9Skd+q3Ji9MFVNbkBYA/DPLtXzxMzfhRAGZ fRrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :arc-authentication-results; bh=RqoopFvQgTbLL9ZG6NlqsHdPZgGppsYFRvuiJMc56Y4=; b=wM7FgNuHsOg5dDWzatjexT7S92GwwadDXZJSeoSiDRLkqKzNTjtpy4EPeF76kJbfzs DTy7HlTGro3pIiOEFKHo0Q7GsEDpXA6iCZ9dh/q79uaHry4YwZpSY40/Ov0iqlSfsks6 rCOrl+u0N83bKADfZA9JY9EHx6G8oJmFi9zI8sbslZhg0qcNyPz51W4MDNoRlivuAQ0a 8gRr3Tz2LX0Foi31YSR8wI35NEp0UaCITXlzLK+0VlUbMB0/KNBWKdwvKwiWiAEvts40 zyBirbDZeG85z3tNxnmOVbLLD4ZrJaaGg2uYHc9adJVL+Jumskrickyw+2zO8k616+Bt 4e+g== 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 t18si10485541pfi.319.2018.04.16.01.57.42; Mon, 16 Apr 2018 01:57: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; 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 S1754431AbeDPI4i (ORCPT + 99 others); Mon, 16 Apr 2018 04:56:38 -0400 Received: from mout.gmx.net ([212.227.15.15]:42337 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754220AbeDPI4g (ORCPT ); Mon, 16 Apr 2018 04:56:36 -0400 Received: from Aperture.informatik.tu-muenchen.de ([131.159.209.98]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LyVIk-1eL6Ke2Uha-015nPT; Mon, 16 Apr 2018 10:56:06 +0200 From: Philipp Klocke Cc: lukas.bulwahn@gmail.com, kernelnewbies@kernelnewbies.org, llvmlinux@lists.linuxfoundation.org, sil2review@lists.osadl.org, der.herr@hofr.at, Philipp Klocke , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: [PATCH] sched/fair: Change sched_feat(x) in !CONFIG_SCHED_DEBUG case Date: Mon, 16 Apr 2018 10:54:26 +0200 Message-Id: <20180416085426.24157-1-Phil_K97@gmx.de> X-Mailer: git-send-email 2.17.0 X-Provags-ID: V03:K1:oqR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vviH6Qhd ZH/saf/8pxIxTTqn7myEY7ALl+iOQ== To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sched_feat(x) return 1 or 0 instead of 2**x or 0 when sysctl_sched_features is constant, by changing the left shift of the mask-bit to a right shift of the bitmap. The behaviour of the code remains unchanged. We prove this by showing that the compiler can evaluate this shift during compile time, which results in generating the same machine code as before. 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)) ~^~~~~~~~~~~~~~~~~~~~~~~~~~ This resolves the warning, leaves the code base largely as is. Tested with gcc 7.3.1 and clang 6.0.0 on x86_64, comparing resulting binaries with diff. Applicable to all modern compilers and architectures Signed-off-by: Philipp Klocke Suggested-by: Lukas Bulwahn --- kernel/sched/sched.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index fb5fc458547f..d2aedee6ab0f 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -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 #endif /* SCHED_DEBUG && HAVE_JUMP_LABEL */ -- 2.17.0