From patchwork Fri Jul 1 12:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12903259 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 47A29CCA481 for ; Fri, 1 Jul 2022 12:54:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00E106B0080; Fri, 1 Jul 2022 08:54:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F00756B0081; Fri, 1 Jul 2022 08:54:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D521B6B0082; Fri, 1 Jul 2022 08:54:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C714C6B0080 for ; Fri, 1 Jul 2022 08:54:41 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 9C53080508 for ; Fri, 1 Jul 2022 12:54:41 +0000 (UTC) X-FDA: 79638525162.10.7D6C4CF Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 34B3B1C0041 for ; Fri, 1 Jul 2022 12:54:40 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id ay10so315655qtb.1 for ; Fri, 01 Jul 2022 05:54:40 -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=Yk+/uLtYXUwgn0wFnU+xBwbbd3TV73jozv6kkTCTPvnSU9wbfdn60UbySuTSzEnlro OFkfibFSzHxte2aNxRaTB4TAFPYFvgl2SO8cegFcl0yTUgA4NOjqmhZQDwqkpglxQE4E EDkQELLxqbSTr1l3tptyPi1u1KXl3+n4nt5EvNzr7Fel2D1S6yqNVMbhuQ5VI5f0fwyQ yDK/6Rzu9EAz4D/X8McX3fiBEh6f6NfyPWW97wLZssbppvSs9DIilPK4/adUVClpALkj 7KF0kU2JesgZU0jpoSRIxaGW5Ygz8MSH42mPif+ahyF2X8YO9PAyEJz82S9F9t0ziyVA 1mKw== 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=sHR93+JQM8Q2JzKysYcHI+z46sPOx+9/X/x5JbwTuNO71rHHoqowWEXSGiSG7d09Yt BeFrFCO8+MlS/tWn2ceNxnTxxvg3J2/D0Q3Q7vW+pwMjansgfCM9buBLQo7luHkNGDHS HDapN2mHavxbzUqmMvIv+A1fAwxCM9qBKaf5Afb2VuVqaWErsM62DNt3KaPvdVapI4H8 qtYPzZlh0b4xhw58NLUbJxB4TJloZSqLkYkRTLGY5SLqGbCmdxQTV1GkPJK5cK9ug0Yj wZmRxKSCdZqn3euPZQeX6qQv8P2cToUbPt9R9JuOyN4A3beF1aiYKHCUIwsDBRzSjhMm 7nbQ== X-Gm-Message-State: AJIora/eglzAL30uI/jewAHdpC5UCWqRQ7cMfE36q9VMOxaQM0cwcTmO kB6HeKK7kTvmiDoWSGBvAxE= X-Google-Smtp-Source: AGRyM1vO/ADr3cD/se1PN5gtMxssiVvttv4kkUOmlPTTOpQ+ZzknMS4C2otZaWPxwqIx7qTrO6XQgA== X-Received: by 2002:ac8:5b88:0:b0:305:340b:6f14 with SMTP id a8-20020ac85b88000000b00305340b6f14mr12235034qta.344.1656680080278; Fri, 01 Jul 2022 05:54:40 -0700 (PDT) Received: from localhost ([2601:4c1:c100:1230:f902:9816:653f:2f66]) by smtp.gmail.com with ESMTPSA id v2-20020a05622a130200b00304e47b9602sm15875188qtk.9.2022.07.01.05.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 05:54:40 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, Andrew Morton , Andy Shevchenko , David Howells , 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 6/8] lib/cpumask: move trivial wrappers around find_bit to the header Date: Fri, 1 Jul 2022 05:54:28 -0700 Message-Id: <20220701125430.2907638-7-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220701125430.2907638-1-yury.norov@gmail.com> References: <20220701125430.2907638-1-yury.norov@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Yk+/uLtY"; spf=pass (imf18.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.178 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=1656680081; 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=O5UYqBUbR4ROWYEOrnTjIodSh67tn5HRKasqhiZYe2i8eVhsaL5f7bjcJH5IBDw5ZgOJ5u 7oLtojjopeQGT70iEjUPs7p+wva149d4p8cqf4rQqqDApFgPty1UxsQpvfOs0tuYt+A7ih OQx29dnjfuprOAnpTWlmR1JJgXGopXE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656680081; a=rsa-sha256; cv=none; b=MoqkpvjA3m6S5xgGa+WnZA3odla5d2eyLymNlK5jbS4rRZmXumR2G/QptVQ5/AascjbfvA wrrDCfyAQ07Et/jI9ycoXFiGyYEPLpZW6O1MTL4D2AtVnFPMpCXat7+ImaRTZF5HyKN9f1 P8U4pNBQDvRifjRIL2dLB1jUUTYOrw8= X-Stat-Signature: be8t4qnuh84u1g9bwoebye698dpxatay X-Rspamd-Queue-Id: 34B3B1C0041 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Yk+/uLtY"; spf=pass (imf18.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.178 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam12 X-Rspam-User: X-HE-Tag: 1656680080-717056 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