From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 248EDC433EF for ; Tue, 5 Oct 2021 07:13:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D012A61409 for ; Tue, 5 Oct 2021 07:13:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D012A61409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A9416E2F2; Tue, 5 Oct 2021 07:13:46 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id A91B56E2EF; Tue, 5 Oct 2021 07:13:44 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10127"; a="223087210" X-IronPort-AV: E=Sophos;i="5.85,348,1624345200"; d="scan'208";a="223087210" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2021 00:13:44 -0700 X-IronPort-AV: E=Sophos;i="5.85,348,1624345200"; d="scan'208";a="713967759" Received: from jstleger-mobl1.amr.corp.intel.com (HELO ldmartin-desk2) ([10.209.157.147]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2021 00:13:43 -0700 Date: Tue, 5 Oct 2021 00:13:43 -0700 From: Lucas De Marchi To: Dan Carpenter Cc: Jani Nikula , Chris Wilson , dri-devel@lists.freedesktop.org, Masahiro Yamada , Steven Price , Andrzej Hajda , intel-gfx@lists.freedesktop.org, "Sarvela, Tomi P" Subject: Re: [Intel-gfx] [PATCH] drm/i915: remove IS_ACTIVE Message-ID: <20211005071343.nufuh3fx3vnxrzro@ldmartin-desk2> X-Patchwork-Hint: comment References: <20211001074041.2076538-1-lucas.demarchi@intel.com> <163308055415.8412.14215483004176995847@build.alporthouse.com> <87bl49t6di.fsf@intel.com> <20211004205227.xpx67yawrs23gzr2@ldmartin-desk2> <20211005061939.GF2083@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20211005061939.GF2083@kadam> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, Oct 05, 2021 at 09:19:39AM +0300, Dan Carpenter wrote: >On Mon, Oct 04, 2021 at 01:52:27PM -0700, Lucas De Marchi wrote: >> Cc'ing Dan Carpenter >> >> On Fri, Oct 01, 2021 at 12:57:13PM +0300, Jani Nikula wrote: >> > On Fri, 01 Oct 2021, Chris Wilson wrote: >> > > Quoting Lucas De Marchi (2021-10-01 08:40:41) >> > > > When trying to bring IS_ACTIVE to linux/kconfig.h I thought it wouldn't >> > > > provide much value just encapsulating it in a boolean context. So I also >> > > > added the support for handling undefined macros as the IS_ENABLED() >> > > > counterpart. However the feedback received from Masahiro Yamada was that >> > > > it is too ugly, not providing much value. And just wrapping in a boolean >> > > > context is too dumb - we could simply open code it. >> > > > >> > > > As detailed in commit babaab2f4738 ("drm/i915: Encapsulate kconfig >> > > > constant values inside boolean predicates"), the IS_ACTIVE macro was >> > > > added to workaround a compilation warning. However after checking again >> > > > our current uses of IS_ACTIVE it turned out there is only >> > > > 1 case in which it would potentially trigger a warning. All the others >> > > > can simply use the shorter version, without wrapping it in any macro. >> > > > And even that single one didn't trigger any warning in gcc 10.3. >> > > > >> > > > So here I'm dialing all the way back to simply removing the macro. If it >> > > > triggers warnings in future we may change the few cases to check for > 0 >> > > > or != 0. Another possibility would be to use the great "not not >> > > > operator" for all positive checks, which would allow us to maintain >> > > > consistency. However let's try first the simplest form though, hopefully >> > > > we don't hit broken compilers spitting a warning: >> > > >> > > You didn't prevent the compilation warning this re-introduces. >> > > >> > > drivers/gpu/drm/i915/i915_config.c:11 i915_fence_context_timeout() warn: should this be a bitwise op? >> > > drivers/gpu/drm/i915/i915_request.c:1679 i915_request_wait() warn: should this be a bitwise op? >> > >> > Looks like that's a Smatch warning. The immediate fix would be to just >> > add the != 0 in the relevant places. But this is stuff that's just going >> > to get broken again unless we add Smatch to CI. Most people aren't >> > running it on a regular basis. > >I would really prefer that instead of ensuring that code doesn't >generate Smatch warnings, people just look over the warnings and then >mass mark them all as false positives and never look at them again. > >It let's us warn about more complicated things without worrying so much >about being perfect. When code is fresh in your head then warnings are >not a big deal to review and you want to warn about every possible issue >After a year then they take forever and so you really want them to be >correct or it's a huge waste of time. I'd prefer Smatch live in the >space where people run it when the code is fresh. > >You would have received some automated emails about this Smatch warning >but I look over the zero day output and filter the results. > >> >> clang gives a warning only in drivers/gpu/drm/i915/i915_config.c and the >> warning is gone if the condition swapped: >> >> - if (context && CONFIG_DRM_I915_FENCE_TIMEOUT) >> + if (CONFIG_DRM_I915_FENCE_TIMEOUT && context) > >I like this rule that when the constant is on the left it's not a mask. >That makes sense. I will add that. thanks, that would be great, so we can really get rid of the macro by sticking this rule since it works for smatch and clang (and gcc doesn't give this warning). thanks Lucas De Marchi > >> >> which would make sense if we think about shortcutting the if condition. >> However smatch still reports the warning and an additional one >> in drivers/gpu/drm/i915/i915_request.c. The ways I found to stop the >> false positives with smatch are: >> >> if (context && CONFIG_DRM_I915_FENCE_TIMEOUT != 0) >> or >> if (context && !!CONFIG_DRM_I915_FENCE_TIMEOUT) >> or >> if (context && CONFIG_DRM_I915_FENCE_TIMEOUT > 0) >> > >I guess I prefer the first and third but I'll add the rule that Clang >uses to silence the warning. > >regards, >dan carpenter >