From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D686C433E6 for ; Mon, 1 Feb 2021 13:44:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6F6B64E7A for ; Mon, 1 Feb 2021 13:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231187AbhBANoW (ORCPT ); Mon, 1 Feb 2021 08:44:22 -0500 Received: from mga01.intel.com ([192.55.52.88]:27820 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbhBANoW (ORCPT ); Mon, 1 Feb 2021 08:44:22 -0500 IronPort-SDR: NzhAKCYhnQXi4XM/YUtH4pHJ+jygKZ/Eg9cKCW9tB8N3QjXczD+vw5qR+BeTYB068swyVbjcGf guKV2pK7B0Rw== X-IronPort-AV: E=McAfee;i="6000,8403,9881"; a="199578880" X-IronPort-AV: E=Sophos;i="5.79,392,1602572400"; d="scan'208";a="199578880" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 05:42:35 -0800 IronPort-SDR: AfFKvMAXe7FVmvGMevF7putl5zn4hCdP5hNEoGE0ehdmlm6i979xyhx1vCzn0j5RAjUyNY0Q0z RHxlfdNlD9MQ== X-IronPort-AV: E=Sophos;i="5.79,392,1602572400"; d="scan'208";a="358585103" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 05:42:30 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l6ZTG-0018vK-O7; Mon, 01 Feb 2021 15:42:26 +0200 Date: Mon, 1 Feb 2021 15:42:26 +0200 From: Andy Shevchenko To: Yury Norov Cc: linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, linux-arch@vger.kernel.org, Geert Uytterhoeven , Yoshinori Sato , Rich Felker , Arnd Bergmann , Dennis Zhou , Andrew Morton , Wolfram Sang , David Sterba , Stefano Brivio , "Ma, Jianpeng" , Wei Yang , Josh Poimboeuf , John Paul Adrian Glaubitz , Joe Perches Subject: Re: [PATCH 4/8] lib: introduce BITS_{FIRST,LAST} macro Message-ID: References: <20210130191719.7085-1-yury.norov@gmail.com> <20210130191719.7085-5-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210130191719.7085-5-yury.norov@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Sat, Jan 30, 2021 at 11:17:15AM -0800, Yury Norov wrote: > BITMAP_{LAST,FIRST}_WORD_MASK() in linux/bitmap.h duplicates the > functionality of GENMASK(). The scope of there macros is wider than just > bitmap. This patch defines 4 new macros: BITS_FIRST(), BITS_LAST(), > BITS_FIRST_MASK() and BITS_LAST_MASK() in linux/bits.h on top of GENMASK() > and replaces BITMAP_{LAST,FIRST}_WORD_MASK() to avoid duplication and > increases scope of the macros. ... > include/linux/bitmap.h | 27 ++++++++++++--------------- > include/linux/bits.h | 6 ++++++ > include/linux/cpumask.h | 8 ++++---- > include/linux/netdev_features.h | 2 +- > include/linux/nodemask.h | 2 +- > lib/bitmap.c | 26 +++++++++++++------------- > lib/find_bit.c | 4 ++-- > lib/genalloc.c | 8 ++++---- Answering to your reply. I meant to split the below to a separate patch. > tools/include/linux/bitmap.h | 20 ++++++-------------- > tools/include/linux/bits.h | 6 ++++++ > tools/lib/bitmap.c | 6 +++--- > tools/lib/find_bit.c | 2 +- > tools/testing/radix-tree/bitmap.c | 4 ++-- ... > +#define BITS_FIRST(nr) GENMASK((nr), 0) > +#define BITS_LAST(nr) GENMASK(BITS_PER_LONG - 1, (nr)) > + > +#define BITS_FIRST_MASK(nr) BITS_FIRST((nr) % BITS_PER_LONG) > +#define BITS_LAST_MASK(nr) BITS_LAST((nr) % BITS_PER_LONG) Any pointers to the difference in generated code for popular architectures (x86. x86_64, arm, aarch64, ppc, ppc64)? -- With Best Regards, Andy Shevchenko