Message ID | 20250401062250.543403-1-houtao@huaweicloud.com (mailing list archive) |
---|---|
Headers | show
Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2D011D54FE for <bpf@vger.kernel.org>; Tue, 1 Apr 2025 06:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743487859; cv=none; b=u8I6DBF/3zBuCWYL4m+9CrKOJZSu+eQnspV1ZOG2Ldjn+YTapqlilAlQzNIcQu1yTep9GY7TzBwWcK54agmyuBQ7odFbYc0NAyqrAfqxc2SKFns2OLmgYW3wIoeDpXUexg0+sCW9+rJ/7p+cnzd35fmlD/pF3P/deuBy4J8Usxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743487859; c=relaxed/simple; bh=76D5pxDXBPUDGwERwu+d2qM4CTY6mefQZdDjbOP1UfM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=YyDSy/J4eiaov6gqsB8wU3x6n1uA53rFG0zzc4usKrOnpyCyhp7CuZFC/tCKxP+zzyl1ulmVgfReJEK6QRTCF9WnNevIbCmGQ+T5tmIYZ6pQ/Ph0/DMdT8Vgru5I8qEWYdyBErogL27LQWB8ZHvfpHg3QOcWbbSPMMOgVV8ijtc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4ZRczy0L3vz4f3m7Y for <bpf@vger.kernel.org>; Tue, 1 Apr 2025 14:10:22 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id B0F6A1A0D1A for <bpf@vger.kernel.org>; Tue, 1 Apr 2025 14:10:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgDXOl9ig+tnpa6yIA--.16784S4; Tue, 01 Apr 2025 14:10:44 +0800 (CST) From: Hou Tao <houtao@huaweicloud.com> To: bpf@vger.kernel.org Cc: Martin KaFai Lau <martin.lau@linux.dev>, Alexei Starovoitov <alexei.starovoitov@gmail.com>, Andrii Nakryiko <andrii@kernel.org>, Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>, Hao Luo <haoluo@google.com>, Yonghong Song <yonghong.song@linux.dev>, Daniel Borkmann <daniel@iogearbox.net>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@fomichev.me>, Jiri Olsa <jolsa@kernel.org>, John Fastabend <john.fastabend@gmail.com>, =?utf-8?q?Toke_H=C3=B8iland-J?= =?utf-8?q?=C3=B8rgensen?= <toke@kernel.org>, Zvi Effron <zeffron@riotgames.com>, Cody Haas <chaas@riotgames.com>, houtao1@huawei.com Subject: [PATCH bpf-next v3 0/6] bpf: Support atomic update for htab of maps Date: Tue, 1 Apr 2025 14:22:44 +0800 Message-Id: <20250401062250.543403-1-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: <bpf.vger.kernel.org> List-Subscribe: <mailto:bpf+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:bpf+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgDXOl9ig+tnpa6yIA--.16784S4 X-Coremail-Antispam: 1UD129KBj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xghudrp/ X-Patchwork-Delegate: bpf@iogearbox.net |
Series |
bpf: Support atomic update for htab of maps
|
expand
|
From: Hou Tao <houtao1@huawei.com> Hi, The motivation for the patch set comes from the question raised by Cody Haas [1]. When trying to concurrently lookup and update an existing element in a htab of maps, the lookup procedure may return -ENOENT unexpectedly. The first revision of the patch set tried to resolve the problem by making the insertion of the new element and the deletion of the old element being atomic from the perspective of the lookup process. While the solution would benefit all hash maps, it does not fully resolved the problem due to the immediate reuse issue. Therefore, in v2 of the patch set, it only fixes the problem for fd htab. Please see individual patches for details. Comments are always welcome. v3: * rebase on bpf_next/for-next * add Acked-by tags v2: https://lore.kernel.org/bpf/20250308135110.953269-1-houtao@huaweicloud.com/ * only support atomic update for fd htab v1: https://lore.kernel.org/bpf/20250204082848.13471-1-hotforest@gmail.com [1]: https://lore.kernel.org/xdp-newbies/CAH7f-ULFTwKdoH_t2SFc5rWCVYLEg-14d1fBYWH2eekudsnTRg@mail.gmail.com/ Hou Tao (6): bpf: Factor out htab_elem_value helper() bpf: Rename __htab_percpu_map_update_elem to htab_map_update_elem_in_place bpf: Support atomic update for htab of maps bpf: Add is_fd_htab() helper bpf: Don't allocate per-cpu extra_elems for fd htab selftests/bpf: Add test case for atomic update of fd htab kernel/bpf/hashtab.c | 148 +++++++------- .../selftests/bpf/prog_tests/fd_htab_lookup.c | 192 ++++++++++++++++++ .../selftests/bpf/progs/fd_htab_lookup.c | 25 +++ 3 files changed, 289 insertions(+), 76 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/fd_htab_lookup.c create mode 100644 tools/testing/selftests/bpf/progs/fd_htab_lookup.c