From patchwork Mon Feb 17 01:41:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Zhang X-Patchwork-Id: 13976980 X-Patchwork-Delegate: bpf@iogearbox.net Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 B753513BAE3 for ; Mon, 17 Feb 2025 01:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757205; cv=none; b=WfyolCs5RuG1z+lzdsMoCrG3NLoWS7l8OfUJYtutmvEZU85Z9XWG4QYRXujdpOyu2IV8aw6U6Bk70zd3/dcrO2u9/gSgqsKxfUogEcEvL6tPzo7kDLfc0+3Q+7BXVS2jP7cU9Qc1Hmb/tK/zZCSPa6AqmhV7scHKYcNuCFLd/g4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757205; c=relaxed/simple; bh=NpISDxi7NgbjwcTbH/rv1VJgLXUJoX4j4klbBItCx/U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VyyMeGTstkQDmkBw09dZs5p1j3emZ56ki9parwg0i2K6+m1nwxajMezNv09+oprdSlLRNSvtN2yzINPlO1gdfaY3VBKD24MNPGAQjK77olSQxBQ2Y+HoJxvCyWkDdAjT2TwvEXVW44Wl+IKceZe511p7xMVmZ+h+BAqZR63qwn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Yx5Fk2lzRz22sxC; Mon, 17 Feb 2025 09:50:18 +0800 (CST) Received: from kwepemh200013.china.huawei.com (unknown [7.202.181.122]) by mail.maildlp.com (Postfix) with ESMTPS id 2F546140155; Mon, 17 Feb 2025 09:53:16 +0800 (CST) Received: from hulk-vt.huawei.com (10.67.175.36) by kwepemh200013.china.huawei.com (7.202.181.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 17 Feb 2025 09:53:15 +0800 From: Xiaomeng Zhang To: CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH -next 1/5] bpf: Remove map_peek_elem callbacks with -EOPNOTSUPP Date: Mon, 17 Feb 2025 01:41:18 +0000 Message-ID: <20250217014122.65645-2-zhangxiaomeng13@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> References: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh200013.china.huawei.com (7.202.181.122) X-Patchwork-Delegate: bpf@iogearbox.net Remove redundant map_peek_elem callbacks with return -EOPNOTSUPP. We can directly return -EOPNOTSUPP when calling the unimplemented callbacks. Signed-off-by: Xiaomeng Zhang --- kernel/bpf/arena.c | 6 ------ kernel/bpf/helpers.c | 5 ++++- kernel/bpf/syscall.c | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 095a9554e1de..0aaefa5d6b09 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -62,11 +62,6 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena) return arena ? arena->user_vm_start : 0; } -static long arena_map_peek_elem(struct bpf_map *map, void *value) -{ - return -EOPNOTSUPP; -} - static long arena_map_push_elem(struct bpf_map *map, void *value, u64 flags) { return -EOPNOTSUPP; @@ -404,7 +399,6 @@ const struct bpf_map_ops arena_map_ops = { .map_get_unmapped_area = arena_get_unmapped_area, .map_get_next_key = arena_map_get_next_key, .map_push_elem = arena_map_push_elem, - .map_peek_elem = arena_map_peek_elem, .map_pop_elem = arena_map_pop_elem, .map_lookup_elem = arena_map_lookup_elem, .map_update_elem = arena_map_update_elem, diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index f27ce162427a..0f429171de6d 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -116,7 +116,10 @@ const struct bpf_func_proto bpf_map_pop_elem_proto = { BPF_CALL_2(bpf_map_peek_elem, struct bpf_map *, map, void *, value) { - return map->ops->map_peek_elem(map, value); + if (map->ops->map_peek_elem) + return map->ops->map_peek_elem(map, value); + else + return -EOPNOTSUPP; } const struct bpf_func_proto bpf_map_peek_elem_proto = { diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index ff1f980bd59a..e6e859f71c5d 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -325,7 +325,10 @@ static int bpf_map_copy_value(struct bpf_map *map, void *key, void *value, } else if (map->map_type == BPF_MAP_TYPE_QUEUE || map->map_type == BPF_MAP_TYPE_STACK || map->map_type == BPF_MAP_TYPE_BLOOM_FILTER) { - err = map->ops->map_peek_elem(map, value); + if (map->ops->map_peek_elem) + err = map->ops->map_peek_elem(map, value); + else + err = -EOPNOTSUPP; } else if (map->map_type == BPF_MAP_TYPE_STRUCT_OPS) { /* struct_ops map requires directly updating "value" */ err = bpf_struct_ops_map_sys_lookup_elem(map, key, value); From patchwork Mon Feb 17 01:41:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Zhang X-Patchwork-Id: 13976978 X-Patchwork-Delegate: bpf@iogearbox.net Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (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 B6E2B79D2 for ; Mon, 17 Feb 2025 01:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757200; cv=none; b=TwqzHnWil9IazwJtOh2mI5Yq30kw1PV3LmOR/0LPoXH4mUeaJ0SG9ZpZD/vPbCYN0Q+ye8VCXs/kC52nq9TfNG3/MSvJBBsheH6x4XTRN5PWVUaj11xVe7yzTTO03btL6jL66FGu99TboQKtmCHs9a9WPDonrn+4ubbtD9RciaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757200; c=relaxed/simple; bh=sG9hgFe1T4yghgopIY77t4MC1sA+1CjH+hduUo7qi7M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QHzqqeJzZZOnG2e4wgETlAhzUa+n9fvtlia+P/JHPZKdKa7rTEI0RgrUqhDN29Sz3oN60BbVdZdfOmUkb/jlMOqgNPxBgyxDeTtV6n70B9Lf/7vdZvpjJ961d9mGBH6H+/sG8Je5IrBRxDgUYW6MquepIr41Xki/3KgGoxvyjEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Yx5Kl0Vfpz1xv1Z; Mon, 17 Feb 2025 09:53:47 +0800 (CST) Received: from kwepemh200013.china.huawei.com (unknown [7.202.181.122]) by mail.maildlp.com (Postfix) with ESMTPS id ACC551A0171; Mon, 17 Feb 2025 09:53:16 +0800 (CST) Received: from hulk-vt.huawei.com (10.67.175.36) by kwepemh200013.china.huawei.com (7.202.181.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 17 Feb 2025 09:53:15 +0800 From: Xiaomeng Zhang To: CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH -next 2/5] bpf: Remove map_push_elem callbacks with -EOPNOTSUPP Date: Mon, 17 Feb 2025 01:41:19 +0000 Message-ID: <20250217014122.65645-3-zhangxiaomeng13@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> References: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh200013.china.huawei.com (7.202.181.122) X-Patchwork-Delegate: bpf@iogearbox.net Remove redundant map_push_elem callbacks with return -EOPNOTSUPP. We can directly return -EOPNOTSUPP when calling the unimplemented callbacks. Signed-off-by: Xiaomeng Zhang --- kernel/bpf/arena.c | 6 ------ kernel/bpf/helpers.c | 5 ++++- kernel/bpf/syscall.c | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 0aaefa5d6b09..7ee98aeccf3c 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -62,11 +62,6 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena) return arena ? arena->user_vm_start : 0; } -static long arena_map_push_elem(struct bpf_map *map, void *value, u64 flags) -{ - return -EOPNOTSUPP; -} - static long arena_map_pop_elem(struct bpf_map *map, void *value) { return -EOPNOTSUPP; @@ -398,7 +393,6 @@ const struct bpf_map_ops arena_map_ops = { .map_mmap = arena_map_mmap, .map_get_unmapped_area = arena_get_unmapped_area, .map_get_next_key = arena_map_get_next_key, - .map_push_elem = arena_map_push_elem, .map_pop_elem = arena_map_pop_elem, .map_lookup_elem = arena_map_lookup_elem, .map_update_elem = arena_map_update_elem, diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 0f429171de6d..000409c8308a 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -88,7 +88,10 @@ const struct bpf_func_proto bpf_map_delete_elem_proto = { BPF_CALL_3(bpf_map_push_elem, struct bpf_map *, map, void *, value, u64, flags) { - return map->ops->map_push_elem(map, value, flags); + if (map->ops->map_push_elem) + return map->ops->map_push_elem(map, value, flags); + else + return -EOPNOTSUPP; } const struct bpf_func_proto bpf_map_push_elem_proto = { diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index e6e859f71c5d..79a118ea9270 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -281,7 +281,10 @@ static int bpf_map_update_value(struct bpf_map *map, struct file *map_file, } else if (map->map_type == BPF_MAP_TYPE_QUEUE || map->map_type == BPF_MAP_TYPE_STACK || map->map_type == BPF_MAP_TYPE_BLOOM_FILTER) { - err = map->ops->map_push_elem(map, value, flags); + if (map->ops->map_push_elem) + err = map->ops->map_push_elem(map, value, flags); + else + err = -EOPNOTSUPP; } else { err = bpf_obj_pin_uptrs(map->record, value); if (!err) { From patchwork Mon Feb 17 01:41:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Zhang X-Patchwork-Id: 13976981 X-Patchwork-Delegate: bpf@iogearbox.net Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 C46B013AA2A for ; Mon, 17 Feb 2025 01:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757206; cv=none; b=o/4OH7B1SrB2yWZg4zBQVrTliiV11SFjs5CgMJqUMGorSU8QvyGSvnRRLs9k+JmZ2chmBXTtEDUrKTBg2NhBH5s/C1dRGdt/6iGQu/R8vwBCt/pUC7DNUu2PYHZ9hmulccLJ7sYXPF1BcdqCo/btq1CmjsFa90YdOjJNajbTuC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757206; c=relaxed/simple; bh=yXWt9ueL23iAUuaQ4cmRIsxa8JH3FHTsmnOVQd16CPc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nXkPlZcwmkGGAfxBc+dvqdx3bDiN0DwuI6lSZutpx9QX9GI+v5zeXmszPm7h7X9kgf1WuIuFYnGrNaNntMQg27Bw0rXb7dDlpoezR+VcxLVDla2IuPN95gd7clvPzjAHmv7ah7iPkF4Bi7boSSEfTChxgcD9VFAwpXsS516R6Xg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Yx5Dj37VVz2Fd2S; Mon, 17 Feb 2025 09:49:25 +0800 (CST) Received: from kwepemh200013.china.huawei.com (unknown [7.202.181.122]) by mail.maildlp.com (Postfix) with ESMTPS id 359B01402C7; Mon, 17 Feb 2025 09:53:17 +0800 (CST) Received: from hulk-vt.huawei.com (10.67.175.36) by kwepemh200013.china.huawei.com (7.202.181.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 17 Feb 2025 09:53:16 +0800 From: Xiaomeng Zhang To: CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH -next 3/5] bpf: Remove map_pop_elem callbacks with -EOPNOTSUPP Date: Mon, 17 Feb 2025 01:41:20 +0000 Message-ID: <20250217014122.65645-4-zhangxiaomeng13@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> References: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh200013.china.huawei.com (7.202.181.122) X-Patchwork-Delegate: bpf@iogearbox.net Remove redundant map_pop_elem callbacks with return -EOPNOTSUPP. We can directly return -EOPNOTSUPP when calling the unimplemented callbacks. Signed-off-by: Xiaomeng Zhang --- kernel/bpf/arena.c | 6 ------ kernel/bpf/bloom_filter.c | 6 ------ kernel/bpf/helpers.c | 5 ++++- kernel/bpf/syscall.c | 5 ++++- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 7ee98aeccf3c..2c95baa8ece2 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -62,11 +62,6 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena) return arena ? arena->user_vm_start : 0; } -static long arena_map_pop_elem(struct bpf_map *map, void *value) -{ - return -EOPNOTSUPP; -} - static long arena_map_delete_elem(struct bpf_map *map, void *value) { return -EOPNOTSUPP; @@ -393,7 +388,6 @@ const struct bpf_map_ops arena_map_ops = { .map_mmap = arena_map_mmap, .map_get_unmapped_area = arena_get_unmapped_area, .map_get_next_key = arena_map_get_next_key, - .map_pop_elem = arena_map_pop_elem, .map_lookup_elem = arena_map_lookup_elem, .map_update_elem = arena_map_update_elem, .map_delete_elem = arena_map_delete_elem, diff --git a/kernel/bpf/bloom_filter.c b/kernel/bpf/bloom_filter.c index 35e1ddca74d2..d8d4dd7b711d 100644 --- a/kernel/bpf/bloom_filter.c +++ b/kernel/bpf/bloom_filter.c @@ -65,11 +65,6 @@ static long bloom_map_push_elem(struct bpf_map *map, void *value, u64 flags) return 0; } -static long bloom_map_pop_elem(struct bpf_map *map, void *value) -{ - return -EOPNOTSUPP; -} - static long bloom_map_delete_elem(struct bpf_map *map, void *value) { return -EOPNOTSUPP; @@ -209,7 +204,6 @@ const struct bpf_map_ops bloom_filter_map_ops = { .map_get_next_key = bloom_map_get_next_key, .map_push_elem = bloom_map_push_elem, .map_peek_elem = bloom_map_peek_elem, - .map_pop_elem = bloom_map_pop_elem, .map_lookup_elem = bloom_map_lookup_elem, .map_update_elem = bloom_map_update_elem, .map_delete_elem = bloom_map_delete_elem, diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 000409c8308a..cb61c06155c8 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -106,7 +106,10 @@ const struct bpf_func_proto bpf_map_push_elem_proto = { BPF_CALL_2(bpf_map_pop_elem, struct bpf_map *, map, void *, value) { - return map->ops->map_pop_elem(map, value); + if (map->ops->map_pop_elem) + return map->ops->map_pop_elem(map, value); + else + return -EOPNOTSUPP; } const struct bpf_func_proto bpf_map_pop_elem_proto = { diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 79a118ea9270..c6f55283f4ff 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -2142,7 +2142,10 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr) err = -ENOTSUPP; if (map->map_type == BPF_MAP_TYPE_QUEUE || map->map_type == BPF_MAP_TYPE_STACK) { - err = map->ops->map_pop_elem(map, value); + if (map->ops->map_pop_elem) + err = map->ops->map_pop_elem(map, value); + else + err = -EOPNOTSUPP; } else if (map->map_type == BPF_MAP_TYPE_HASH || map->map_type == BPF_MAP_TYPE_PERCPU_HASH || map->map_type == BPF_MAP_TYPE_LRU_HASH || From patchwork Mon Feb 17 01:41:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Zhang X-Patchwork-Id: 13976982 X-Patchwork-Delegate: bpf@iogearbox.net Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 D3FFF143748 for ; Mon, 17 Feb 2025 01:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757208; cv=none; b=LtAP7i9dfVajwccN6Wkv+wV420iyaGDIkyH/Jq+X2M+U8faUwcVwITva1e+N8u1tehaVqd2TfIpVmClzmYByJY+Nt6dImkTJYEfe+vnQP5pD092JxSEYi/0e1JklGoP0EJRqPobp2TB84oKm2hHEVbiyjaq9G4vE5c1EVUOCWVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757208; c=relaxed/simple; bh=aoCFHOArg/5CMCvaMGgiDfp332tpZDkZXfcfflPznKs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FReBP8vnpfN8SE45zVb9H95PGA2iP/sIyvwuLW7HYn6GJJmORNeHWb/G5BRa9xpLQbJ6vhcM/vbMSwxkE4nnNtYMDVEaInkh3tSDyuj5jxdthXO6NqOFIyMnBoCdyYv4sN+29qd2ZeLjBukT3L9uXRuE0puorj/4GrOUQCKclAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Yx5F011rxzkXSL; Mon, 17 Feb 2025 09:49:40 +0800 (CST) Received: from kwepemh200013.china.huawei.com (unknown [7.202.181.122]) by mail.maildlp.com (Postfix) with ESMTPS id B4FDC1401E9; Mon, 17 Feb 2025 09:53:17 +0800 (CST) Received: from hulk-vt.huawei.com (10.67.175.36) by kwepemh200013.china.huawei.com (7.202.181.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 17 Feb 2025 09:53:17 +0800 From: Xiaomeng Zhang To: CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH -next 4/5] bpf: Remove map_delete_elem callbacks with -EOPNOTSUPP Date: Mon, 17 Feb 2025 01:41:21 +0000 Message-ID: <20250217014122.65645-5-zhangxiaomeng13@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> References: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh200013.china.huawei.com (7.202.181.122) X-Patchwork-Delegate: bpf@iogearbox.net Remove redundant map_delete_elem callbacks with return -EOPNOTSUPP. We can directly return -EOPNOTSUPP when calling the unimplemented callbacks. Signed-off-by: Xiaomeng Zhang --- kernel/bpf/arena.c | 6 ------ kernel/bpf/bloom_filter.c | 6 ------ kernel/bpf/helpers.c | 5 ++++- kernel/bpf/ringbuf.c | 7 ------- kernel/bpf/syscall.c | 5 ++++- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 2c95baa8ece2..50f07bbd33fa 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -62,11 +62,6 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena) return arena ? arena->user_vm_start : 0; } -static long arena_map_delete_elem(struct bpf_map *map, void *value) -{ - return -EOPNOTSUPP; -} - static int arena_map_get_next_key(struct bpf_map *map, void *key, void *next_key) { return -EOPNOTSUPP; @@ -390,7 +385,6 @@ const struct bpf_map_ops arena_map_ops = { .map_get_next_key = arena_map_get_next_key, .map_lookup_elem = arena_map_lookup_elem, .map_update_elem = arena_map_update_elem, - .map_delete_elem = arena_map_delete_elem, .map_check_btf = arena_map_check_btf, .map_mem_usage = arena_map_mem_usage, .map_btf_id = &bpf_arena_map_btf_ids[0], diff --git a/kernel/bpf/bloom_filter.c b/kernel/bpf/bloom_filter.c index d8d4dd7b711d..f3bba8ac2532 100644 --- a/kernel/bpf/bloom_filter.c +++ b/kernel/bpf/bloom_filter.c @@ -65,11 +65,6 @@ static long bloom_map_push_elem(struct bpf_map *map, void *value, u64 flags) return 0; } -static long bloom_map_delete_elem(struct bpf_map *map, void *value) -{ - return -EOPNOTSUPP; -} - static int bloom_map_get_next_key(struct bpf_map *map, void *key, void *next_key) { return -EOPNOTSUPP; @@ -206,7 +201,6 @@ const struct bpf_map_ops bloom_filter_map_ops = { .map_peek_elem = bloom_map_peek_elem, .map_lookup_elem = bloom_map_lookup_elem, .map_update_elem = bloom_map_update_elem, - .map_delete_elem = bloom_map_delete_elem, .map_check_btf = bloom_map_check_btf, .map_mem_usage = bloom_map_mem_usage, .map_btf_id = &bpf_bloom_map_btf_ids[0], diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index cb61c06155c8..132c2830c758 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -74,7 +74,10 @@ BPF_CALL_2(bpf_map_delete_elem, struct bpf_map *, map, void *, key) { WARN_ON_ONCE(!rcu_read_lock_held() && !rcu_read_lock_trace_held() && !rcu_read_lock_bh_held()); - return map->ops->map_delete_elem(map, key); + if (map->ops->map_delete_elem) + return map->ops->map_delete_elem(map, key); + else + return -EOPNOTSUPP; } const struct bpf_func_proto bpf_map_delete_elem_proto = { diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c index 1499d8caa9a3..e2d22f10a11f 100644 --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -247,11 +247,6 @@ static long ringbuf_map_update_elem(struct bpf_map *map, void *key, void *value, return -ENOTSUPP; } -static long ringbuf_map_delete_elem(struct bpf_map *map, void *key) -{ - return -ENOTSUPP; -} - static int ringbuf_map_get_next_key(struct bpf_map *map, void *key, void *next_key) { @@ -356,7 +351,6 @@ const struct bpf_map_ops ringbuf_map_ops = { .map_poll = ringbuf_map_poll_kern, .map_lookup_elem = ringbuf_map_lookup_elem, .map_update_elem = ringbuf_map_update_elem, - .map_delete_elem = ringbuf_map_delete_elem, .map_get_next_key = ringbuf_map_get_next_key, .map_mem_usage = ringbuf_map_mem_usage, .map_btf_id = &ringbuf_map_btf_ids[0], @@ -371,7 +365,6 @@ const struct bpf_map_ops user_ringbuf_map_ops = { .map_poll = ringbuf_map_poll_user, .map_lookup_elem = ringbuf_map_lookup_elem, .map_update_elem = ringbuf_map_update_elem, - .map_delete_elem = ringbuf_map_delete_elem, .map_get_next_key = ringbuf_map_get_next_key, .map_mem_usage = ringbuf_map_mem_usage, .map_btf_id = &user_ringbuf_map_btf_ids[0], diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index c6f55283f4ff..36eed7016da4 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1789,7 +1789,10 @@ static int map_delete_elem(union bpf_attr *attr, bpfptr_t uattr) } else if (IS_FD_PROG_ARRAY(map) || map->map_type == BPF_MAP_TYPE_STRUCT_OPS) { /* These maps require sleepable context */ - err = map->ops->map_delete_elem(map, key); + if (map->ops->map_delete_elem) + err = map->ops->map_delete_elem(map, key); + else + err = -EOPNOTSUPP; goto out; } From patchwork Mon Feb 17 01:41:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaomeng Zhang X-Patchwork-Id: 13976983 X-Patchwork-Delegate: bpf@iogearbox.net Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 1A8F813B293 for ; Mon, 17 Feb 2025 01:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757208; cv=none; b=tZBTS5o1dmZWuzhs47qYoD7rBF/2VkpSPEXyKDiNw3I7rKCywH8xda/XVaEklljPRwEs+htTRSh1NhZA7Vve0gJJ49sVAZBhtf2B6TCZA/fw9/wgmKmcGZb8lyWaDXZYWYURpZlo0IxC9WQGwnOET04Vu8QDjrzn79sE3uFGCMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739757208; c=relaxed/simple; bh=bgrxAgD4FAv8davl9VSPrFONST1pdyk5vXsqlhSmA8U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GgWwesMJfjEhW6WOzAgdNup3vidwpkQR2nwJacZxG+M5lh5+/ZhfxfgTgUV2+oaWFL7COo/vcIwqwhqb3ktv9zQezGhX671M7D2qWJ8OUfzkrnvXifhHgr7TlZ8GjDoxJnkFp/mYyuyER7X0KTjLQc9PFTM+rYUQZRhtWiTfPxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Yx5Fm22THzRs9J; Mon, 17 Feb 2025 09:50:20 +0800 (CST) Received: from kwepemh200013.china.huawei.com (unknown [7.202.181.122]) by mail.maildlp.com (Postfix) with ESMTPS id 4C1A51401E9; Mon, 17 Feb 2025 09:53:18 +0800 (CST) Received: from hulk-vt.huawei.com (10.67.175.36) by kwepemh200013.china.huawei.com (7.202.181.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 17 Feb 2025 09:53:17 +0800 From: Xiaomeng Zhang To: CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH -next 5/5] bpf: Remove map_get_next_key callbacks with -EOPNOTSUPP Date: Mon, 17 Feb 2025 01:41:22 +0000 Message-ID: <20250217014122.65645-6-zhangxiaomeng13@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> References: <20250217014122.65645-1-zhangxiaomeng13@huawei.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh200013.china.huawei.com (7.202.181.122) X-Patchwork-Delegate: bpf@iogearbox.net Remove redundant map_get_next_key callbacks with return -EOPNOTSUPP. We can directly return -EOPNOTSUPP when calling the unimplemented callbacks. Signed-off-by: Xiaomeng Zhang --- kernel/bpf/arena.c | 6 ------ kernel/bpf/bloom_filter.c | 6 ------ kernel/bpf/bpf_cgrp_storage.c | 6 ------ kernel/bpf/bpf_inode_storage.c | 7 ------- kernel/bpf/bpf_task_storage.c | 6 ------ kernel/bpf/ringbuf.c | 8 -------- kernel/bpf/syscall.c | 10 ++++++++-- 7 files changed, 8 insertions(+), 41 deletions(-) diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 50f07bbd33fa..7f37ef1b72ce 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -62,11 +62,6 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena) return arena ? arena->user_vm_start : 0; } -static int arena_map_get_next_key(struct bpf_map *map, void *key, void *next_key) -{ - return -EOPNOTSUPP; -} - static long compute_pgoff(struct bpf_arena *arena, long uaddr) { return (u32)(uaddr - (u32)arena->user_vm_start) >> PAGE_SHIFT; @@ -382,7 +377,6 @@ const struct bpf_map_ops arena_map_ops = { .map_direct_value_addr = arena_map_direct_value_addr, .map_mmap = arena_map_mmap, .map_get_unmapped_area = arena_get_unmapped_area, - .map_get_next_key = arena_map_get_next_key, .map_lookup_elem = arena_map_lookup_elem, .map_update_elem = arena_map_update_elem, .map_check_btf = arena_map_check_btf, diff --git a/kernel/bpf/bloom_filter.c b/kernel/bpf/bloom_filter.c index f3bba8ac2532..3aed40c92c26 100644 --- a/kernel/bpf/bloom_filter.c +++ b/kernel/bpf/bloom_filter.c @@ -65,11 +65,6 @@ static long bloom_map_push_elem(struct bpf_map *map, void *value, u64 flags) return 0; } -static int bloom_map_get_next_key(struct bpf_map *map, void *key, void *next_key) -{ - return -EOPNOTSUPP; -} - /* Called from syscall */ static int bloom_map_alloc_check(union bpf_attr *attr) { @@ -196,7 +191,6 @@ const struct bpf_map_ops bloom_filter_map_ops = { .map_alloc_check = bloom_map_alloc_check, .map_alloc = bloom_map_alloc, .map_free = bloom_map_free, - .map_get_next_key = bloom_map_get_next_key, .map_push_elem = bloom_map_push_elem, .map_peek_elem = bloom_map_peek_elem, .map_lookup_elem = bloom_map_lookup_elem, diff --git a/kernel/bpf/bpf_cgrp_storage.c b/kernel/bpf/bpf_cgrp_storage.c index 54ff2a85d4c0..305f23c36afc 100644 --- a/kernel/bpf/bpf_cgrp_storage.c +++ b/kernel/bpf/bpf_cgrp_storage.c @@ -141,11 +141,6 @@ static long bpf_cgrp_storage_delete_elem(struct bpf_map *map, void *key) return err; } -static int notsupp_get_next_key(struct bpf_map *map, void *key, void *next_key) -{ - return -ENOTSUPP; -} - static struct bpf_map *cgroup_storage_map_alloc(union bpf_attr *attr) { return bpf_local_storage_map_alloc(attr, &cgroup_cache, true); @@ -208,7 +203,6 @@ const struct bpf_map_ops cgrp_storage_map_ops = { .map_alloc_check = bpf_local_storage_map_alloc_check, .map_alloc = cgroup_storage_map_alloc, .map_free = cgroup_storage_map_free, - .map_get_next_key = notsupp_get_next_key, .map_lookup_elem = bpf_cgrp_storage_lookup_elem, .map_update_elem = bpf_cgrp_storage_update_elem, .map_delete_elem = bpf_cgrp_storage_delete_elem, diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c index 15a3eb9b02d9..6db158c2a42b 100644 --- a/kernel/bpf/bpf_inode_storage.c +++ b/kernel/bpf/bpf_inode_storage.c @@ -175,12 +175,6 @@ BPF_CALL_2(bpf_inode_storage_delete, return inode_storage_delete(inode, map); } -static int notsupp_get_next_key(struct bpf_map *map, void *key, - void *next_key) -{ - return -ENOTSUPP; -} - static struct bpf_map *inode_storage_map_alloc(union bpf_attr *attr) { return bpf_local_storage_map_alloc(attr, &inode_cache, false); @@ -196,7 +190,6 @@ const struct bpf_map_ops inode_storage_map_ops = { .map_alloc_check = bpf_local_storage_map_alloc_check, .map_alloc = inode_storage_map_alloc, .map_free = inode_storage_map_free, - .map_get_next_key = notsupp_get_next_key, .map_lookup_elem = bpf_fd_inode_storage_lookup_elem, .map_update_elem = bpf_fd_inode_storage_update_elem, .map_delete_elem = bpf_fd_inode_storage_delete_elem, diff --git a/kernel/bpf/bpf_task_storage.c b/kernel/bpf/bpf_task_storage.c index 1109475953c0..3bdb49aab55f 100644 --- a/kernel/bpf/bpf_task_storage.c +++ b/kernel/bpf/bpf_task_storage.c @@ -303,11 +303,6 @@ BPF_CALL_2(bpf_task_storage_delete, struct bpf_map *, map, struct task_struct *, return ret; } -static int notsupp_get_next_key(struct bpf_map *map, void *key, void *next_key) -{ - return -ENOTSUPP; -} - static struct bpf_map *task_storage_map_alloc(union bpf_attr *attr) { return bpf_local_storage_map_alloc(attr, &task_cache, true); @@ -324,7 +319,6 @@ const struct bpf_map_ops task_storage_map_ops = { .map_alloc_check = bpf_local_storage_map_alloc_check, .map_alloc = task_storage_map_alloc, .map_free = task_storage_map_free, - .map_get_next_key = notsupp_get_next_key, .map_lookup_elem = bpf_pid_task_storage_lookup_elem, .map_update_elem = bpf_pid_task_storage_update_elem, .map_delete_elem = bpf_pid_task_storage_delete_elem, diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c index e2d22f10a11f..932a6c06e3e0 100644 --- a/kernel/bpf/ringbuf.c +++ b/kernel/bpf/ringbuf.c @@ -247,12 +247,6 @@ static long ringbuf_map_update_elem(struct bpf_map *map, void *key, void *value, return -ENOTSUPP; } -static int ringbuf_map_get_next_key(struct bpf_map *map, void *key, - void *next_key) -{ - return -ENOTSUPP; -} - static int ringbuf_map_mmap_kern(struct bpf_map *map, struct vm_area_struct *vma) { struct bpf_ringbuf_map *rb_map; @@ -351,7 +345,6 @@ const struct bpf_map_ops ringbuf_map_ops = { .map_poll = ringbuf_map_poll_kern, .map_lookup_elem = ringbuf_map_lookup_elem, .map_update_elem = ringbuf_map_update_elem, - .map_get_next_key = ringbuf_map_get_next_key, .map_mem_usage = ringbuf_map_mem_usage, .map_btf_id = &ringbuf_map_btf_ids[0], }; @@ -365,7 +358,6 @@ const struct bpf_map_ops user_ringbuf_map_ops = { .map_poll = ringbuf_map_poll_user, .map_lookup_elem = ringbuf_map_lookup_elem, .map_update_elem = ringbuf_map_update_elem, - .map_get_next_key = ringbuf_map_get_next_key, .map_mem_usage = ringbuf_map_mem_usage, .map_btf_id = &user_ringbuf_map_btf_ids[0], }; diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 36eed7016da4..087abbacbd05 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1850,7 +1850,10 @@ static int map_get_next_key(union bpf_attr *attr) } rcu_read_lock(); - err = map->ops->map_get_next_key(map, key, next_key); + if (map->ops->map_get_next_key) + err = map->ops->map_get_next_key(map, key, next_key); + else + err = -EOPNOTSUPP; rcu_read_unlock(); out: if (err) @@ -2037,7 +2040,10 @@ int generic_map_lookup_batch(struct bpf_map *map, for (cp = 0; cp < max_count;) { rcu_read_lock(); - err = map->ops->map_get_next_key(map, prev_key, key); + if (map->ops->map_get_next_key) + err = map->ops->map_get_next_key(map, prev_key, key); + else + err = -EOPNOTSUPP; rcu_read_unlock(); if (err) break;