Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6408493iob; Tue, 10 May 2022 18:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw04AU/AzKCXO7SYb6UBvv9pBaiMCmnNmS5eVdTTq1w6CsdQOLVGG6UgyuEo/xRP4L9p0b1 X-Received: by 2002:a17:906:3101:b0:6d6:5b64:906f with SMTP id 1-20020a170906310100b006d65b64906fmr22041929ejx.513.1652232979041; Tue, 10 May 2022 18:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652232979; cv=none; d=google.com; s=arc-20160816; b=vs1ua2Jxe3+H97Pvue8pahGjumkG4f1NFvqj2tJ517cAjQkb0aA63Oswz7BEKs1JIR RkpjJ7xYYj/5SxntYZ0e6yZmDGAqRISou9zPauBJWzicLRBWGfIPLOUg0hZsFWCHdoa5 Tmt2J8mlKqsRzC5cWZmaQ2BtlLXtsXQpvBpNU3hgjyvgxIC5E//Bpnv7+bCEtJ5oaJnT Fin0JhkNxO2vY4QqtMNerwh3QND6AHaH9qJirBFc3+BME9aCQEksGyWl0LX4ksyOty7h /d3dSxo9yFdRaLektWX3hlGzHJ6m5i8KfG6s2j3BmrBAt+CS/SDHwEcvOgePATyVXat0 k06g== 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=KQbaG/uNayn0MvP5ZcG3kEKMtXIrQTLtyOWN/V1ZKEQ=; b=fEBQfkk8Y8yQ+xPmIO9Gi2hTQLQIkcFiL8t2e+z/HOmebGYICM1PYcOL+Y3BJ6yxf/ UQZsAbtUC/YV9Fiw4eT+JKmi4VgtL3Ilp6t7bpuFNKHj3Rb0C7+NdqK/30xAbtna0fb3 +e4Y2EgFBKZZxZwTgLlW+MMs5S+Phpinq3jt78ZkNr3bzpqg+0xUYXTjxGoRYIXx+4gT T4AmX/tfBB46zW9cvsRQigNyqBY7sRGMUGU7K275hv26CkyhStkH0HSrWmO5c0/hULMl IF51oV1Ol8ECyhsj3eso/B53ToKGUE3Fspv6hiinQR20JfCPPB6zf3qC8z1i25XKlg9R m7xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SmHRlvDV; 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 hv11-20020a17090760cb00b006e89058c9f5si1013361ejc.320.2022.05.10.18.35.45; Tue, 10 May 2022 18:36:18 -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=SmHRlvDV; 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 S236492AbiEJTRC (ORCPT + 99 others); Tue, 10 May 2022 15:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbiEJTRB (ORCPT ); Tue, 10 May 2022 15:17:01 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0E72608F3 for ; Tue, 10 May 2022 12:16:59 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id i5so33924ilv.0 for ; Tue, 10 May 2022 12:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KQbaG/uNayn0MvP5ZcG3kEKMtXIrQTLtyOWN/V1ZKEQ=; b=SmHRlvDV4tZDjXY+KbUw8jmDD9jgLhF6z8RTkYgz9M84hje9NC+xkoLeeOEcuYLURC uu0S7Ndi7zHqsHkchf/gkxav760GNAbm+XhMDbKlng6seeYjX7mE1kOvlOFKFb8FtThi j+/5hLVyOAqSW3Q3P72aUouuYBbQ+N0y8OAQIb8ydv+zGMcAIyByBd/PaPn7wO3PlHCz i1IF5t0uWlFclnXVGtbIQS1R/Qwwl+2U3XTcL6Raun81TKp3kw/PVxJ8Am7pVtQ/xQrB HgaaT+qPKH4IUIOr1vTTbf3k9jxVbryi9yc4zAlEG9Z0jwcYV+UVKhuMkjvnEQUi3S2x 4+UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KQbaG/uNayn0MvP5ZcG3kEKMtXIrQTLtyOWN/V1ZKEQ=; b=oyWIQplCQVKppJWHMbQ99q5LnFnoIaMcjWyohouzKzEK1GatN/8ROLDYLsEe1jdi+J ptFlWZP/NrMAMpTybCgmUhjLORhlpPL2QkpLn/901pK2dOt41aJnuMgQ7XhM8TMUqH36 pMxudAy2RbW3onV+hKMUA1mwP8CVZnOs+A6DwivSjMDk2V7iSgRNzOMFxEf3zIwNpgSx e6w6LrMrYGhEbOfp1lOYwZUmmusjzHD88jugIXYLzowaPCIyWe0VhRHFlYMjNxrxn+Cl 90etSeVp1zHHqgHVjXdtWW6MYPbKDz1ImqUirPb2x7A2yA4fNqY6PGAqjfXriqXjCoA+ oWrA== X-Gm-Message-State: AOAM5302KgBjes7qPfuGmGkZIgqL1kQb5to2mCYOdTqdMq6EG+wIKDMQ jsOAilW/eopMDetDt6ShGrg= X-Received: by 2002:a05:6e02:1e08:b0:2cf:1c31:15ec with SMTP id g8-20020a056e021e0800b002cf1c3115ecmr10607722ila.133.1652210218459; Tue, 10 May 2022 12:16:58 -0700 (PDT) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id o9-20020a92a809000000b002cdfeead6basm49951ilh.63.2022.05.10.12.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 12:16:57 -0700 (PDT) Date: Tue, 10 May 2022 12:16:55 -0700 From: Yury Norov To: Max Filippov 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 , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , "open list:TENSILICA XTENSA PORT (xtensa)" Subject: Re: [PATCH 08/22] bitops: introduce MANY_BITS() macro Message-ID: References: <20220510154750.212913-1-yury.norov@gmail.com> <20220510154750.212913-9-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 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()? > but I can't use is_power_of_2 in a preprocessor condition, can I? I believe you can't. Thanks, Yury