Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2367324lqp; Sun, 24 Mar 2024 16:05:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUh2+eWluXiUkEPIFQ3AflA2ZbtPKPCgVT0lGYlaPk3+GFa9lchV6gDza5AFKz/G0T1otcstEwOvCuMnncsO9PepTddzEwLHuNOr48JBQ== X-Google-Smtp-Source: AGHT+IEWNub+zDFdFxMj0RP1xH9ocGZsOs5ts/35tVIlF2m+xxWxnmuYpgqig/avRVfjQrxcTJRk X-Received: by 2002:a05:6870:700d:b0:229:fb04:2496 with SMTP id u13-20020a056870700d00b00229fb042496mr6149407oae.52.1711321522693; Sun, 24 Mar 2024 16:05:22 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p38-20020a634f66000000b005cd88161d2fsi6489223pgl.694.2024.03.24.16.05.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:05:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=BmDYf7gw; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-112973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112973-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BB77BB23A9B for ; Sun, 24 Mar 2024 22:55:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8F5312B143; Sun, 24 Mar 2024 22:36:27 +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="BmDYf7gw" 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 9F0C512AAE4; Sun, 24 Mar 2024 22:36:25 +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=1711319786; cv=none; b=IhLKhSCso1lPOy8iI3/hvfZdO3ScgBQshoTB50Dyn9BElo9IYXmjI/V87BD75Rx4q3W+414UzERER+llD9Jqb79x3j5qMAmZaef/wGs7YUqJd514+Q6L2x/ulFcnHZ7AQDOg8ZbMqFgDTOx4DjZxan2cWcxLhSA9dMUhQuM4uo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319786; c=relaxed/simple; bh=xK0i92mfHWjtbHuvvYSsqP6XNXzKzuRNT/nlSFXVJtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hII44sqdZdTBxP6ZyIvNQziOU5XZ97UfbOSkccQyMUykcmcQtmHGu+8POXXxVaivd1v9a4ZnNLiKOrcQiw+vGOJ9PYq7RzRkxjzYt3j81RRmil0IExZ4WxHfa6TFjK8Fmp2zXQMmuVIbFT4rlrvVb2NZLR6CEXpewmbB+Q81X40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BmDYf7gw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB621C433F1; Sun, 24 Mar 2024 22:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319785; bh=xK0i92mfHWjtbHuvvYSsqP6XNXzKzuRNT/nlSFXVJtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmDYf7gwqcHendEvHWHyzcE0Ic/HonxL4CfQndx9K05wW5POJpaIchDvT+6OdRIuV +HHcF67FyWIcJADd7KtoezzvHkFrqeAfrDtG+KlGfu6ur/z32wXdu6whYAuDWf6Eo6 GN+kaJk8cm94ff/SQzR+/SdmUWWThbxqM8tKmPdZ7UCS4D46c+HeeKyAr4sVZqpWbg TJvUDqv15468HQCDMwizPZG/KxSpZTto9ueMdPUgI2aXhox6BHcRb8UUOLhevZodOw VGAK20tw4l8gzIkUzJydtPUNMr4WkuLmGLLgJPbz8FhdvJ9iirCmNrTOWl0XyjsGVx 7WspQ3Nspt9MA== 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.8 086/715] selftest/bpf: Add map_in_maps with BPF_MAP_TYPE_PERF_EVENT_ARRAY values Date: Sun, 24 Mar 2024 18:24:25 -0400 Message-ID: <20240324223455.1342824-87-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 767e0693df106..dfbab214f4d1c 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