]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bpf: Mark BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE deprecated
authorYonghong Song <yonghong.song@linux.dev>
Sun, 27 Aug 2023 15:28:37 +0000 (08:28 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 8 Sep 2023 15:42:18 +0000 (08:42 -0700)
Now 'BPF_MAP_TYPE_CGRP_STORAGE + local percpu ptr'
can cover all BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE functionality
and more. So mark BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE deprecated.
Also make changes in selftests/bpf/test_bpftool_synctypes.py
and selftest libbpf_str to fix otherwise test errors.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230827152837.2003563-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/prog_tests/libbpf_str.c
tools/testing/selftests/bpf/test_bpftool_synctypes.py

index 8790b3962e4b85f22593f8f9c9f8d94eaf6981f3..73b155e522047d76fc20b17a2268b6af7c34d1b9 100644 (file)
@@ -932,7 +932,14 @@ enum bpf_map_type {
         */
        BPF_MAP_TYPE_CGROUP_STORAGE = BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,
        BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
-       BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
+       BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED,
+       /* BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE is available to bpf programs
+        * attaching to a cgroup. The new mechanism (BPF_MAP_TYPE_CGRP_STORAGE +
+        * local percpu kptr) supports all BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
+        * functionality and more. So mark * BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
+        * deprecated.
+        */
+       BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED,
        BPF_MAP_TYPE_QUEUE,
        BPF_MAP_TYPE_STACK,
        BPF_MAP_TYPE_SK_STORAGE,
index 8790b3962e4b85f22593f8f9c9f8d94eaf6981f3..73b155e522047d76fc20b17a2268b6af7c34d1b9 100644 (file)
@@ -932,7 +932,14 @@ enum bpf_map_type {
         */
        BPF_MAP_TYPE_CGROUP_STORAGE = BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,
        BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
-       BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
+       BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED,
+       /* BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE is available to bpf programs
+        * attaching to a cgroup. The new mechanism (BPF_MAP_TYPE_CGRP_STORAGE +
+        * local percpu kptr) supports all BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
+        * functionality and more. So mark * BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
+        * deprecated.
+        */
+       BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED,
        BPF_MAP_TYPE_QUEUE,
        BPF_MAP_TYPE_STACK,
        BPF_MAP_TYPE_SK_STORAGE,
index efb8bd43653c5a01bf9db2bfaac19bc6f42ef0be..c440ea3311ed929ad8698cac09280ac61abb2300 100644 (file)
@@ -142,10 +142,14 @@ static void test_libbpf_bpf_map_type_str(void)
                /* Special case for map_type_name BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED
                 * where it and BPF_MAP_TYPE_CGROUP_STORAGE have the same enum value
                 * (map_type). For this enum value, libbpf_bpf_map_type_str() picks
-                * BPF_MAP_TYPE_CGROUP_STORAGE.
+                * BPF_MAP_TYPE_CGROUP_STORAGE. The same for
+                * BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED and
+                * BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE.
                 */
                if (strcmp(map_type_name, "BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED") == 0)
                        continue;
+               if (strcmp(map_type_name, "BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED") == 0)
+                       continue;
 
                ASSERT_STREQ(buf, map_type_name, "exp_str_value");
        }
index 0cfece7ff4f84b0531417bf8a0e0696e3ff628de..0ed67b6b31dd0231ec8a9b3baf583b562aac80c3 100755 (executable)
@@ -509,6 +509,15 @@ def main():
     source_map_types.remove('cgroup_storage_deprecated')
     source_map_types.add('cgroup_storage')
 
+    # The same applied to BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED and
+    # BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE which share the same enum value
+    # and source_map_types picks
+    # BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED/percpu_cgroup_storage_deprecated.
+    # Replace 'percpu_cgroup_storage_deprecated' with 'percpu_cgroup_storage'
+    # so it aligns with what `bpftool map help` shows.
+    source_map_types.remove('percpu_cgroup_storage_deprecated')
+    source_map_types.add('percpu_cgroup_storage')
+
     help_map_types = map_info.get_map_help()
     help_map_options = map_info.get_options()
     map_info.close()