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: 12903267 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 18D78C433EF for ; Fri, 1 Jul 2022 12:56:53 +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=vMA7qA5cuFAIgX +vY7o/73aEdmuJz98OZ7SIxNq2I1USlHyLUCOLANY1ivWqUufPn1hpRTsMWv4Mj/SIGK6rflE+BhF dYNNeyN7Ts9DRkHDqQossMsyRSKZTOj7+iMBqkh5YjctGIb2dvJnSK0pFiiw8SNkn/oTGCe9ukmnD NVAlSdpoXho09AUbocyEvONtzOqnlQMVL/OkYmcZKKO8xIKq7TTo+m1V0NsLIzwvAmAINl2l9G6AQ iQWcigS2vV28Dla9mWV4hqzxO06VXIfJJR698eLsbOGdyvd2EsPieCTHD5IBwcsmT3gOSXZJ+fUJU noepHb7nNX+UbyPAtaSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GBY-004s6r-3E; Fri, 01 Jul 2022 12:55:48 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GAU-004raf-G0 for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 12:54:46 +0000 Received: by mail-qt1-x82e.google.com with SMTP id he28so315995qtb.13 for ; Fri, 01 Jul 2022 05:54:41 -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=1xzHcFg1BRR6kHqGBP7YA4t/4jZgXp6b0K4nwohmCmGRPIU2pD05lwV5790+J3PzN/ qlwIBW/0mXmyMARY1e3ARx4RalPMWa1AW+JQF3gUwc3HfCMnadzpoC5yafx4NhyZOF1P XKEE8meVPHRgycNmAPTifeksultAY0Jv/yYgagM/QTwTa7G3dGcJpOwI89pyI40Fdy3u BXMjeNb9AYrwyyZsiEb758c3PV6HYA6haGyRw5B18+pwtx0ithThEr6xvzM+0y+0RjRn gOsbRkiXeFuC3KDDWbmqnWaS0L1Q9kdr7k3Vh3y5tEl/GBZPrGrm0MstAtbYJQZk5M1a rb5g== X-Gm-Message-State: AJIora/eFfQhyXk0SIf52cBnJyYFAk2UzQr0JA5cbQ83NvWSs8TEYHpu iaAOwtbp46x+Cq5KziPEZv4= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220701_055442_646505_B6703F86 X-CRM114-Status: GOOD ( 18.78 ) 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