Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6646732iob; Wed, 11 May 2022 02:10:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxb72P6R9Unwmru1pcumC4YuUdIPYAhn03YlB5cKF04qMinZGeZolyJQCCwvVGCYvOTLbNp X-Received: by 2002:a17:907:62a6:b0:6ef:8118:d3e2 with SMTP id nd38-20020a17090762a600b006ef8118d3e2mr23070297ejc.605.1652260205695; Wed, 11 May 2022 02:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652260205; cv=none; d=google.com; s=arc-20160816; b=uRSOR6JZA2fBCD9ynh7BT4TJfmhEf/n3b+GbyB7Zgxu0OBdSN5Rh7B7dfsdYZdFuIy xXuj0HnebGPCtONXtEF3pZAJqa59NLSVtnwIEbqKKT9Eo6lJkYlczRpcBGTcVql5aBe8 UNL9uCz59mNH36oXQkK2zW+c16wCHI72vf9uzaPOrcPrVYQlGsDselLn7yjtEsxJm4md gsH4DCeIJVaooJT4NHOARsPrP9AEQ7P7/UrzxtCYFX7krT43zyaqlqWPYInQgPKUAVM8 6ekRuKARDaJX80FFhohKotigDRV8CNCzF/vuTU4JJSiowid07rZhS5v1pUOdsboSaCOU nmHQ== 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=BtVYbChrQb9+TbAIbuoATF9Q1J0NgY2dl10/0GKd40Y=; b=oxFFGzDqPlB0zCsNjIZXN1RYv/YXYVxlnwOfosqQlZkB3+xJfXr4lqzjspto1hHlTh sde8BWn6mkW1nzfqSaydMl+ToJPwsJH3uZBusXGGoWO9SEfmQ45OQ1bnyTAfkymsh0GR NTmiCrhw7IjtDonmFo2ILtkmvudWqUuTP5FKGZQTFeXWC3BKd2LXmE9/3Mg6SSVGUvws P6a0H/GEnXIge2N0kCC4qD2ER1jWCQ0iGvIGkSUc0njfeE7glvbGzHw0NzftVH4JqwaQ 0Dzcmgjm9GLsP4cP2iECPlhG8SXqEEhl6SgYfO5I0Q+8Hgz7OyBKqFyAYz/9a/WpD+sj lAbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Eth5/BcD"; 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 e22-20020a17090658d600b006f405294f68si1743327ejs.61.2022.05.11.02.09.41; Wed, 11 May 2022 02:10: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="Eth5/BcD"; 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 S231723AbiEKEzl (ORCPT + 99 others); Wed, 11 May 2022 00:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbiEKEzh (ORCPT ); Wed, 11 May 2022 00:55:37 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3781D7A45E for ; Tue, 10 May 2022 21:55:36 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id n24so1384391oie.12 for ; Tue, 10 May 2022 21:55:36 -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=BtVYbChrQb9+TbAIbuoATF9Q1J0NgY2dl10/0GKd40Y=; b=Eth5/BcDhOsEjKlKqiQqgbB2THavdp8z3RyNtk5YZAEHxfd9cVU7iNxRneXMRjxQZt gEmtJASQ+JHR29IBv/kVR+yk9f4IPghCgmQ2YlgbuvwNHHNzW5B3e0lznhEam6bjpvR/ qh476h+Pf9YBu5zOMvhF0UjnTtc6O2LvJ55JQmtXpyMw2tbnpNqRO1BxPPWVgyPTCwI3 G2bd0CyyNXSOb2Z/VRocApl8C0gWZoXlvHkAx6eO7MIRMap+cZFOFeLPxs4mNpZfTrOB 8HbDHOPKfrJqyHPkpgc69cYLh/y+P6ZgU+3Y1HY+Q9I2uxXGPoGriuXIUlwxfcFYc1Yc 3CpQ== 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=BtVYbChrQb9+TbAIbuoATF9Q1J0NgY2dl10/0GKd40Y=; b=FbL8VyfcMMDPzZZbG7YKQbFr8s0GHkuhP8s0lw6XAIHjmrZaZlE5/S00DdIFyb6+uA Xvi92DnTPzcnNqPrUZKLNlvcGMHYPqeSMwbzDbR425MfPLzANatKnq2HOXNwPuWlQOUQ 8d9LrfIi3tbBIlJ7A48KbAXy4VBy4atyPo32OohxnAgOi0lWB8wH2L+oGnNZ3sB0jYM8 bW3BDJZHBhJJREdeWhrmKNFN2FEZTvUvplqd9QeACLCq8hvZbEgS6WW82qygX3xOb1M9 JjNIqH0x99fziR3vJoIYTGx+rVTKpbhKF45KCXbq+iW/Om5EcbqzLozYp50BXvYxBO27 1IBA== X-Gm-Message-State: AOAM532wct9/NMvfI6/8/VxeeolX//+Dz0w9tyfanSb6RTjoqFM9tJTd Et+bzLgQB3EnOJ1lQu8NG9oTE8yAQlRdtxacZ/4= X-Received: by 2002:a05:6808:1202:b0:2f9:c7b4:fd56 with SMTP id a2-20020a056808120200b002f9c7b4fd56mr1564634oil.55.1652244934349; Tue, 10 May 2022 21:55:34 -0700 (PDT) MIME-Version: 1.0 References: <20220510154750.212913-1-yury.norov@gmail.com> <20220510154750.212913-9-yury.norov@gmail.com> In-Reply-To: From: Max Filippov Date: Tue, 10 May 2022 21:55:23 -0700 Message-ID: Subject: Re: [PATCH 08/22] bitops: introduce MANY_BITS() macro To: Yury Norov Cc: Andy Shevchenko , David Laight , Greg Kroah-Hartman , Joe Perches , Julia Lawall , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Nicholas Piggin , Nicolas Palix , Peter Zijlstra , Rasmus Villemoes , Matti Vaittinen , LKML , Alexei Starovoitov , Andrew Morton , Chris Zankel , Christophe Leroy , "Eric W . Biederman" , Kumar Kartikeya Dwivedi , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , "open list:TENSILICA XTENSA PORT (xtensa)" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, May 10, 2022 at 12:16 PM Yury Norov wrote: > > Hi Max, > > On Tue, May 10, 2022 at 10:57:25AM -0700, Max Filippov wrote: > > Hi Yury, > > > > On Tue, May 10, 2022 at 8:48 AM Yury Norov wrote: > > > arch/xtensa/kernel/traps.c and include/linux/log2.h define very similar > > > functions with different behaviour. XTENSA defines IS_POW2(), and > > > log2.h defines is_power_of_2(). The difference is that IS_POW2() > > > considers 0 as power of 2, while is_power_of_2() - does not. > > > > IS_POW2 is constructed this way because we know that there is at least > > one non-zero bit in the value that it tests. > > > > > This discrepancy may confuse reader. From mathematical point of view, > > > 0 is not a power of 2. > > > > If it would reduce the confusion we can add a check that the value is > > non-zero in the IS_POW2 macro. > > > > I'd really like to not introduce the local macro and just use something > > standard, > > This patch introduces a macro MANY_BITS() in include/linux/bitops.h, which > is a full analogue of IS_POW2(). Would it work for you to switch to > MANY_BITS()? It would, I guess. It would also work if is_power_of_2 was a macro. -- Thanks. -- Max