From patchwork Wed Jul 6 17:42:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12908435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83864C43334 for ; Wed, 6 Jul 2022 17:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3R6Qjjkxla+Ws5rM4bmRT0VAvtiWWOewk9jPqTP+EAo=; b=hvL/2dzyjC7wkX ElrfPSx1UqfRlSvZSRzAt67ePaIIqG4ogT78/NWzoXmxF5O75Y3nFw0ubNjb6U9QsM5m3KJgk3SIe sLFJv0+s2hpWi8ixPXH+YIQ8mf8XhcAehjaFI4gkzfdHPDeY9RdAbTTgLHZFq6YjLA3wqvBXf94a0 zJoU5s6ae4YSErmgbeAmcky/Z22SEWJowaTUkXfYBukQjhyAexlcNqKmXkKI3UAIT55VX9No1XPHu G6YuksK2DI4CjVVYXBwQbQjS43ZXDbNfwMbwE8caGGl6SwWxYXiMLV4ddj0ZJTJeOyhFTCqiCYlUh BdrDlSwYJ+C9nNdJWGzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o994T-00BmS0-Ha; Wed, 06 Jul 2022 17:44:18 +0000 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o993H-00Bltd-Jc for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2022 17:43:08 +0000 Received: by mail-qt1-x82b.google.com with SMTP id r2so19256044qta.0 for ; Wed, 06 Jul 2022 10:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gmLdladheqxAWwfcqAo0zECfXUO+llLx3LkvFH+700E=; b=hiMIpOPvM1brHtsKUEsAondMOkcJYY374HhguLWQ/mAEG1sjeYPeDD2R7UVdBEc/zf WNJdA8d2mby20mGe9ATAS0dM/qKUmfTpeFW8kvcp+eKwY5yJHLgWZrj1WEeT1sYNnJSH t7DASNWe/NnxKSck20sRZygA/AiOhgsJEw79PuUdZi0tyYEDgJJVM922ZygtPiNU4B9d H/vRBKSp1Ba7Rk3fOv/Tfv3wZZitZ6g5qZdRo+wqTgSHl5sxGF9Ho+LZUz/XHRcwzkSR zWfaAru7HdMSZeT4W1kucwMQDvDyedeyI1ufccF/h6RmFGFHrH6/Siz8ZqdXuZRRkapw B++Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gmLdladheqxAWwfcqAo0zECfXUO+llLx3LkvFH+700E=; b=6WtRTCz5eJS4yBfOgZVzJentF/U8ZOP0FEeh7BgO7I8UpZdLA3Uyb0Wc1M0p7/o5E1 QoUcBRzkWVg01uQDLcxB+q2Smq6XUlyTjoJoxb4fcb6ajiKvHSjKIK36eNCr/LL1br5U BfeMdXcZs8dXgMQF6xOJ1k2ESdkHq1Byv99FMZVOLvFXpCvJW1M/EezeooI8DsoOoIDh 3sqpSh1kGjdod0+ATkPaVWWZSNolF60OH7Xz/+YdrvWqz2bgBGjfkVsMrJ5Jr24+w6at GEDNhRtX9uFfx0Vxw0l/a9X8PTKoQlgUrQa/el0me5nlH7NLP5rnlhyzSdhS7Om9nkUj kMlg== X-Gm-Message-State: AJIora9sY2jDiiHM0RgwYfYOIBngrU/nX1CbWxB0dhHQFCfZLtWAuR34 gIC1XnKpUJh84pvM4HrGJL0= X-Google-Smtp-Source: AGRyM1uMKh5o2uyu2vAixHPJkegWWzRHanfW2sKk3I5GXSG39t97WBzrBudT1Aw70xJOOvOkB9zwTw== X-Received: by 2002:a05:6214:c22:b0:472:f86e:47b2 with SMTP id a2-20020a0562140c2200b00472f86e47b2mr12968747qvd.102.1657129382656; Wed, 06 Jul 2022 10:43:02 -0700 (PDT) Received: from localhost (c-69-254-185-160.hsd1.ar.comcast.net. [69.254.185.160]) by smtp.gmail.com with ESMTPSA id bq9-20020a05620a468900b006af6f0893c6sm19449800qkb.91.2022.07.06.10.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 10:43:02 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, Andrew Morton , Andy Shevchenko , David Howells , Ingo Molnar , Geert Uytterhoeven , Jonathan Corbet , "Kirill A . Shutemov" , Matthew Wilcox , NeilBrown , Rasmus Villemoes , Russell King , Vlastimil Babka , William Kucharski , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Cc: Yury Norov Subject: [PATCH 06/10] lib/cpumask: move trivial wrappers around find_bit to the header Date: Wed, 6 Jul 2022 10:42:49 -0700 Message-Id: <20220706174253.4175492-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706174253.4175492-1-yury.norov@gmail.com> References: <20220706174253.4175492-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_104303_767304_D15D02AA X-CRM114-Status: GOOD ( 18.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To avoid circular dependencies, cpumask keeps simple (almost) one-line wrappers around find_bit() in a c-file. Commit 47d8c15615c0a2 ("include: move find.h from asm_generic to linux") moved find.h header out of asm_generic include path, and it helped to fix many circular dependencies, including some in cpumask.h. This patch moves those one-liners to header files. Signed-off-by: Yury Norov --- include/linux/cpumask.h | 57 ++++++++++++++++++++++++++++++++++++++--- lib/cpumask.c | 55 --------------------------------------- 2 files changed, 54 insertions(+), 58 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 760022bcb925..ea3de2c2c180 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -241,7 +241,21 @@ static inline unsigned int cpumask_last(const struct cpumask *srcp) return find_last_bit(cpumask_bits(srcp), nr_cpumask_bits); } -unsigned int __pure cpumask_next(int n, const struct cpumask *srcp); +/** + * cpumask_next - get the next cpu in a cpumask + * @n: the cpu prior to the place to search (ie. return will be > @n) + * @srcp: the cpumask pointer + * + * Returns >= nr_cpu_ids if no further cpus set. + */ +static inline +unsigned int cpumask_next(int n, const struct cpumask *srcp) +{ + /* -1 is a legal arg here. */ + if (n != -1) + cpumask_check(n); + return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1); +} /** * cpumask_next_zero - get the next unset cpu in a cpumask @@ -258,8 +272,25 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp) return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1); } -unsigned int __pure cpumask_next_and(int n, const struct cpumask *, const struct cpumask *); -unsigned int __pure cpumask_any_but(const struct cpumask *mask, unsigned int cpu); +/** + * cpumask_next_and - get the next cpu in *src1p & *src2p + * @n: the cpu prior to the place to search (ie. return will be > @n) + * @src1p: the first cpumask pointer + * @src2p: the second cpumask pointer + * + * Returns >= nr_cpu_ids if no further cpus set in both. + */ +static inline +unsigned int cpumask_next_and(int n, const struct cpumask *src1p, + const struct cpumask *src2p) +{ + /* -1 is a legal arg here. */ + if (n != -1) + cpumask_check(n); + return find_next_and_bit(cpumask_bits(src1p), cpumask_bits(src2p), + nr_cpumask_bits, n + 1); +} + unsigned int cpumask_local_spread(unsigned int i, int node); unsigned int cpumask_any_and_distribute(const struct cpumask *src1p, const struct cpumask *src2p); @@ -324,6 +355,26 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, boo for ((cpu) = -1; \ (cpu) = cpumask_next_and((cpu), (mask1), (mask2)), \ (cpu) < nr_cpu_ids;) + +/** + * cpumask_any_but - return a "random" in a cpumask, but not this one. + * @mask: the cpumask to search + * @cpu: the cpu to ignore. + * + * Often used to find any cpu but smp_processor_id() in a mask. + * Returns >= nr_cpu_ids if no cpus set. + */ +static inline +unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) +{ + unsigned int i; + + cpumask_check(cpu); + for_each_cpu(i, mask) + if (i != cpu) + break; + return i; +} #endif /* SMP */ #define CPU_BITS_NONE \ diff --git a/lib/cpumask.c b/lib/cpumask.c index da68f6bbde44..cb7262ff8633 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -7,61 +7,6 @@ #include #include -/** - * cpumask_next - get the next cpu in a cpumask - * @n: the cpu prior to the place to search (ie. return will be > @n) - * @srcp: the cpumask pointer - * - * Returns >= nr_cpu_ids if no further cpus set. - */ -unsigned int cpumask_next(int n, const struct cpumask *srcp) -{ - /* -1 is a legal arg here. */ - if (n != -1) - cpumask_check(n); - return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1); -} -EXPORT_SYMBOL(cpumask_next); - -/** - * cpumask_next_and - get the next cpu in *src1p & *src2p - * @n: the cpu prior to the place to search (ie. return will be > @n) - * @src1p: the first cpumask pointer - * @src2p: the second cpumask pointer - * - * Returns >= nr_cpu_ids if no further cpus set in both. - */ -unsigned int cpumask_next_and(int n, const struct cpumask *src1p, - const struct cpumask *src2p) -{ - /* -1 is a legal arg here. */ - if (n != -1) - cpumask_check(n); - return find_next_and_bit(cpumask_bits(src1p), cpumask_bits(src2p), - nr_cpumask_bits, n + 1); -} -EXPORT_SYMBOL(cpumask_next_and); - -/** - * cpumask_any_but - return a "random" in a cpumask, but not this one. - * @mask: the cpumask to search - * @cpu: the cpu to ignore. - * - * Often used to find any cpu but smp_processor_id() in a mask. - * Returns >= nr_cpu_ids if no cpus set. - */ -unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) -{ - unsigned int i; - - cpumask_check(cpu); - for_each_cpu(i, mask) - if (i != cpu) - break; - return i; -} -EXPORT_SYMBOL(cpumask_any_but); - /** * cpumask_next_wrap - helper to implement for_each_cpu_wrap * @n: the cpu prior to the place to search