From patchwork Sat Jul 7 00:30:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 10512629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C75AF600CA for ; Sat, 7 Jul 2018 00:31:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9B72287BD for ; Sat, 7 Jul 2018 00:31:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B6492883A; Sat, 7 Jul 2018 00:31:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 07B26287BD for ; Sat, 7 Jul 2018 00:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Mime-Version:References:In-Reply-To: Message-Id:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kW2sqE1Vth8pPB/UQmRFaAEYnhrPfkuLB+1oh1uw71g=; b=kNWHDvPkMqruTt I5ZEDFp99ecmoSgQPAngTo0D2RBrgRPBo1zLxZG2518QIyvOMo9RYcC1+6Wm/xpK3bK9amWa6QFLu ZqM84b2GBtaklqyA3gpghIX/qcbQzEUsgrNjRoWXw7JY0Z+E5vMZH/DRb8krWV/uQ1tZLBA8sl72F fYxaeG9eVU/HWh34/A/Q0hERC3XjSJvEyoohhV+pZbd9OZTd2fkNtaif75jcS6xExRipHH5MdhxR7 2uUTxp70p+Ifv5F30BBohtWZ9GtuxSKGZg7jmdgKuvyfBRgprBeQKhLBS1Z8Vj/9fxHmNIHvQt9z4 8+PrTvai/yVja8rZOT7A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbb7x-0001QX-Md; Sat, 07 Jul 2018 00:31:05 +0000 Received: from mail.linuxfoundation.org ([140.211.169.12]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbb7u-0001Q3-2W for linux-arm-kernel@lists.infradead.org; Sat, 07 Jul 2018 00:31:03 +0000 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 97839CE9; Sat, 7 Jul 2018 00:30:50 +0000 (UTC) Date: Fri, 6 Jul 2018 17:30:49 -0700 From: Andrew Morton To: Will Deacon Subject: Re: [RESEND PATCH v2 3/9] asm-generic: Move some macros from linux/bitops.h to a new bits.h file Message-Id: <20180706173049.e28171504c745934a280dee8@linux-foundation.org> In-Reply-To: <1529412794-17720-4-git-send-email-will.deacon@arm.com> References: <1529412794-17720-1-git-send-email-will.deacon@arm.com> <1529412794-17720-4-git-send-email-will.deacon@arm.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180706_173102_159189_F4F6BBF4 X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peterz@infradead.org, yamada.masahiro@socionext.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mingo@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 19 Jun 2018 13:53:08 +0100 Will Deacon wrote: > In preparation for implementing the asm-generic atomic bitops in terms > of atomic_long_*, we need to prevent asm/atomic.h implementations from > pulling in linux/bitops.h. A common reason for this include is for the > BITS_PER_BYTE definition, so move this and some other BIT() and masking > macros into a new header file, linux/bits.h > > --- a/include/linux/bitops.h > +++ b/include/linux/bitops.h > @@ -2,29 +2,9 @@ > #ifndef _LINUX_BITOPS_H > #define _LINUX_BITOPS_H > #include > +#include > > -#ifdef __KERNEL__ > -#define BIT(nr) (1UL << (nr)) > -#define BIT_ULL(nr) (1ULL << (nr)) > -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) > -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) > -#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) > -#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) > -#define BITS_PER_BYTE 8 > #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) > -#endif Why does it leave BITS_TO_LONGS() in place? That becomes unfortunate with Chris's patch, so I'm moving BITS_TO_LONGS() into bits.h. From: Chris Wilson Subject: include/linux/bitops.h: introduce BITS_PER_TYPE net_dim.h has a rather useful extension to BITS_PER_BYTE to compute the number of bits in a type (BITS_PER_BYTE * sizeof(T)), so promote the macro to bitops.h, alongside BITS_PER_BYTE, for wider usage. Link: http://lkml.kernel.org/r/20180706094458.14116-1-chris@chris-wilson.co.uk Signed-off-by: Chris Wilson Reviewed-by: Jani Nikula Cc: Randy Dunlap Cc: Andy Gospodarek Cc: David S. Miller Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Andrew Morton --- include/linux/bitops.h | 3 ++- include/linux/net_dim.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff -puN include/linux/bitops.h~bitops-introduce-bits_per_type include/linux/bitops.h --- a/include/linux/bitops.h~bitops-introduce-bits_per_type +++ a/include/linux/bitops.h @@ -11,7 +11,8 @@ #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) #define BITS_PER_BYTE 8 -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) #endif /* diff -puN include/linux/net_dim.h~bitops-introduce-bits_per_type include/linux/net_dim.h --- a/include/linux/net_dim.h~bitops-introduce-bits_per_type +++ a/include/linux/net_dim.h @@ -363,7 +363,6 @@ static inline void net_dim_sample(u16 ev } #define NET_DIM_NEVENTS 64 -#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) #define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1)) static inline void net_dim_calc_stats(struct net_dim_sample *start,