Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2556571lqp; Mon, 25 Mar 2024 02:29:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxEcmopNmQjFKFQB5l8Wu65r+g1PADti6eY/gI6MEEO2031gSzUsS3GzzdOlBYtX+qHTfwqNnhHdMUkbKGkrKBbf89pKo6dxOKuxRe+g== X-Google-Smtp-Source: AGHT+IFRtGzpyrncInEzrCQBRjixG5AzsBOcY8L1se9mzUs5uRGMi8PTaaV3NZYbaEjhtXjQe3uE X-Received: by 2002:a05:6a20:9148:b0:1a3:bd97:4cab with SMTP id x8-20020a056a20914800b001a3bd974cabmr7122915pzc.6.1711358982951; Mon, 25 Mar 2024 02:29:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711358982; cv=pass; d=google.com; s=arc-20160816; b=NBWDle1ysvaKtxvvZoGPBQqB/SjLBxUGpZ4El9dFTXa44SlCVixLZYQSaWfZfVsFA8 T3Ye8KGxjIXUwcWd1gdrBW4disGV+QQ6nM6GEX7FIs2zTUcRdLavC1aMEASWlDivQ93/ jVoSoMiDgZjgYpcN7F0EftnKkrjEu6vmSPUEUIYGvLnITXJ+wsBnBd1FwmbJVtFfnQBe IxSTxCcGPLBadlsjfzp2kq7PRY1p0SskmYb4/T65GdW26QOm5H7UlHc9J7V08Y4cJlmc svQwCexQsGvQbxrJF47JoiJDKIDUWSaiv8Zr/wvSYw1aSA83tFoUxoSqpRMgc0ZbeBPP ie3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MhkB5Nbw50YOS4t/v9Eslc9/pQ2WzaR77pMB2E7ABDM=; fh=HTBDGJ0RM+NTzncUcIwihEfvJh67r1/EXXQU0dSa+IY=; b=xvfty/mVQlL0erUol9mx1ALicQqTkya2IYyf2k9eQPnPKwU/4U7nNVuqXBS1cOVZJM IciL1qwtP946tecP8Gy7SLrjafJJKKoe0Z6FnB/Kpn5y4Isij7WQpFnETuA5pCyDCI+e 3k8wAdnJi3gzwjkRDAeQU9t1EVwTw8N/3y7OvdKz1BssOnUgszwRyPpHQoIhh4E4SvPt nTzw5h4jf9jMUNiF9Wsl0nxtRP/GABcW2W0hBozyPJVHIl7O/JjvGnhUu8vskTkAQreO qDh2kHAq+aA74wdvtlTBzc4ko7x5znhgOZIHnDxTWDb2/k7sKSHYQYE05aiQjc5pKol1 oQSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lLnqT+wi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c17-20020a634e11000000b005dc8719cdfasi7072214pgb.298.2024.03.25.02.29.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115830-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=pass header.i=@kernel.org header.s=k20201202 header.b=lLnqT+wi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115830-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 9AAF729C862 for ; Mon, 25 Mar 2024 09:29:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F8F1378C67; Mon, 25 Mar 2024 03:01:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lLnqT+wi" 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 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