From patchwork Mon Jul 29 12:11:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11063731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18E8E13AC for ; Mon, 29 Jul 2019 12:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07CD025E13 for ; Mon, 29 Jul 2019 12:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F017E26D05; Mon, 29 Jul 2019 12:14:06 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3948122ADC for ; Mon, 29 Jul 2019 12:14:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hs4Vi-0006dZ-2w; Mon, 29 Jul 2019 12:12:14 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hs4Vh-0006cg-1W for xen-devel@lists.xenproject.org; Mon, 29 Jul 2019 12:12:13 +0000 X-Inumbo-ID: 17b824e4-b1fa-11e9-8980-bc764e045a96 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 17b824e4-b1fa-11e9-8980-bc764e045a96; Mon, 29 Jul 2019 12:12:10 +0000 (UTC) Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: rXCzYAjwYizDDTkz6FnzAG/UCfIsAm3iRY9iWj+g0iXQnTkp2dtZoQ5PGxZqpxYbdH1yOjpQNN 8zw/JT1wErd+RpwZbkspNiXdf7JArMzEhlwUwsTg7onpzfAGHXEIhNkNR+YLqz4x2robemVN0e ZjXt0fC55KAHI0wKjUFnLh3phmP2IKmuyJ7wuvDrtOZJ+T8P9JR7FNb5IKeO0n3h2s6Ekwx2z3 3hsvhe6hQmk8cNYvMhBrzhYBYGBU1YCkX+akSKP/DCB547cm8WzgDsC1JYG8aE4lG+wAcPq7+W g20= X-SBRS: 2.7 X-MesageID: 3672663 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,322,1559534400"; d="scan'208";a="3672663" From: Andrew Cooper To: Xen-devel Date: Mon, 29 Jul 2019 13:11:56 +0100 Message-ID: <20190729121204.13559-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190729121204.13559-1-andrew.cooper3@citrix.com> References: <20190729121204.13559-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 02/10] xen/bitmap: Drop {bitmap, cpumask, nodes}_shift_{left, right}() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , Volodymyr Babchuk , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP These operations have never been used in Xen since their introduction, and it doesn't seem likely that they will in the future. Bloat-o-meter reports that they aren't the smalled when compiled, either. add/remove: 0/2 grow/shrink: 0/0 up/down: 0/-814 (-814) Function old new delta __bitmap_shift_left 366 - -366 __bitmap_shift_right 448 - -448 Total: Before=3323730, After=3322916, chg -0.02% Suggested-by: Jan Beulich Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk v3: * New --- xen/common/bitmap.c | 88 ---------------------------------------------- xen/include/xen/bitmap.h | 22 ------------ xen/include/xen/cpumask.h | 15 -------- xen/include/xen/nodemask.h | 19 ---------- 4 files changed, 144 deletions(-) diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c index 34de387880..fd070bee97 100644 --- a/xen/common/bitmap.c +++ b/xen/common/bitmap.c @@ -109,94 +109,6 @@ void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits) } EXPORT_SYMBOL(__bitmap_complement); -/* - * __bitmap_shift_right - logical right shift of the bits in a bitmap - * @dst - destination bitmap - * @src - source bitmap - * @nbits - shift by this many bits - * @bits - bitmap size, in bits - * - * Shifting right (dividing) means moving bits in the MS -> LS bit - * direction. Zeros are fed into the vacated MS positions and the - * LS bits shifted off the bottom are lost. - */ -void __bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int shift, int bits) -{ - int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG; - int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; - unsigned long mask = (1UL << left) - 1; - for (k = 0; off + k < lim; ++k) { - unsigned long upper, lower; - - /* - * If shift is not word aligned, take lower rem bits of - * word above and make them the top rem bits of result. - */ - if (!rem || off + k + 1 >= lim) - upper = 0; - else { - upper = src[off + k + 1]; - if (off + k + 1 == lim - 1 && left) - upper &= mask; - } - lower = src[off + k]; - if (left && off + k == lim - 1) - lower &= mask; - dst[k] = rem - ? (upper << (BITS_PER_LONG - rem)) | (lower >> rem) - : lower; - if (left && k == lim - 1) - dst[k] &= mask; - } - if (off) - memset(&dst[lim - off], 0, off*sizeof(unsigned long)); -} -EXPORT_SYMBOL(__bitmap_shift_right); - - -/* - * __bitmap_shift_left - logical left shift of the bits in a bitmap - * @dst - destination bitmap - * @src - source bitmap - * @nbits - shift by this many bits - * @bits - bitmap size, in bits - * - * Shifting left (multiplying) means moving bits in the LS -> MS - * direction. Zeros are fed into the vacated LS bit positions - * and those MS bits shifted off the top are lost. - */ - -void __bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int shift, int bits) -{ - int k, lim = BITS_TO_LONGS(bits), left = bits % BITS_PER_LONG; - int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; - for (k = lim - off - 1; k >= 0; --k) { - unsigned long upper, lower; - - /* - * If shift is not word aligned, take upper rem bits of - * word below and make them the bottom rem bits of result. - */ - if (rem && k > 0) - lower = src[k - 1]; - else - lower = 0; - upper = src[k]; - if (left && k == lim - 1) - upper &= (1UL << left) - 1; - dst[k + off] = rem ? (lower >> (BITS_PER_LONG - rem)) - | (upper << rem) - : upper; - if (left && k + off == lim - 1) - dst[k + off] &= (1UL << left) - 1; - } - if (off) - memset(dst, 0, off*sizeof(unsigned long)); -} -EXPORT_SYMBOL(__bitmap_shift_left); - void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits) { diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h index 0430c1ce2a..4e1e690af1 100644 --- a/xen/include/xen/bitmap.h +++ b/xen/include/xen/bitmap.h @@ -38,8 +38,6 @@ * bitmap_empty(src, nbits) Are all bits zero in *src? * bitmap_full(src, nbits) Are all bits set in *src? * bitmap_weight(src, nbits) Hamming Weight: number set bits - * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n - * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n */ /* @@ -74,10 +72,6 @@ extern int __bitmap_equal(const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); extern void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits); -extern void __bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int shift, int bits); -extern void __bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int shift, int bits); extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, const unsigned long *bitmap2, int bits); extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, @@ -233,22 +227,6 @@ static inline int bitmap_weight(const unsigned long *src, int nbits) return __bitmap_weight(src, nbits); } -static inline void bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int n, int nbits) -{ - bitmap_switch(nbits,, - *dst = *src >> n, - __bitmap_shift_right(dst, src, n, nbits)); -} - -static inline void bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int n, int nbits) -{ - bitmap_switch(nbits,, - *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits), - __bitmap_shift_left(dst, src, n, nbits)); -} - #undef bitmap_switch #undef bitmap_bytes diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h index 1d73f9f3b6..6be9567e9e 100644 --- a/xen/include/xen/cpumask.h +++ b/xen/include/xen/cpumask.h @@ -31,9 +31,6 @@ * int cpumask_full(mask) Is mask full (all bits sets)? * int cpumask_weight(mask) Hamming weigh - number of set bits * - * void cpumask_shift_right(dst, src, n) Shift right - * void cpumask_shift_left(dst, src, n) Shift left - * * int cpumask_first(mask) Number lowest set bit, or NR_CPUS * int cpumask_next(cpu, mask) Next cpu past 'cpu', or NR_CPUS * int cpumask_last(mask) Number highest set bit, or NR_CPUS @@ -213,18 +210,6 @@ static inline void cpumask_copy(cpumask_t *dstp, const cpumask_t *srcp) bitmap_copy(dstp->bits, srcp->bits, nr_cpumask_bits); } -static inline void cpumask_shift_right(cpumask_t *dstp, - const cpumask_t *srcp, int n) -{ - bitmap_shift_right(dstp->bits, srcp->bits, n, nr_cpumask_bits); -} - -static inline void cpumask_shift_left(cpumask_t *dstp, - const cpumask_t *srcp, int n) -{ - bitmap_shift_left(dstp->bits, srcp->bits, n, nr_cpumask_bits); -} - static inline int cpumask_first(const cpumask_t *srcp) { return min_t(int, nr_cpu_ids, find_first_bit(srcp->bits, nr_cpu_ids)); diff --git a/xen/include/xen/nodemask.h b/xen/include/xen/nodemask.h index e287399352..5eebc2c5ee 100644 --- a/xen/include/xen/nodemask.h +++ b/xen/include/xen/nodemask.h @@ -30,9 +30,6 @@ * int nodes_full(mask) Is mask full (all bits sets)? * int nodes_weight(mask) Hamming weight - number of set bits * - * void nodes_shift_right(dst, src, n) Shift right - * void nodes_shift_left(dst, src, n) Shift left - * * int first_node(mask) Number lowest set bit, or MAX_NUMNODES * int next_node(node, mask) Next node past 'node', or MAX_NUMNODES * int last_node(mask) Number highest set bit, or MAX_NUMNODES @@ -189,22 +186,6 @@ static inline int __nodes_weight(const nodemask_t *srcp, int nbits) return bitmap_weight(srcp->bits, nbits); } -#define nodes_shift_right(dst, src, n) \ - __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES) -static inline void __nodes_shift_right(nodemask_t *dstp, - const nodemask_t *srcp, int n, int nbits) -{ - bitmap_shift_right(dstp->bits, srcp->bits, n, nbits); -} - -#define nodes_shift_left(dst, src, n) \ - __nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES) -static inline void __nodes_shift_left(nodemask_t *dstp, - const nodemask_t *srcp, int n, int nbits) -{ - bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); -} - /* FIXME: better would be to fix all architectures to never return > MAX_NUMNODES, then the silly min_ts could be dropped. */