BPF List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: fenghua.yu@intel.com, reinette.chatre@intel.com
Cc: bpf@vger.kernel.org, james.morse@arm.com,
	Jakub Kicinski <kuba@kernel.org>,
	tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, peterz@infradead.org, will@kernel.org,
	linux-riscv@lists.infradead.org
Subject: [PATCH bpf] cacheinfo: move get_cpu_cacheinfo_id() back out
Date: Sat, 20 Nov 2021 08:55:28 -0800	[thread overview]
Message-ID: <20211120165528.197359-1-kuba@kernel.org> (raw)

This commit more or less reverts commit 709c4362725a ("cacheinfo:
Move resctrl's get_cache_id() to the cacheinfo header file").

There are no users of the static inline helper outside of resctrl/core.c
and cpu.h is a pretty heavy include, it pulls in device.h etc. This
trips up architectures like riscv which want to access cacheinfo
in low level headers like elf.h.

Link: https://lore.kernel.org/all/20211120035253.72074-1-kuba@kernel.org/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: fenghua.yu@intel.com
CC: reinette.chatre@intel.com
CC: tglx@linutronix.de
CC: mingo@redhat.com
CC: bp@alien8.de
CC: dave.hansen@linux.intel.com
CC: x86@kernel.org
CC: hpa@zytor.com
CC: paul.walmsley@sifive.com
CC: palmer@dabbelt.com
CC: aou@eecs.berkeley.edu
CC: peterz@infradead.org
CC: will@kernel.org
CC: linux-riscv@lists.infradead.org

x86 resctrl folks, does this look okay?

I'd like to do some bpf header cleanups in -next which this is blocking.
How would you like to handle that? This change looks entirely harmless,
can I get an ack and take this via bpf/netdev to Linus ASAP so it
propagates to all trees?
---
 arch/x86/kernel/cpu/resctrl/core.c | 20 ++++++++++++++++++++
 include/linux/cacheinfo.h          | 21 ---------------------
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index bb1c3f5f60c8..3c0b2c34be23 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -284,6 +284,26 @@ static void rdt_get_cdp_l2_config(void)
 	rdt_get_cdp_config(RDT_RESOURCE_L2);
 }
 
+/*
+ * Get the id of the cache associated with @cpu at level @level.
+ * cpuhp lock must be held.
+ */
+static int get_cpu_cacheinfo_id(int cpu, int level)
+{
+	struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
+	int i;
+
+	for (i = 0; i < ci->num_leaves; i++) {
+		if (ci->info_list[i].level == level) {
+			if (ci->info_list[i].attributes & CACHE_ID)
+				return ci->info_list[i].id;
+			return -1;
+		}
+	}
+
+	return -1;
+}
+
 static void
 mba_wrmsr_amd(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r)
 {
diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
index 2f909ed084c6..c8c71eea237d 100644
--- a/include/linux/cacheinfo.h
+++ b/include/linux/cacheinfo.h
@@ -3,7 +3,6 @@
 #define _LINUX_CACHEINFO_H
 
 #include <linux/bitops.h>
-#include <linux/cpu.h>
 #include <linux/cpumask.h>
 #include <linux/smp.h>
 
@@ -102,24 +101,4 @@ int acpi_find_last_cache_level(unsigned int cpu);
 
 const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
 
-/*
- * Get the id of the cache associated with @cpu at level @level.
- * cpuhp lock must be held.
- */
-static inline int get_cpu_cacheinfo_id(int cpu, int level)
-{
-	struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu);
-	int i;
-
-	for (i = 0; i < ci->num_leaves; i++) {
-		if (ci->info_list[i].level == level) {
-			if (ci->info_list[i].attributes & CACHE_ID)
-				return ci->info_list[i].id;
-			return -1;
-		}
-	}
-
-	return -1;
-}
-
 #endif /* _LINUX_CACHEINFO_H */
-- 
2.31.1


             reply	other threads:[~2021-11-20 16:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-20 16:55 Jakub Kicinski [this message]
2021-11-23 17:45 ` [PATCH bpf] cacheinfo: move get_cpu_cacheinfo_id() back out Song Liu
2021-11-23 18:37   ` Jakub Kicinski
2021-11-23 18:48   ` James Morse
2021-11-24  8:14     ` Song Liu
2021-11-25 15:59       ` Alexei Starovoitov
2021-11-29 18:28         ` Reinette Chatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211120165528.197359-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mingo@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=reinette.chatre@intel.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox