Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp258245imw; Fri, 8 Jul 2022 02:23:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJ0CdKn2aaXibvj6EBV8xClc12yFRCF7j9pJEJEQsnOzTi61ziKM8S5swYsibDrobSY+Vr X-Received: by 2002:a17:90b:1c12:b0:1ef:9067:ed4a with SMTP id oc18-20020a17090b1c1200b001ef9067ed4amr10998156pjb.90.1657272185094; Fri, 08 Jul 2022 02:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657272185; cv=none; d=google.com; s=arc-20160816; b=aQIMI9b77jTgtvT+Jh21aOaSzIbWl52Afl3GFtiLteVr8tEbucEqB2apOgXZ7r09HK ktHosWEWMG20SutYTAEhcI+B0OVBeP6Uax4w+AOnEpqIodOtq4FJXKkLmyQzutfZEaLq Q4LxMwlnCxFoyVX7ZlUWmqFiOEbNxi2RL1ISOukk1jW165kNzH3MVFClZJB+P38xetU6 up5wwSd+GqFDrh5PkMIJwRJ3P1bHLRAtjMIhQT34JFw2yY0z0h3mQju6OrxNYUp1Gt49 sXuq+joFIkpeU+buJrrUHU9A9rHYKAnTq38kVq1Jq4z+lV3VufWGtd9ImwKg9ClHVBz9 G4Cg== 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=t15woDQAKcLwTx4KSzr1H1UOGudxvBL6EDZDZBycJuo=; b=VsyoLb90AQYF8jJjTSKSWXmD44fTnZdhoYgSVVrHIbiHqwC4Mf5K2gjwfq1oi/IIoy /O+dpKHnymJmPNC65HVp+YZAqLcDLJ/DkdZdEu23+RvZujUGQAaAjo+uAQ7067qhnDwP Ong7kSIUTvuhta9tkwx8WKsPgolteA8DR9JrvqVB68rOqWAc+1kWFRk4fWzhuNxID+vT vBKtHKg1vxkR8KBe0HLYPYTJcE1ZvBnDo5p72UVjgbwsn7QRT7RohgLaOqfANDICqRBX QqnsxpAeEC5N1rl/D5cqvYOe8e7eiyuPtJfnRQToq5MbRDMp6pLmMgcv+cwv0DnBSRzQ /ssA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="IFqYXn/Q"; 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 a184-20020a6390c1000000b00414ec29c59esi4613066pge.426.2022.07.08.02.22.50; Fri, 08 Jul 2022 02:23:05 -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="IFqYXn/Q"; 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 S237381AbiGHJNR (ORCPT + 99 others); Fri, 8 Jul 2022 05:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236587AbiGHJNP (ORCPT ); Fri, 8 Jul 2022 05:13:15 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BACE255A6 for ; Fri, 8 Jul 2022 02:13:14 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id e69so30261010ybh.2 for ; Fri, 08 Jul 2022 02:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=t15woDQAKcLwTx4KSzr1H1UOGudxvBL6EDZDZBycJuo=; b=IFqYXn/QYAIeCOOZhukGgGtSiZtEQuOAXDtCdI81/WdiBbHokVGMy2W0YQ74nPISpl dDbbkZDodL5tCEFadouqwKtiGNWaAnXO/I7x4vOIKkDTil1CGYMgft78nJgEPtNLHCN7 zNutOamYTU8snjH7UWD+vh1xmOhvHZo2/HHu/u1f+ymBEXdJ65RsXjA2uUlC9E1C21Dc gBwuQRZs2i/UdSBhI13OF2OdaResD3sdwEahDzvbt1ppyEO93sAC5oHpKcTSZijFVksu 1WxhBD+YYLLMJTjAoj8mvno4O/iMVfAsku3pusIZ62riq+jYxDDXVTXpVTaCiJrCY5CO Hsdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t15woDQAKcLwTx4KSzr1H1UOGudxvBL6EDZDZBycJuo=; b=5dlzNU/s/GjvV8UJ0PO+EsxHmnSKLu4YGZfIbAoTwylFEomPvlq9wdLrKy0FwZJRLb edyE4C1KDX0ytDPJ9lZbVOgfeSlQP/X3LSdICfJe2PLnprTkK4cVEVjuZber1kN+RhX/ MWuSJGaN2W0NMgnOlqRLHwo8Rxh3VWZiPwt88p6duksltz7FCIX7Quh0xVSwUJdGgr9M iI/VzKGe2RfGLmaEGy00gBdXB2ocM2Vz3ICHsYVBpHo06oe2upFPA1wR17ddwuOjQnWK nYSSZeBFclmemV/xS8rMiUI5/FSGUsZgM1ZOKPfgzk144tgb1/2VfAK6M4JG/HMTv/i/ y5+Q== X-Gm-Message-State: AJIora/L9iZegxEJghlOqJrwAJt4VyKMVG8GPoih+CwmWO7B36xXutO7 d0ngprWXxPWhkHAG3PZpQUyCf22sLU/vXJO6WWI= X-Received: by 2002:a25:858e:0:b0:66e:4898:63e2 with SMTP id x14-20020a25858e000000b0066e489863e2mr2610749ybk.296.1657271593413; Fri, 08 Jul 2022 02:13:13 -0700 (PDT) MIME-Version: 1.0 References: <20220706182300.70862-1-yury.norov@gmail.com> <20220706182300.70862-2-yury.norov@gmail.com> <423c4368-0a1c-792c-2637-768532fc7782@rasmusvillemoes.dk> In-Reply-To: From: Andy Shevchenko Date: Fri, 8 Jul 2022 11:12:36 +0200 Message-ID: Subject: Re: [PATCH 1/5] lib: add find_nth(,and,andnot)_bit() To: Rasmus Villemoes Cc: Yury Norov , Linux Kernel Mailing List , Alexander Lobakin , Andy Shevchenko , Arnd Bergmann , David Gow , Eric Dumazet , Isabella Basso , Kees Cook , Keith Busch , Kumar Kartikeya Dwivedi , Marco Elver , Mark Rutland , Steven Rostedt , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= 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 Fri, Jul 8, 2022 at 10:55 AM Rasmus Villemoes wrote: > On 07/07/2022 23.03, Yury Norov wrote: > > >> And I don't > >> like that the index is apparently 1-based (and that surprising API isn't > >> spelled out anywhere). > > > > Yeah... My motivation to start counting from 1 is to keep consistency > > with ffs: __ffs(word) <=> fns(word, 1). > > I understand that you're translating that second f in ffs (find First > set) to a 1. But I disagree that that's necessarily a logical thing to > do. Everybody understands that (given a C or python or... context) when > some prose talks about "the first element in an array", it's the one at > [0]. So I find it much more natural that the set bits in a word are > enumerated 0, 1, ..., popcount(w)-1. I agree that here we operate with an array of bits, which naturally starts from bit 0. -- With Best Regards, Andy Shevchenko