Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp16131rwe; Wed, 24 Aug 2022 15:57:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR6IK1fn3Qqhn3ZZVOdx4Skfn2/z+UdNLu103IBMs9/wP67YWL37mxAOOHWBK6e9fHqg0yoB X-Received: by 2002:a17:907:97cd:b0:731:5d0:4434 with SMTP id js13-20020a17090797cd00b0073105d04434mr645245ejc.603.1661381830351; Wed, 24 Aug 2022 15:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661381830; cv=none; d=google.com; s=arc-20160816; b=FB52Jkdc0S1t1cC2M/8SyHxnvD7Er1yPWAJmzLc+EkISidleD+Zyt4wsLCdlOX+ZCh Xa8OuHCZcb54holw5HD0x9uEkzfBfC/mkELw1tLAVgk4LBUew7V9rZ2hTuEDIlFlQ41m qFfR0o4H5dxmZhfiM2NTWFvl7U/IqOEGscI+cqpReVZ1+41rJRyP0laM2q7eZZe2tCYd fXrR9ZK4csTZc8TcadTtlK24c+74s6bMEq6IjEfgzjEIW47OZqectiPmwFF9/IB5cns2 XHpuksYwBasTL407sFrLhhCBs57lNjMPO1wxPuRXJMAP/oLSRPLTQCg8WNeeiytDngI0 SKVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fQnzJIEDcaaaAEZ4bKB8WpKO4pGwq6tvX+PHOcNDifc=; b=r1nkgbDtOilvblzsv/qo1zYX92VHEJvvYMRFZWj6WYE0lFoMxnw1bGauMQ1z3KVlGF 73zmIj1xyauKHXUtkoKlG7xMgrAVs6onhI21N2QwZGWrZIIWNo2jbKUFbJfCO+GLLrQL hKg2PcxnajE5fRkIiPYTGgRv4FVoR0gux/0Jxtywo8ztFEhHG8+Cu4R/kmEG6QTsTkEw MzXZOHrjXPVuevfEr0RbPjEWI+YpQqqo8od6oAIIH4kRsiiHG1xY2gyW9rXfAp+ohnnO B8Duv8jt5QpbxlCxJCIIj3eOfaISJD9lNS2zw2VDfM9frV/yU1r/sxkP6PaqtKMxUmDG J3GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S6XK5qBa; 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 ha4-20020a170906a88400b0073c100331cbsi2482867ejb.384.2022.08.24.15.56.45; Wed, 24 Aug 2022 15:57:10 -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=S6XK5qBa; 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 S232007AbiHXWLu (ORCPT + 99 others); Wed, 24 Aug 2022 18:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbiHXWLs (ORCPT ); Wed, 24 Aug 2022 18:11:48 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37FC77CB61 for ; Wed, 24 Aug 2022 15:11:48 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id u3-20020a4ab5c3000000b0044b125e5d9eso2327322ooo.12 for ; Wed, 24 Aug 2022 15:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=fQnzJIEDcaaaAEZ4bKB8WpKO4pGwq6tvX+PHOcNDifc=; b=S6XK5qBaPzXK+yQlGtkLHV2f3omv6DmzUi5hJvo06Usv0rieEgwAalzLA8je3zA7ge PcrNsgBwROGm5JyPMqmTWcIQnm+01mcYqHYCUZCeO2iOOYSspE5h4praNEbit/FVx8W0 hrM2dcbPkQxG4Qasa8Xx9uctrSpe26DwFYmdzbhwiL8uTwmN3zYVkxkT5tqZnwy5jkd3 IWHOafy518S8yOStVuZONgoFxwPIlWDLtF84+I7duCrsexl6io7iAcruti1i05CjChSm QRaRRXRlqNuVzDL4Ktb4HDKBZYqtqmmE0GLaD+HWMOWj6vswPMn7oJJDyMXQ+f3WhO49 eJUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=fQnzJIEDcaaaAEZ4bKB8WpKO4pGwq6tvX+PHOcNDifc=; b=A+eSMdQyGfkhDibuXidUdhdWWnbfbSxueIvjZO52nhZV8JIXMiukpKr/z+pnYPunyg WtA4ky/sEufNagPFxjb71z0dZZIdH4go3zoPOsaOYGBDMhHlbdENeqqRBtE9rLTBDJo8 fKjVFncyMSMXvEmheApHjgmscNzxP0JmmruEhiCIBM2uxTAyJGZS58pKIJ/L26GdiH/Z nPyj+90vFCMrDGZjzbwNg3JoqXSbWgxLtpyZ0Kvgk97hS49W+FZYfXENuUFcrkSxoBfA LB5Y/zxx8cBveXsRX428dxRMYaGgzG8eyA1D5old11cfv8L8njJdnXB2vGchg6hJppLr PM1Q== X-Gm-Message-State: ACgBeo0ki8wpRzPwibcC334E9jucjEphZ+XNP6taLXJthdk5EC8mYqJL eDPlYOZKaUVWWspCZtT9TDk= X-Received: by 2002:a4a:e6d2:0:b0:445:6fb:498a with SMTP id v18-20020a4ae6d2000000b0044506fb498amr340849oot.96.1661379107384; Wed, 24 Aug 2022 15:11:47 -0700 (PDT) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id w197-20020aca30ce000000b0034484c532c7sm4281344oiw.32.2022.08.24.15.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 15:11:46 -0700 (PDT) Date: Wed, 24 Aug 2022 15:09:35 -0700 From: Yury Norov To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Guenter Roeck , Dennis Zhou , Russell King , Catalin Marinas , Andy Shevchenko , Rasmus Villemoes , Alexey Klimov , Kees Cook , Andy Whitcroft Subject: Re: [PATCH v2 2/3] lib/find_bit: create find_first_zero_bit_le() Message-ID: References: <20220824012624.2826445-1-yury.norov@gmail.com> <20220824012624.2826445-3-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 > Just make the macro take that "last word op" as another argument, and > then you don't need these tricks, and you can do the _le() version in > lib/find.c file *exactly* like the regular version, using just > > #ifdef __BIG_ENDIAN > unsigned long find_first_zero_bit_le(const unsigned long *addr, > unsigned long size) > { return FIND_FIRST_BIT(~addr[idx], swab(val), size); } > #else > unsigned long find_first_zero_bit_le(const unsigned long *addr, > unsigned long size) __alias(find_first_zero_bit); > #endif > > or something like that. > > And yes, it means that the "regular" versions need to pass in just > "val" as a last-word expression, but who cares? It's still cleaner, > and easier to explain: "The first expression finds the word that > matches our requirement, the second expression munges the word we > found into the bit order we use". OK. I'll do like this: #define FIND_FIRST_BIT(FETCH, MUNG, size) ... unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) { return FIND_FIRST_BIT(~addr[idx], /* NOP */, size); } unsigned long find_first_zero_bit_le(const unsigned long *addr, unsigned long size) { return FIND_FIRST_BIT(~addr[idx], swab, size); } It doesn't actually look that worse. Thanks, Yury