Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2611686lqp; Mon, 25 Mar 2024 04:31:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXf2Qyv0EAlVgaME+xhUsal2vgTMIfo2XZsu6jF/TT/leWESk5rP34TAvu8HaIHAaULyxirRwW6bhZBO7Q9yHCHvMLr7jaoX4KZIwuFcA== X-Google-Smtp-Source: AGHT+IHJJSiLy0ZQCgS3Xkjaja/t7wir+o8sMcej9WR6ATid6eUl9gI0k1KxqK3pl6Hq1xIJp3Je X-Received: by 2002:a17:907:720a:b0:a47:5171:8d61 with SMTP id dr10-20020a170907720a00b00a4751718d61mr2912994ejc.60.1711366280976; Mon, 25 Mar 2024 04:31:20 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kt25-20020a170906aad900b00a47355bfc97si2493209ejb.852.2024.03.25.04.31.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="uOm/jyu8"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-115621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115621-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A40FA1F366E2 for ; Mon, 25 Mar 2024 11:31:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5899634AD2F; Mon, 25 Mar 2024 02:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uOm/jyu8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C30E21E7E09; Sun, 24 Mar 2024 23:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321416; cv=none; b=isqV8TLU0e0/MtKe+3aCmp0fVGdyk+NnO8VuI8jWvGw77SRNmEmsmQynJZGHQL3NZe4dz2hQKBK2P6wJfjYP2W8FzI1d6LNjxmhFU7rbqj2PQg6Fu1ZrFBTPv7sAizxNQbUde//DAI3aVW6tPyEBLj/MT8xd+BiiC25p+4WH2ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321416; c=relaxed/simple; bh=WXJELdjmfhpY9E4BbpJkUyyeE92xfAoPZohF6gyjslc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r3rVUhoFaut3YScF/jeuFSxU6X9+RRP88u06v6uCQGBfzuM9veuiRR/+EDg0tmP3peBsyaDSfCVQmDUS2cx+g6Rtt7FRf8Z3iqTMj78n73Z6s5XpEwh+8tW1g/BSPAer89ywF3mI7cR7VpvnNzVE2CTgBzKYEiX5nq2amHBUXqw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uOm/jyu8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA94EC433A6; Sun, 24 Mar 2024 23:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321415; bh=WXJELdjmfhpY9E4BbpJkUyyeE92xfAoPZohF6gyjslc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOm/jyu8AhQNzXJVnc8T+z8C5TSBIVbPevrc8vdHONVsLjhk8gnR4t4jDYiqcCP1C 4FcTBd+WNRgIY1ao9Pp1V9bQ0i4QHgTkO6TFGpw1EEGyZFaVM5rjv1UANnjr3vRLWE AeQiFF9OToO9Dp9MbO+OZTDrdR+sqQW3WG731LXByvBjnhKe0MDUI4sVwBvebNitwD 64xS6OeeRp7Q9wzyZsZJEqGgYYv6UFCDXE/bqV1n0t12cZg7Ny53Tb8nkzCzoF0R3f X5OId9PiKIhcViAlp9QG1T5TheHleWK2+2a+vDZeBWbML76FY542ImxE9uTUTIEllR MnunQDFvISt3w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrey Grafin , Andrii Nakryiko , Yonghong Song , Hou Tao , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.6 139/638] selftest/bpf: Add map_in_maps with BPF_MAP_TYPE_PERF_EVENT_ARRAY values Date: Sun, 24 Mar 2024 18:52:56 -0400 Message-ID: <20240324230116.1348576-140-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324230116.1348576-1-sashal@kernel.org> References: <20240324230116.1348576-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Andrey Grafin [ Upstream commit 40628f9fff73adecac77a9aa390f8016724cad99 ] Check that bpf_object__load() successfully creates map_in_maps with BPF_MAP_TYPE_PERF_EVENT_ARRAY values. These changes cover fix in the previous patch "libbpf: Apply map_set_def_max_entries() for inner_maps on creation". A command line output is: - w/o fix $ sudo ./test_maps libbpf: map 'mim_array_pe': failed to create inner map: -22 libbpf: map 'mim_array_pe': failed to create: Invalid argument(-22) libbpf: failed to load object './test_map_in_map.bpf.o' Failed to load test prog - with fix $ sudo ./test_maps .. test_maps: OK, 0 SKIPPED Fixes: 646f02ffdd49 ("libbpf: Add BTF-defined map-in-map support") Signed-off-by: Andrey Grafin Signed-off-by: Andrii Nakryiko Acked-by: Yonghong Song Acked-by: Hou Tao Link: https://lore.kernel.org/bpf/20240117130619.9403-2-conquistador@yandex-team.ru Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- .../selftests/bpf/progs/test_map_in_map.c | 26 +++++++++++++++++++ tools/testing/selftests/bpf/test_maps.c | 6 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/test_map_in_map.c b/tools/testing/selftests/bpf/progs/test_map_in_map.c index f416032ba858b..b295f9b721bf8 100644 --- a/tools/testing/selftests/bpf/progs/test_map_in_map.c +++ b/tools/testing/selftests/bpf/progs/test_map_in_map.c @@ -21,6 +21,32 @@ struct { __type(value, __u32); } mim_hash SEC(".maps"); +/* The following three maps are used to test + * perf_event_array map can be an inner + * map of hash/array_of_maps. + */ +struct perf_event_array { + __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); + __type(key, __u32); + __type(value, __u32); +} inner_map0 SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS); + __uint(max_entries, 1); + __type(key, __u32); + __array(values, struct perf_event_array); +} mim_array_pe SEC(".maps") = { + .values = {&inner_map0}}; + +struct { + __uint(type, BPF_MAP_TYPE_HASH_OF_MAPS); + __uint(max_entries, 1); + __type(key, __u32); + __array(values, struct perf_event_array); +} mim_hash_pe SEC(".maps") = { + .values = {&inner_map0}}; + SEC("xdp") int xdp_mimtest0(struct xdp_md *ctx) { diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index 7fc00e423e4dd..e0dd101c9f2bd 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -1190,7 +1190,11 @@ static void test_map_in_map(void) goto out_map_in_map; } - bpf_object__load(obj); + err = bpf_object__load(obj); + if (err) { + printf("Failed to load test prog\n"); + goto out_map_in_map; + } map = bpf_object__find_map_by_name(obj, "mim_array"); if (!map) { -- 2.43.0