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: 12908421 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91D37CCA473 for ; Wed, 6 Jul 2022 17:43:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D38D6B007D; Wed, 6 Jul 2022 13:43:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 560946B007E; Wed, 6 Jul 2022 13:43:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 251E46B0080; Wed, 6 Jul 2022 13:43:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 154AF6B007D for ; Wed, 6 Jul 2022 13:43:04 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DA04E32DA7 for ; Wed, 6 Jul 2022 17:43:03 +0000 (UTC) X-FDA: 79657395846.25.9776087 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf30.hostedemail.com (Postfix) with ESMTP id 80C578003A for ; Wed, 6 Jul 2022 17:43:03 +0000 (UTC) Received: by mail-qt1-f170.google.com with SMTP id z13so19273634qts.12 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=YO6p1/vzKKStRR+DizSvWu76cFTrmT3dEtWzMdwu5WM+JgCdG4Il3CmydyLEaUd1zd 5HJvyYHYgKqySRl/FM5QJlUsKlVifzWMG8gDbeKu9G7B6/5yBWPCdOZYTNhGZL/d/xKr di3X5NITpFLKxphbhKcOx8LNw85gzwUlsfZs/sXfjizB7yUbz5NHwSuER9/vq3in/5Jx AfUhGbmn1kgaxI46iQ7Rs7ZPMvzaFJ8yV8plCR6LMDVMBPVjS3HTvTEsTAj8R7Zy9GKO cmNnZ7MWQM6oe8o8Wjm/Kuz2I/0sxYR8h2zP0L28ybyGKZuQDULpT6tLwR4sL+h3d59u rkcg== X-Gm-Message-State: AJIora+FtGff0feYvdCrU3o4KWXWFaA3e43d+d3CHfNU5eEG5SY4PAed tHBwk0IqcL37kYrPPZhAF72JLPd4SxLgcQ== 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657129383; a=rsa-sha256; cv=none; b=otMeUMzKNwjK+qs496GJcm/7mGWeZecKtBF5CPzx4dler2cO0967Ub6poHozYr/feV5a/9 y+mUYH8b52oyEooj7TYqzWnzFd6pMTZaFQt764GaLKlufI6PhDmMGnqemaLmjMVkTckBDO HCiXStGv2cOtdfH/PKYTvueAC9LSuxE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hiMIpOPv; spf=pass (imf30.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657129383; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gmLdladheqxAWwfcqAo0zECfXUO+llLx3LkvFH+700E=; b=6kiZHaSnor2zuEZwgsgKbiqYpKTw/0We8yZOFWHAgtdXoX7PM3HHpYTsCQYnSmKHILZFhG jyS7TSOKulUlHWpmgB4O4yyvb164aKdo6tlDgI8JuP/dvxC1Zo6evzMcupnM5UMC0Xqvj/ aWuntwobbwq43k76wy9K/PuLpxZBJoA= Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hiMIpOPv; spf=pass (imf30.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.170 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: himt3icfnc1rxt5zbfwmpt6gtoj4uq53 X-Rspamd-Queue-Id: 80C578003A X-HE-Tag: 1657129383-966616 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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