All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: bpf@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH bpf-next 2/5] bpf: create a header for cgroup_storage_type()
Date: Mon, 13 Dec 2021 15:42:20 -0800	[thread overview]
Message-ID: <20211213234223.356977-3-kuba@kernel.org> (raw)
In-Reply-To: <20211213234223.356977-1-kuba@kernel.org>

cgroup_storage_type() is a static inline which needs to deference
bpf_map. Move it to its own header so that we don't need to pull
in bpf.h. It only has a couple of callers.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 include/linux/bpf-cgroup-storage.h | 17 +++++++++++++++++
 include/linux/bpf-cgroup.h         |  9 ---------
 kernel/bpf/helpers.c               |  1 +
 kernel/bpf/local_storage.c         |  1 +
 4 files changed, 19 insertions(+), 9 deletions(-)
 create mode 100644 include/linux/bpf-cgroup-storage.h

diff --git a/include/linux/bpf-cgroup-storage.h b/include/linux/bpf-cgroup-storage.h
new file mode 100644
index 000000000000..0e0f3409c586
--- /dev/null
+++ b/include/linux/bpf-cgroup-storage.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BPF_CGROUP_STORAGE_H
+#define _BPF_CGROUP_STORAGE_H
+
+#include <linux/bpf.h>
+#include <linux/bpf-cgroup.h>
+
+static inline enum bpf_cgroup_storage_type cgroup_storage_type(
+	struct bpf_map *map)
+{
+	if (map->map_type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE)
+		return BPF_CGROUP_STORAGE_PERCPU;
+
+	return BPF_CGROUP_STORAGE_SHARED;
+}
+
+#endif
diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 11820a430d6c..12474516e0be 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -194,15 +194,6 @@ int __cgroup_bpf_run_filter_getsockopt_kern(struct sock *sk, int level,
 					    int optname, void *optval,
 					    int *optlen, int retval);
 
-static inline enum bpf_cgroup_storage_type cgroup_storage_type(
-	struct bpf_map *map)
-{
-	if (map->map_type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE)
-		return BPF_CGROUP_STORAGE_PERCPU;
-
-	return BPF_CGROUP_STORAGE_SHARED;
-}
-
 struct bpf_cgroup_storage *
 cgroup_storage_lookup(struct bpf_cgroup_storage_map *map,
 		      void *key, bool locked);
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 8babae03d30a..415c38222069 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2,6 +2,7 @@
 /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
  */
 #include <linux/bpf.h>
+#include <linux/bpf-cgroup-storage.h>
 #include <linux/rcupdate.h>
 #include <linux/random.h>
 #include <linux/smp.h>
diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
index 035e9e3a7132..195f9c13ef5b 100644
--- a/kernel/bpf/local_storage.c
+++ b/kernel/bpf/local_storage.c
@@ -1,5 +1,6 @@
 //SPDX-License-Identifier: GPL-2.0
 #include <linux/bpf-cgroup.h>
+#include <linux/bpf-cgroup-storage.h>
 #include <linux/bpf.h>
 #include <linux/bpf_local_storage.h>
 #include <linux/btf.h>
-- 
2.31.1


  parent reply	other threads:[~2021-12-13 23:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 23:42 [PATCH bpf-next 0/5] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
2021-12-13 23:42 ` [PATCH bpf-next 1/5] bpf: add header for enum bpf_cgroup_storage_type Jakub Kicinski
2021-12-13 23:42 ` Jakub Kicinski [this message]
2021-12-13 23:42 ` [PATCH bpf-next 3/5] bpf: create a header for struct bpf_link Jakub Kicinski
2021-12-14  5:15   ` Alexei Starovoitov
2021-12-14 15:04     ` Jakub Kicinski
2021-12-14 15:18       ` Jakub Kicinski
2021-12-14 15:24         ` Jakub Kicinski
2021-12-13 23:42 ` [PATCH bpf-next 4/5] bpf: remove the cgroup -> bpf header dependecy Jakub Kicinski
2021-12-14 19:27   ` kernel test robot
2021-12-14 19:27     ` kernel test robot
2021-12-13 23:42 ` [PATCH bpf-next 5/5] bpf: push down the bpf-link include Jakub Kicinski

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=20211213234223.356977-3-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.