From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 03/54] Partially revert bpf: Zero-fill re-used per-cpu map element
Date: Thu, 10 Dec 2020 15:26:40 +0100 [thread overview]
Message-ID: <20201210142602.216723238@linuxfoundation.org> (raw)
In-Reply-To: <20201210142602.037095225@linuxfoundation.org>
Drop the added selftest as it depends on functionality that doesn't
exist in 5.4.
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../selftests/bpf/prog_tests/map_init.c | 214 ------------------
.../selftests/bpf/progs/test_map_init.c | 33 ---
2 files changed, 247 deletions(-)
delete mode 100644 tools/testing/selftests/bpf/prog_tests/map_init.c
delete mode 100644 tools/testing/selftests/bpf/progs/test_map_init.c
diff --git a/tools/testing/selftests/bpf/prog_tests/map_init.c b/tools/testing/selftests/bpf/prog_tests/map_init.c
deleted file mode 100644
index 14a31109dd0e0..0000000000000
--- a/tools/testing/selftests/bpf/prog_tests/map_init.c
+++ /dev/null
@@ -1,214 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* Copyright (c) 2020 Tessares SA <http://www.tessares.net> */
-
-#include <test_progs.h>
-#include "test_map_init.skel.h"
-
-#define TEST_VALUE 0x1234
-#define FILL_VALUE 0xdeadbeef
-
-static int nr_cpus;
-static int duration;
-
-typedef unsigned long long map_key_t;
-typedef unsigned long long map_value_t;
-typedef struct {
- map_value_t v; /* padding */
-} __bpf_percpu_val_align pcpu_map_value_t;
-
-
-static int map_populate(int map_fd, int num)
-{
- pcpu_map_value_t value[nr_cpus];
- int i, err;
- map_key_t key;
-
- for (i = 0; i < nr_cpus; i++)
- bpf_percpu(value, i) = FILL_VALUE;
-
- for (key = 1; key <= num; key++) {
- err = bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST);
- if (!ASSERT_OK(err, "bpf_map_update_elem"))
- return -1;
- }
-
- return 0;
-}
-
-static struct test_map_init *setup(enum bpf_map_type map_type, int map_sz,
- int *map_fd, int populate)
-{
- struct test_map_init *skel;
- int err;
-
- skel = test_map_init__open();
- if (!ASSERT_OK_PTR(skel, "skel_open"))
- return NULL;
-
- err = bpf_map__set_type(skel->maps.hashmap1, map_type);
- if (!ASSERT_OK(err, "bpf_map__set_type"))
- goto error;
-
- err = bpf_map__set_max_entries(skel->maps.hashmap1, map_sz);
- if (!ASSERT_OK(err, "bpf_map__set_max_entries"))
- goto error;
-
- err = test_map_init__load(skel);
- if (!ASSERT_OK(err, "skel_load"))
- goto error;
-
- *map_fd = bpf_map__fd(skel->maps.hashmap1);
- if (CHECK(*map_fd < 0, "bpf_map__fd", "failed\n"))
- goto error;
-
- err = map_populate(*map_fd, populate);
- if (!ASSERT_OK(err, "map_populate"))
- goto error_map;
-
- return skel;
-
-error_map:
- close(*map_fd);
-error:
- test_map_init__destroy(skel);
- return NULL;
-}
-
-/* executes bpf program that updates map with key, value */
-static int prog_run_insert_elem(struct test_map_init *skel, map_key_t key,
- map_value_t value)
-{
- struct test_map_init__bss *bss;
-
- bss = skel->bss;
-
- bss->inKey = key;
- bss->inValue = value;
- bss->inPid = getpid();
-
- if (!ASSERT_OK(test_map_init__attach(skel), "skel_attach"))
- return -1;
-
- /* Let tracepoint trigger */
- syscall(__NR_getpgid);
-
- test_map_init__detach(skel);
-
- return 0;
-}
-
-static int check_values_one_cpu(pcpu_map_value_t *value, map_value_t expected)
-{
- int i, nzCnt = 0;
- map_value_t val;
-
- for (i = 0; i < nr_cpus; i++) {
- val = bpf_percpu(value, i);
- if (val) {
- if (CHECK(val != expected, "map value",
- "unexpected for cpu %d: 0x%llx\n", i, val))
- return -1;
- nzCnt++;
- }
- }
-
- if (CHECK(nzCnt != 1, "map value", "set for %d CPUs instead of 1!\n",
- nzCnt))
- return -1;
-
- return 0;
-}
-
-/* Add key=1 elem with values set for all CPUs
- * Delete elem key=1
- * Run bpf prog that inserts new key=1 elem with value=0x1234
- * (bpf prog can only set value for current CPU)
- * Lookup Key=1 and check value is as expected for all CPUs:
- * value set by bpf prog for one CPU, 0 for all others
- */
-static void test_pcpu_map_init(void)
-{
- pcpu_map_value_t value[nr_cpus];
- struct test_map_init *skel;
- int map_fd, err;
- map_key_t key;
-
- /* max 1 elem in map so insertion is forced to reuse freed entry */
- skel = setup(BPF_MAP_TYPE_PERCPU_HASH, 1, &map_fd, 1);
- if (!ASSERT_OK_PTR(skel, "prog_setup"))
- return;
-
- /* delete element so the entry can be re-used*/
- key = 1;
- err = bpf_map_delete_elem(map_fd, &key);
- if (!ASSERT_OK(err, "bpf_map_delete_elem"))
- goto cleanup;
-
- /* run bpf prog that inserts new elem, re-using the slot just freed */
- err = prog_run_insert_elem(skel, key, TEST_VALUE);
- if (!ASSERT_OK(err, "prog_run_insert_elem"))
- goto cleanup;
-
- /* check that key=1 was re-created by bpf prog */
- err = bpf_map_lookup_elem(map_fd, &key, value);
- if (!ASSERT_OK(err, "bpf_map_lookup_elem"))
- goto cleanup;
-
- /* and has expected values */
- check_values_one_cpu(value, TEST_VALUE);
-
-cleanup:
- test_map_init__destroy(skel);
-}
-
-/* Add key=1 and key=2 elems with values set for all CPUs
- * Run bpf prog that inserts new key=3 elem
- * (only for current cpu; other cpus should have initial value = 0)
- * Lookup Key=1 and check value is as expected for all CPUs
- */
-static void test_pcpu_lru_map_init(void)
-{
- pcpu_map_value_t value[nr_cpus];
- struct test_map_init *skel;
- int map_fd, err;
- map_key_t key;
-
- /* Set up LRU map with 2 elements, values filled for all CPUs.
- * With these 2 elements, the LRU map is full
- */
- skel = setup(BPF_MAP_TYPE_LRU_PERCPU_HASH, 2, &map_fd, 2);
- if (!ASSERT_OK_PTR(skel, "prog_setup"))
- return;
-
- /* run bpf prog that inserts new key=3 element, re-using LRU slot */
- key = 3;
- err = prog_run_insert_elem(skel, key, TEST_VALUE);
- if (!ASSERT_OK(err, "prog_run_insert_elem"))
- goto cleanup;
-
- /* check that key=3 replaced one of earlier elements */
- err = bpf_map_lookup_elem(map_fd, &key, value);
- if (!ASSERT_OK(err, "bpf_map_lookup_elem"))
- goto cleanup;
-
- /* and has expected values */
- check_values_one_cpu(value, TEST_VALUE);
-
-cleanup:
- test_map_init__destroy(skel);
-}
-
-void test_map_init(void)
-{
- nr_cpus = bpf_num_possible_cpus();
- if (nr_cpus <= 1) {
- printf("%s:SKIP: >1 cpu needed for this test\n", __func__);
- test__skip();
- return;
- }
-
- if (test__start_subtest("pcpu_map_init"))
- test_pcpu_map_init();
- if (test__start_subtest("pcpu_lru_map_init"))
- test_pcpu_lru_map_init();
-}
diff --git a/tools/testing/selftests/bpf/progs/test_map_init.c b/tools/testing/selftests/bpf/progs/test_map_init.c
deleted file mode 100644
index c89d28ead6737..0000000000000
--- a/tools/testing/selftests/bpf/progs/test_map_init.c
+++ /dev/null
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (c) 2020 Tessares SA <http://www.tessares.net> */
-
-#include "vmlinux.h"
-#include <bpf/bpf_helpers.h>
-
-__u64 inKey = 0;
-__u64 inValue = 0;
-__u32 inPid = 0;
-
-struct {
- __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
- __uint(max_entries, 2);
- __type(key, __u64);
- __type(value, __u64);
-} hashmap1 SEC(".maps");
-
-
-SEC("tp/syscalls/sys_enter_getpgid")
-int sysenter_getpgid(const void *ctx)
-{
- /* Just do it for once, when called from our own test prog. This
- * ensures the map value is only updated for a single CPU.
- */
- int cur_pid = bpf_get_current_pid_tgid() >> 32;
-
- if (cur_pid == inPid)
- bpf_map_update_elem(&hashmap1, &inKey, &inValue, BPF_NOEXIST);
-
- return 0;
-}
-
-char _license[] SEC("license") = "GPL";
--
2.27.0
next prev parent reply other threads:[~2020-12-10 18:26 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-10 14:26 [PATCH 5.4 00/54] 5.4.83-rc1 review Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 01/54] pinctrl: baytrail: Replace WARN with dev_info_once when setting direct-irq pin to output Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 02/54] pinctrl: baytrail: Fix pin being driven low for a while on gpiod_get(..., GPIOD_OUT_HIGH) Greg Kroah-Hartman
2020-12-10 14:26 ` Greg Kroah-Hartman [this message]
2020-12-10 14:26 ` [PATCH 5.4 04/54] usb: gadget: f_fs: Use local copy of descriptors for userspace copy Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 05/54] USB: serial: kl5kusb105: fix memleak on open Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 06/54] USB: serial: ch341: add new Product ID for CH341A Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 07/54] USB: serial: ch341: sort device-id entries Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 08/54] USB: serial: option: add Fibocom NL668 variants Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 09/54] USB: serial: option: add support for Thales Cinterion EXS82 Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 10/54] USB: serial: option: fix Quectel BG96 matching Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 11/54] tty: Fix ->pgrp locking in tiocspgrp() Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 12/54] tty: Fix ->session locking Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 13/54] ALSA: hda/realtek: Fix bass speaker DAC assignment on Asus Zephyrus G14 Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 14/54] ALSA: hda/realtek: Add mute LED quirk to yet another HP x360 model Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 15/54] ALSA: hda/realtek: Enable headset of ASUS UX482EG & B9400CEA with ALC294 Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 16/54] ALSA: hda/realtek - Add new codec supported for ALC897 Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 17/54] ALSA: hda/generic: Add option to enforce preferred_dacs pairs Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 18/54] ftrace: Fix updating FTRACE_FL_TRAMP Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 19/54] cifs: allow syscalls to be restarted in __smb_send_rqst() Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 20/54] cifs: fix potential use-after-free in cifs_echo_request() Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 21/54] s390/pci: fix CPU address in MSI for directed IRQ Greg Kroah-Hartman
2020-12-10 16:34 ` Niklas Schnelle
2020-12-10 16:46 ` Greg Kroah-Hartman
2020-12-10 14:26 ` [PATCH 5.4 22/54] i2c: imx: Dont generate STOP condition if arbitration has been lost Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 23/54] thunderbolt: Fix use-after-free in remove_unplugged_switch() Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 24/54] drm/i915/gt: Program mocs:63 for cache eviction on gen9 Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 25/54] scsi: mpt3sas: Fix ioctl timeout Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 26/54] dm writecache: fix the maximum number of arguments Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 27/54] powerpc/64s/powernv: Fix memory corruption when saving SLB entries on MCE Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 28/54] genirq/irqdomain: Add an irq_create_mapping_affinity() function Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 29/54] powerpc/pseries: Pass MSI affinity to irq_create_mapping() Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 30/54] dm: fix bug with RCU locking in dm_blk_report_zones Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 31/54] dm: remove invalid sparse __acquires and __releases annotations Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 32/54] x86/uprobes: Do not use prefixes.nbytes when looping over prefixes.bytes Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 33/54] coredump: fix core_pattern parse error Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 34/54] mm: list_lru: set shrinker map bit when child nr_items is not zero Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 35/54] mm/swapfile: do not sleep with a spin lock held Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 36/54] speakup: Reject setting the speakup line discipline outside of speakup Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 37/54] i2c: imx: Fix reset of I2SR_IAL flag Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 38/54] i2c: imx: Check for I2SR_IAL after every byte Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 39/54] spi: bcm2835: Release the DMA channel if probe fails after dma_init Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 40/54] iommu/amd: Set DTE[IntTabLen] to represent 512 IRTEs Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 41/54] tracing: Fix userstacktrace option for instances Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 42/54] lib/syscall: fix syscall registers retrieval on 32-bit platforms Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 43/54] can: af_can: can_rx_unregister(): remove WARN() statement from list operation sanity check Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 44/54] gfs2: check for empty rgrp tree in gfs2_ri_update Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 45/54] netfilter: ipset: prevent uninit-value in hash_ip6_add Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 46/54] tipc: fix a deadlock when flushing scheduled work Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 47/54] ASoC: wm_adsp: fix error return code in wm_adsp_load() Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 48/54] rtw88: debug: Fix uninitialized memory in debugfs code Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 49/54] i2c: qup: Fix error return code in qup_i2c_bam_schedule_desc() Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 50/54] dm writecache: remove BUG() and fail gracefully instead Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 51/54] Input: i8042 - fix error return code in i8042_setup_aux() Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 52/54] netfilter: nf_tables: avoid false-postive lockdep splat Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 53/54] netfilter: nftables_offload: set address type in control dissector Greg Kroah-Hartman
2020-12-10 14:27 ` [PATCH 5.4 54/54] x86/insn-eval: Use new for_each_insn_prefix() macro to loop over prefixes bytes Greg Kroah-Hartman
2020-12-10 21:04 ` [PATCH 5.4 00/54] 5.4.83-rc1 review Jon Hunter
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=20201210142602.216723238@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).