From mboxrd@z Thu Jan 1 00:00:00 1970 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 B7D16145B2C; Sun, 24 Mar 2024 23:13:49 +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=1711322030; cv=none; b=CAGJUhx1lW9seO8ElDdy9jYyXE+AbEi0KoHQm5pFHuje0ULSKCdtCVnwWOZnrSRhE7/IGHdOQ7PZJmeqq0wQTjmeNUkROc24MjXZAtnpCbPXnYatEgxTRjMQc55E7taNRQ8OKh6WG0m3BxYabO59AlpvZJvYzfbfWxay3TejhTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322030; c=relaxed/simple; bh=NyPwPnV3tRxSLBf5Rdd6hqsddZMu5hwDMK4gpLucHkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uzwSNcq+mcimaE/cqQ+ypzegLrm46fYiT4dSdFP74U+naeqzzOjwP4u6O7l+U5Y1416tfi0G2BT8R/tiuHKp/FP7T8aB07hk4WDDig88OVyu4j3z1qkauy548B2jR274HhbN+PFVwIGtATWprjZ46JtIcToRFE4+ZPy8Rn9nGUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lLnqT+wi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lLnqT+wi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC5CEC43399; Sun, 24 Mar 2024 23:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322029; bh=NyPwPnV3tRxSLBf5Rdd6hqsddZMu5hwDMK4gpLucHkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lLnqT+wiakqp20JWwBgP2sUi+4fUAWkx/LY0Uj/XZRc8tL21+q49VdyAhuxwknoGc efFjKsQr3LVYe6L19xcvlzX25q/T97Z66/4NDpTU0Skoqbux/vkhX1iDqLnbF9drmk Hk0ALvWIpmgURBPVYQZ1sQ8W9/RK0epE/mlyVwVozBoGzMqRzumc5Ma57TzBFQOcpu eruUgC8rSzwthbd0vDBHr3No0IE5lMBPOVjVrT41BN2DepH9I2S6IXIdqsLRHZdhjI eunVZzksOuaUw1cYJjVJ+E8Kx06MyQd87u+g839HnzdhG5OR3YsE+kmbaWw1SHuk2U 0oemXCs2VhO0A== 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.1 101/451] libbpf: Apply map_set_def_max_entries() for inner_maps on creation Date: Sun, 24 Mar 2024 19:06:17 -0400 Message-ID: <20240324231207.1351418-102-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 f04deb90e516e8e48bf8693397529bc942a9e80b ] This patch allows to auto create BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_HASH_OF_MAPS with values of BPF_MAP_TYPE_PERF_EVENT_ARRAY by bpf_object__load(). Previous behaviour created a zero filled btf_map_def for inner maps and tried to use it for a map creation but the linux kernel forbids to create a BPF_MAP_TYPE_PERF_EVENT_ARRAY map with max_entries=0. 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-1-conquistador@yandex-team.ru Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e2014b1250ea2..c71d4d0f5c6f3 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -70,6 +70,7 @@ static struct bpf_map *bpf_object__add_map(struct bpf_object *obj); static bool prog_is_subprog(const struct bpf_object *obj, const struct bpf_program *prog); +static int map_set_def_max_entries(struct bpf_map *map); static const char * const attach_type_name[] = { [BPF_CGROUP_INET_INGRESS] = "cgroup_inet_ingress", @@ -4992,6 +4993,9 @@ static int bpf_object__create_map(struct bpf_object *obj, struct bpf_map *map, b if (bpf_map_type__is_map_in_map(def->type)) { if (map->inner_map) { + err = map_set_def_max_entries(map->inner_map); + if (err) + return err; err = bpf_object__create_map(obj, map->inner_map, true); if (err) { pr_warn("map '%s': failed to create inner map: %d\n", -- 2.43.0