Received: by 10.192.165.148 with SMTP id m20csp462521imm; Fri, 20 Apr 2018 09:31:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/CEygPun3GZibSghrxbK9IFMFBZCP9brY/A+Kbf3W+wN0MSDBiNwSh6k84z9lPEMZKc8+9 X-Received: by 2002:a17:902:1682:: with SMTP id h2-v6mr5788077plh.127.1524241865685; Fri, 20 Apr 2018 09:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524241865; cv=none; d=google.com; s=arc-20160816; b=hazo15sxhXgdxKd98avHr4MkVaV6fBDvHcsovqOtpzSs9GP8iRs7abZRHYXW5itn/+ SGty9zTIOIo37brFl1qurs23vw73KX26Xn4Bz9ItEc5OemRiobGrsN1j+OpbkNYjWWlR K7zdGCa3gZMmlTWYZDmFMWGq98EnAB8ALrhZ2nPqYWTBZ7b1gNLn70Zix8o0K4lcC5m5 1uQcmqVTboDl6ic8hGKUnTw3q2ebJ+lSlJmR3qeUwt6A5nblAlhK3wULOsKdsDiCKkNN lh88JIo/vVIr1scgU/tmKzBcG/zZ10rJDHMMJdLLrvxmKqscZkf+8eHoyHhPnmowm+1H L8AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=B5ZTZMGGiPNQOtVcKWvKaniSL3Kg5Yw6STC57xK56wY=; b=ydPbHY2oPp+ADswbMCIR3NzoRzAG0iev+6JVFL94LnYFG7avEWk+NmLxB3gAZbbg2d +9slpYmCwhF3VLT7QtfBLcO0WyU59u1yoOw5wJSQmEvbcpLuljg2QiMa5qZJSlFd/QgT y4eCuTZkTRWU6RQ47k9Lbs/1TL7LKG9Z+I7YToVpg5KL1GR3kRAF9Z3wNyCuKYmzY26S ETJyHGC+0w0ASroz3T2fahLfKJwwqaEyDlOppWHBamAewuqRyl8j30JPVwErPwSPeZ7v 2xUYNmBTlkBjUvgerwXdvERt1AK1Wvxxlxb25fHhj7wmNFKgNU5kKrUnx2GbNIJl30In h1QQ== 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 s1si5037192pgb.281.2018.04.20.09.30.51; Fri, 20 Apr 2018 09:31:05 -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 S1752489AbeDTQ3k (ORCPT + 99 others); Fri, 20 Apr 2018 12:29:40 -0400 Received: from mout.gmx.net ([212.227.15.15]:50407 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbeDTQ3i (ORCPT ); Fri, 20 Apr 2018 12:29:38 -0400 Received: from [10.0.0.10] ([194.19.225.180]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M8ehf-1eEHUE2NAR-00wIJC; Fri, 20 Apr 2018 18:29:09 +0200 Subject: Re: [PATCH] sched/fair: Change sched_feat(x) in !CONFIG_SCHED_DEBUG case To: Peter Zijlstra 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 References: <20180416085426.24157-1-Phil_K97@gmx.de> <20180420075717.GB4064@hirez.programming.kicks-ass.net> From: Philipp Klocke Openpgp: preference=signencrypt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6M9e/E+90JLqUWiWZXzLRMLvOW3ZWeyUdGsM30c5WjXMIIwkOZ+8W5kbcLqEnHKT2Kx+KqKf yFdQnhDjshgKgu5hd67m6Lv+jD/lXLEkHMwYqBjqhcRinhDtLZOKskK7h0MAEQEAAcLBZQQY AQgADwUCVcNThQIbDAUJCWYBgAAKCRBPmrpXHFpjqy0QEADqUcSEJr5tRG0633Abw94K7Vf0 zj2cM8TIGK099wrFAtqX45Lq0rzES0K8uWTCo46HG4EDIHB9AyAViOlb/Rlp3iq63S+mP+Mo 9/amfn17fE07wMAm+fUtsfhrZcbBZpEjpCC2WBcqq2kzA5zV1HdcD6MhCV9MANkgBiRCGiLI Rc6hd0QuNlf6RdLdSCEibFVuC129860Jm6BUabjKWUoo4JgTadrqcm81e9f4uAxb6H8AdiPy RHzHNyNFwv4btWJBoz//tbk3loActraIag14TXWStAqFvnxaoTm+03/qisqyiTupJjjV87IA IHeJh7vajm000AjY1O8jdQBhKZ7OMsuBugtsM2B2KURfiDmBj+2/gyJDfJ4wg8GXc26DS8ON 7XTJPtmpgChrnx6aSPSVH14ic1egjS4mpd5papSMJBM7YPM/W/hKvy4+bahfi7jX+9bTQG7y 6jyB/OhtJ9R25mgJV9ixuGo+u/hKWTnuw3QkB3LnNcJRagM0JWUL1u+WGF/hdn5bk0lWMCEO LzzPe1A1zCtWKkbngoC+/XqkIFoGtftGXtxYLiOMBd87S7zCEniUQyL5dZWZl9xtpkcdbNEv uw5tIyT766GkXUFqUhuEzuVcY5Pz0lxOQh0L9WRciLWXcGHvvXhbNGtwsfOJf1UBEx/iVYZG 12TtBTzNsw== Message-ID: <34572fee-36d0-36e1-ba6d-f098b145aba4@gmx.de> Date: Fri, 20 Apr 2018 18:29:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180420075717.GB4064@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:21MWT+ns+NPtOtGY+yn8fZjoC/a5fyj88C9dU0YGvDFYGrWM5r1 ELxFs04GwsfTwY8AgUPRpz6JzJntLEZjuF7HmdRGdfwdJNZH/dPfxgI7x+fhWSMndFnylGn 461VFlYNESvbjUxI36g0Mb9On33dQnoKH9CG0/AV8nc62ivESxTYMEMwB1fa1oIkSXF4myS TV7K5rw7kV6pzd4pEDnDQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:yf7Che9Rtew=:IiHYIVHpfywmAE+ZShNYmg gRMXsCbclSb/srGQ8BDlU3m+JOI1UGX6YZZxRo8fTGXvKkuoMig6EGqOsMzrAvOKfQCII9S9w nUYDj5ULtdrDTX6P5Xe7CIKqk8YGzsrhby+cxSpdIx8WUjr8u4mjw4LuuMEkiVLpRHX5+2oD6 mCQ8kRIwPmH9WUoLm19LoON5AxGm+MF6oH+6knBmADvggVrQ16/l+6h/Z9UFJDVswF9eO7ATd 9Tnij4b2LFcxOjHsB+TsadDKJQVegypDfnaH4ndnlZt9rE4vocAnTf5Q3+CwqRmpaLC3QrJrF RGhpMIjMoxjtCiyXmTVFpmE473WJpPBLpsE8VbtTMIP0D8mHpRIFJ4yWgRlfR2FownhDaJSfv ta3xvReyZeSkvB59f2w6y9kj5n+8bYteGHK2nxknlMMfnZLfrf+Fo4hIou/qQpfJQueLogXIV poX9d6CrwRVhGEPu3P4V79YpyQ7kHe42m5/CQDKJ8905QESDX5czAJAO1wV9+yYfCAxMXHZg3 hk8SMExL+a/FH6K9y53/lB46l5ywtTkGeNLtajMQZxxbudRifOmGpv2S0sDagtY5JK698X2NS VKWUDxDVDpCmhr7KVha8Qem1SFQFg806KhsdKSk38eXtfqJlE7hCYMeqOhLhEV3M+b6WLdSlt lIA1GX5InhXtF6/P2MbaLwlw7JASKG/Y7A1r4566QcOynoD35hXemCpnxWRilzXl6xAhTGaxv C0gVjh88pNXLzFNwOZAhiu1b4gSUyBltfz8o+O+uyNphwzFcmFC/D8QByRxJ1374qMdCm4+Yl HoOlvI3Zq/bI848MH4/jOaPZptJedQ4fXjyR7JG2BculW3sX/A= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.04.2018 09:57, Peter Zijlstra wrote: > 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? The gain is stopping a warning that clutters the output log of clang. To improve readability, one can drop the ifdef-structure and just keep the right shift version, like Nicholas suggested. This will have a (very small) impact on performance in CONFIG_SCHED_DEBUG case, but when debugging, performance is no problem anyways. > WTH does clang complain about a constant? Can't you just disable that > stupid warning? There are 2 ways to disable the warning. Either disable it for this particular occurrence, which clutters the code with #pragma's. THIS is really ugly. Or disable it globally and maybe miss some important/helpful warnings. > Also, if sysctl_sched_features is a constant, the both expressions > _should_ really result in a constant and clang should still warn about > it. No, because clang only warns if the constant is neither 1 nor 0. (These being the 'best' integer representations of booleans) > I'm really not seeing why we'd want to do this. Just fix clang to not be > stupid. >