Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2601284lqp; Mon, 25 Mar 2024 04:10:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnGkOLSo//7HraVBcecA1EXV15vZ/pfX1PYauDGvZ/IBe+O+00gZEDr7Ww667ZLNaOrHKDOG33/6unqqtoKDPz7++x9YteozMNkj/GVA== X-Google-Smtp-Source: AGHT+IFFfwRxBMmw9mT5ZTDD52jwqr0uXXe3l+GudC8cxpMcZ8SBnqgB7AlIxe6uRzsqQ2hQ1dNr X-Received: by 2002:a05:6a00:2305:b0:6ea:7486:84ac with SMTP id h5-20020a056a00230500b006ea748684acmr7362924pfh.4.1711365050591; Mon, 25 Mar 2024 04:10:50 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bv67-20020a632e46000000b005e84c73a015si7078591pgb.766.2024.03.25.04.10.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=Pczxqz1K; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-115418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115418-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B7EEC2C3CBB for ; Mon, 25 Mar 2024 10:53:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CB7D2081C5; Mon, 25 Mar 2024 02:36:56 +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="Pczxqz1K" 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 811FD82D8C; Sun, 24 Mar 2024 22:49:56 +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=1711320597; cv=none; b=sBReYwhFm2bQwwh5o38pDgMQy+6Y0SJCsX3yQKwz2a9FQJnxpZlwncOJ1k+W3lsVzhzV6anMDxillx7Qe+OJGeylaynY3srIxfYF9SrkdOqb8Z4CxFlkBM2LTkilunBtU/AyU1kNgrLyujXKcb4DpJNj4iF2Fd56SIpV42OySp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320597; c=relaxed/simple; bh=WXJELdjmfhpY9E4BbpJkUyyeE92xfAoPZohF6gyjslc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QVQ+CLVTUziHMH9etM9FJW127mQwBM1Dzw9PRoUHsyRJPcpxig+WFtKu2dqpMx4z/XS1x1EMKKJ+qzyLHJnKKkgVq8LrtlvL0c+dB+vYEwCLEE0Xz1PoWFfUWkIME4JK6zJqRzV+U0pS97JCbPol+lYGqH4MRuoZ7Xrrb6Qbik8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pczxqz1K; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CDF4C43394; Sun, 24 Mar 2024 22:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320596; bh=WXJELdjmfhpY9E4BbpJkUyyeE92xfAoPZohF6gyjslc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pczxqz1Kf7i/2a1cFhn5kQhtK9X77ncWYYGfLrHxTkjteykakubpyTjybiSMla6aG PgqU8il4aVZUmlXX9OiFgEhOqOX3k5JOBKAhGmc3Y6rKFJU0FyLX9K3SYT9khPieTO 4UtKDbh6qdfom1Ovs9IZNUQvO5UYYd70oZOh8bkVVQcL/OT/bE3KivjS1jOWS6DQK3 btajftCJk6mIozaOgFfR7xhElSq2YyApMVnJgQcKFd7msQB81Sv05eSj5+VI6uEmUm w8tjEl39cyI+0LuCklWGulzw0lAIB84I+dt7r71ShZZkOSWDetdcInvdSl9h06EbvW LliO4ECQPKvCw== 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.7 157/713] selftest/bpf: Add map_in_maps with BPF_MAP_TYPE_PERF_EVENT_ARRAY values Date: Sun, 24 Mar 2024 18:38:03 -0400 Message-ID: <20240324224720.1345309-158-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-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