Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3809972rwb; Tue, 20 Sep 2022 05:12:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6cI+6Lpx8rpZV1+a7upADBxdbZNeFFfLfyw5k/k4yP2clYTj2z9G14y4RLqvJwpvAyVuoy X-Received: by 2002:a17:907:2c4b:b0:77e:2c09:4111 with SMTP id hf11-20020a1709072c4b00b0077e2c094111mr16940824ejc.21.1663675923369; Tue, 20 Sep 2022 05:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663675923; cv=none; d=google.com; s=arc-20160816; b=P64VBmmL10EoB8n/j6ZQs2qYWyv2oF9GGODFRRmo3AWtLhz8Ark20Iw1P5AyXf441q q5WQ6vTp86NIOrKClOLLBOhbopgYaBKo2LJ2Z1wR41FFKD0EKPkuGE59NfJ2KiH26d2r vP1lUmBGG8RdwJB8hpfXXVIABgnK0NKLmclZi2Z9y7VcMBEBh/ndx0ZUKuifCoItnh43 xqKhvANCaGEiU2YKYDPA3IG7oVciaTk2WCNUOHMZqA/M2b13l4++ngMptZUhKi0XwUAt f4pu0QOULvCoERwHiKGhG8I3uXV7wJTt2UmWijqn06l4wBjQAGDpNiqXj2n5uSHdSnAF LnEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=av+um2nxNFMsGCgykg1Bvh6CT9h0m6bfqZsAm4AFt8k=; b=BOIV11zi1zGelqQuhtZQF2YVckPCvedJv6LDTVefKpOux31w3rr2zyLk87V/OPcGw/ OZ8jppH8d07H3aR3U2vLcytOKSX6Z/cHEUVmNn2IVJo/ko3DT/ELNhefqfJWnouSEfWt qnUyqME5u/fnNFql9z/4hnCvH49RTr+SyhqOX7cSAdext5Sw0kbqkz3yBAF1uhYl4t1d ZndIY5cP8MMjujob12fV6MG4nxA3pamRSgjdyj27waq7w4az8JezJ7cbs7J3N2lWRpEk OElscUFBo8S+XoBR8pswmwlM++y+7HtzVeDAOFgmxjJAHj4+d7go6RlSkx+U8Rkecr28 C5FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eEMJ8Yvk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b0078185d33874si1227697ejc.304.2022.09.20.05.11.37; Tue, 20 Sep 2022 05:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eEMJ8Yvk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbiITMAe (ORCPT + 99 others); Tue, 20 Sep 2022 08:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbiITMAI (ORCPT ); Tue, 20 Sep 2022 08:00:08 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89C43C142 for ; Tue, 20 Sep 2022 05:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663675200; x=1695211200; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=6attfvJn2TlCroEf1Q0w21onYCW/hVVtQgXXXvv2Utc=; b=eEMJ8YvkoyY0/sQSHKuFYAOYY6YSjezpKqDy+ZpBnUTT6xg6NvEPGcXL 9y1fPyNW+JjcAtyenVT0GmG1ut/J9i6gh2yP43YNwTSEBuilTzYhUYNdb hJ6Cu0SN8UxDxSOdCBPqR2vGTMTAX9JfVZYE49aV+4UrBG13XkEXpfVys Nzh2LpnVboCjUQJ4Se+Q0iWdX/scohqIMBn4xu9MAFee7xFCXuWlaV2FV H0Ie49k8a7Gqot5ZzlvP6wpoh86RNF6Ny8iem9eQehvi7kIR9nnYkSKMQ JA8q+piXV/096JEmhDUz+d0bDoZA4J4zkHaTczbGNl+FLqIAgUiMJRyKo w==; X-IronPort-AV: E=McAfee;i="6500,9779,10475"; a="299663285" X-IronPort-AV: E=Sophos;i="5.93,330,1654585200"; d="scan'208";a="299663285" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2022 05:00:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,330,1654585200"; d="scan'208";a="618885283" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 20 Sep 2022 04:59:56 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oabur-004yhD-2z; Tue, 20 Sep 2022 14:59:53 +0300 Date: Tue, 20 Sep 2022 14:59:53 +0300 From: Andy Shevchenko To: Linus Torvalds Cc: Yury Norov , linux-kernel@vger.kernel.org, Alexey Klimov , Andy Whitcroft , Catalin Marinas , David Laight , Dennis Zhou , Guenter Roeck , Kees Cook , Rasmus Villemoes , Valentin Schneider , Sven Schnelle , Russell King Subject: Re: [PATCH v4 3/4] lib/find_bit: optimize find_next_bit() functions Message-ID: References: <20220915020730.852234-1-yury.norov@gmail.com> <20220915020730.852234-4-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 19, 2022 at 08:23:00AM -0700, Linus Torvalds wrote: > On Mon, Sep 19, 2022 at 6:46 AM Andy Shevchenko > wrote: > > > > > +#define FIND_NEXT_BIT(FETCH, MUNGE, size, start) \ > > > +({ \ > [..] > > > +out: \ > > > > I dunno if GCC expression limits the scope of goto labels > > No. Labels are function-global by default. If you need block-scope for > them, you need to declare them explicitly in tha block before use with > "__label__". > > > but on the safe side you can add a prefix to it, so it becomes: > > > > FIND_NEXT_BIT_out: > > That doesn't really help, since if you were to use the macro twice, > you'd still get a name clash. > > That said, I'm not convinced any of this matters, since these macros > aren't supposed to be used anywhere else, and in fact, they aren't > even in any header file that would allow anybody else to use them. > > So I think all the normal "make macros safe" rules are simply > irrelevant for these cases - despite the readable name, these macros > are local special cases for code generation and avoiding duplication, > not generic "use this macro to find a bit". > > So it's one thing if a macro is in a header file to be used by random > code. It's a different thing entirely if it's a specialized local > macro for a local issue, that nobody else is ever going to even see. > > So I don't think it would be wrong to use __label__ to block-scope it, > or to use a longer name, but I also don't think it's really required. > > It's not exactly super-common, but we have various cases of macros > that generate full (or partial) function bodies in various places, > where the macro does various things that should *never* be done in a > "regular" macro that gets used by normal code. > > You can see one class of this with something like > > git grep '^static.*##.*(.*\\$' -- '*.c' > > but to *really* go blind, see the "SYSCALL_DEFINE*()" macros in > . > > Those will mess with your mind, and go "whoever wrote those macros > needs to be institutionalized". They do some impressive things, > including creating local functions _and_ starting a new function > definition where the actual code then isn't part of the macro, but > actually just continues where the macro was used. > > Which is all very natural and actually looks quite nice and readable > in the places that use it, with users looking like > > SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) > { > int fd; > struct pid *p; > ... > > which is all pretty legible. But there's no question that that macro > violates every single "normal" macro rule. > > The FIND_NEXT_BIT() macro in comparison is pretty tame. Thanks for elaboration. It makes a lot of sense and something TIL material to me. -- With Best Regards, Andy Shevchenko