Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp904134rwe; Wed, 24 Aug 2022 10:59:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Po2dLUf/qKF2I8xu8/29Ex76xruQ2HUPGQfOzvgnJbrDBTs3749fL7oMggbXfD6pxeHy3 X-Received: by 2002:a05:6402:14d5:b0:446:22b8:8da1 with SMTP id f21-20020a05640214d500b0044622b88da1mr186875edx.214.1661363995536; Wed, 24 Aug 2022 10:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661363995; cv=none; d=google.com; s=arc-20160816; b=oY/vWJrkYthExuR8lTbr0nSQjJfVzkBFr+uz0x85CljyvT8ms063hoIVefzloAreFf 9YFoINX+JQpP0/5KaBSHURJC4qRj5xWuw19aQj+Q6m9rLR6WRyIWNZdXFyNSIaEZMtGn o57gD0QxDVMuJQHzdt+VinAKacRup93pJv2+AaiPNTVYqC7D19IWM7duXMNUGqBtXJN1 kBjR6CafchDSfO+AcZ8OiPnx839pkLZhHnsiclIeQs6OM7pzKpxky3XD9YH3RFFrBtfm gDQPQlUaXjzrmTCt6ANgYa6fW4bwJPzgNFnyAnyI/SYRCpMOg7lIdWeOhq8D2AjzM3+/ Mn3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3majRtgK1WM50+kP58AFxmfVpFYPY7FKVRe4D0xTAv0=; b=GAdO+sQM8HwuHMbkQgHr6nJYW4gBdZ9vcCpiZDH3TCMk61pYhZZM4a+PZAqct4O9V/ P2P25HnD9pzdG3izixplCjPTpqoVALOB+GXJArN/gP6g0K6kTBrlpkH1+/j/7Mz0OL5S DwWQLpmG2ZjVqMJ+05H32WWFm0JRCIdr8BO8Gnh9Yo25i8+0NtDP01qq6n+8perwCd0Z dexOF18zAU6+npeuhAxgOJG5sPkkLhczEwA7Uy3Xepb42f0ozVQWTerE/1dJqHYy3lsD GjQmaPWFG27Dn+NPeimXPbvYw9JaKA8iQLfFZ2omanRCD3fIsnlxFPPUICo34O9iRdNB KFQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qxBMKiEQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt10-20020a170907728a00b007308200cc45si2400158ejc.35.2022.08.24.10.59.26; Wed, 24 Aug 2022 10:59:55 -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=@gmail.com header.s=20210112 header.b=qxBMKiEQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240333AbiHXRpu (ORCPT + 99 others); Wed, 24 Aug 2022 13:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240290AbiHXRpq (ORCPT ); Wed, 24 Aug 2022 13:45:46 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02AA181B15 for ; Wed, 24 Aug 2022 10:45:39 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id c9so12117045qkk.6 for ; Wed, 24 Aug 2022 10:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=3majRtgK1WM50+kP58AFxmfVpFYPY7FKVRe4D0xTAv0=; b=qxBMKiEQGuZvs5Dq43ToYAMt54TMF7Yxv4BNjtRFc9vAvinTZMAwC8bUtp+Lf7j2YI iTlHFUivMbvLhrl8nn2eckkR5yXTOO5gqNA3sq4n+dPxNow71aRHFxezX9H4G02VwG2x x7U0HiQ6NymmNAg9Eu4TBMhEp8dpj+CxRTAXBA6f0GlIQq/loErqqrqTR3K50zwZBUVM krvoWho2zym5qCH3tPnnCM2Pr1mMiph9qPS9LelomKaU1rOahdD5DzJznFwFrjcFLG6j yGiRmjyiLyTk6YIdTnvxeCxD775yZ94eKFe4aNi3OHgpCcp8hg/a7003HUAmBb9hSKL7 QOdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=3majRtgK1WM50+kP58AFxmfVpFYPY7FKVRe4D0xTAv0=; b=6jGu2UxKCBHJRM+vlxGf9h4JP3QRB9aj57oDoxgao3Hq5sb5VDVuoULIx1E/EZmcWv thI2on6+5iv7JbrCY1+Zjin4BWKNyivtkfYMOrzVzQKR57bA4UmOzKOpQY3DQnvJraWb fmBp/17Ke34+7ZAo3JxZjfHSpEpSd43uJ49Y2eeEDBEv1p+Msh3hT35tsybFPKoEtdGO tRCv0y0UTorDvYQQgmYpDFbVhILGq0RLNjR25E97ldwp3o7YpPwZ9NGcRT3Dzd9Hfy34 Eykfoq+yBWQoOk+bXTSeOmXHQINWE21HPyydxoO9OEg54m26yJsiPGvJAt2/pfPFUGIG zAIQ== X-Gm-Message-State: ACgBeo1GV4qy8YU1lmo3EbxqaG2GPfcKRdhIZIany+B0x6fJ51yYaxPC LsqU82lXHLdvWSCaN616dRTMTTEHTrljrtWozPQ= X-Received: by 2002:ae9:e311:0:b0:6ba:e711:fb27 with SMTP id v17-20020ae9e311000000b006bae711fb27mr305631qkf.320.1661363137961; Wed, 24 Aug 2022 10:45:37 -0700 (PDT) MIME-Version: 1.0 References: <20220824012624.2826445-1-yury.norov@gmail.com> <20220824012624.2826445-2-yury.norov@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Wed, 24 Aug 2022 20:45:01 +0300 Message-ID: Subject: Re: [PATCH v2 1/3] lib/find_bit: introduce FIND_FIRST_BIT() macro To: Yury Norov Cc: Linus Torvalds , Linux Kernel Mailing List , Guenter Roeck , Dennis Zhou , Russell King , Catalin Marinas , Andy Shevchenko , Rasmus Villemoes , Alexey Klimov , Kees Cook , Andy Whitcroft Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Wed, Aug 24, 2022 at 4:19 PM Yury Norov wrote: > On Wed, Aug 24, 2022 at 12:10:02PM +0300, Andy Shevchenko wrote: > > On Wed, Aug 24, 2022 at 4:51 AM Yury Norov wrote: ... > > > +#define FIND_FIRST_BIT(EXPRESSION, size) \ > > > +({ \ > > > + unsigned long idx, val, sz = (size); \ > > > + \ > > > + for (idx = 0; idx * BITS_PER_LONG < sz; idx++) { \ > > > > I think we can do slightly better: > > > > for (unsigned long idx = 0; idx < sz; idx += BITS_PER_LONG) { > > unsigned long val; > > This will blow up the EXPRESSION. We can mitigate it on user side: I'm not sure I understand how EXPRESSION is involved in all this. What I proposed is to replace the for-loop one-by-one to one-by-BITS_PER_LONG. But okay, I have re-read the above patch and now I see what you are doing, basically you use internal variables of the macro in the EXPRESSION. Hmm... -- With Best Regards, Andy Shevchenko