Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp720086imw; Fri, 8 Jul 2022 10:26:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1usSH0rGF34px6fOwUFA2VXtj5+VlFe74NwRrCc/cuEwayqN1gPPxaCML95WtAp695FaWP8 X-Received: by 2002:a65:430a:0:b0:412:1877:7def with SMTP id j10-20020a65430a000000b0041218777defmr4279603pgq.93.1657301166349; Fri, 08 Jul 2022 10:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657301166; cv=none; d=google.com; s=arc-20160816; b=A6XGLg+zf7+JLRe8yenP3jORM1BvAGuQOlfH7XT2sY8dtFM0m0LBUXfpWHWqku40lC b6dGkfmR8huwfHtkH/2akucydP+SbHi2JLrCxdnnr6Rd+gT17QwHFjm9oNE/klN6UO0D wW7ruygXgZ2zCe37MvsEgU+OCh4+T5B6Dl4PGQ8l3SBi6SljGtycArEUnsSL6ywBvMTP Uh+0Tiv5vN4SMF4oCoPoQNxAFHBH2XxfcD368gWtB6u/FmaUw4oztaWFVF8R25/srAKH /xDrHFq0MYhsuBsyHa8EuVN/nUmv/WE5+Njj/qgTtWzi56LLUpDGVrW+WZQAu05ZRkN0 4abw== 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=4OKQC1JfennXMYbCH8QLvSZ9ug8KCsBnDh54Yf6DjVM=; b=UnZteJ9VMyqO0sDlOFPYsvW9Su5fTUdm5LNjNrnsxhQe1Cyo7bYux2jbJp/GIh73Wl PU5Vnlxn2X9SapIKWoPczZisoIkN1W/MfctdAmQ3Ke+MfB8A1iL2dKFCXxfgZACyPkKu zj3IjnQqb21XdYDV8068jmHTMJzdgQpj4oOG5+g/GvF75naAjw/UxwhDR9OYugV/U22D rq2YebQXNgYVyub8nry7q89PmytbbS1Al5RBMUUihGlnxSvgyaVUd+Ohfch5fAIaYb6/ dRnDnpFv5ZGaqUJBl2lLYK2K8MNJNGGGrYnz1PBWKE6tB3ySDJccBCwS8E5SN3MhPYRs hYVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JNrhC24t; 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 c4-20020a170903234400b0016becaaa23csi20091342plh.434.2022.07.08.10.25.52; Fri, 08 Jul 2022 10:26:06 -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=JNrhC24t; 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 S238544AbiGHQlC (ORCPT + 99 others); Fri, 8 Jul 2022 12:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238408AbiGHQlA (ORCPT ); Fri, 8 Jul 2022 12:41:00 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086062A711 for ; Fri, 8 Jul 2022 09:40:59 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id 185so10630115vse.6 for ; Fri, 08 Jul 2022 09:40:59 -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=4OKQC1JfennXMYbCH8QLvSZ9ug8KCsBnDh54Yf6DjVM=; b=JNrhC24tPcjj2Z6XWK9r9nRSuWELe3mhvLRc0RbRppcAtR4JfNGs/V0I8QkDuGWQ9k aoDmdcO41Hxkve2tq7gX6+VEpZzyXv8GlgDSjSPqVUx/iVAaAuS7b74ClQ9Erre1UDFw J0r97wURkzpgiR/9UxMBFTVtyGxTFrGirQnc2ja98n5g0Y01cgz0XnQL7DYJyPGXL/nV aW5D0NkVD5413ncIxapey+9mKOyPqwsc3yV+2L2mLsIfSM/dUFuvXx8G3bCgnzupdLc/ nUS1j+VDbMhbYQeB7qDv02EDxQB2WijfDlTmnrO1jpGvgfAU68bseH37rrCRAlfRfpv3 W3Xg== 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=4OKQC1JfennXMYbCH8QLvSZ9ug8KCsBnDh54Yf6DjVM=; b=mcO+Pwp/0TZ2winVXUn9VcMsfeqUSYdTgtdkECYXWAu+OBEent9FvBMEJZ8Z0PwdQH Bv2VS7gcSanzpsKIyQLyrxyChOlYoya4O889Txyjn74SD0Y8m4DTqLd+KAFVi0zlFqgY mgXyom5PFMLJkOLInlRX0tOkKOtYAIl96EvbbdwRjM2jx+XqFPv73CNNbK/EhDVoDKGe BOLB8Esdtxj6Xo/YrH2MW5mpl9B13A3v58WauwWjYhb5B2arHRSbuUt2UNsDMxcRmd8Q wBm4tdoYzYnRGXy7F9tEiZBWAm65VJm/J4jRAY9gH3ZR0fVqpC+XiQhhFHCIOL96XuIZ d8xw== X-Gm-Message-State: AJIora8NS0bDEM02ukvn4klAnOElrWJV+bmIRkjRbwEQbiwDLj6NIofx uv/nd9Hsiuc4hhYF1Q2kh/708H9dWeztlekABf8= X-Received: by 2002:a05:6102:3d9e:b0:357:4526:ae58 with SMTP id h30-20020a0561023d9e00b003574526ae58mr221179vsv.56.1657298458927; Fri, 08 Jul 2022 09:40:58 -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: Yury Norov Date: Fri, 8 Jul 2022 09:40:48 -0700 Message-ID: Subject: Re: [PATCH 1/5] lib: add find_nth(,and,andnot)_bit() To: Andy Shevchenko Cc: Rasmus Villemoes , 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 2:13 AM Andy Shevchenko wrote: > > 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. OK, I'll send v2 shortly