Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2363678lqp; Sun, 24 Mar 2024 15:55:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsFXTdb+HRpDXuzdAFb2IccPS2OZD/wTr6TQiFwbASF7oz/5KqXdQdUOp07YXWIy9I94F2YxDQ5heyYmIMaJOzsDbavOVDSb3n+c1d8w== X-Google-Smtp-Source: AGHT+IH8T5ryRWv5HIACdLcr1Z+jfLZMSyQrRZbiw/cIED30Uu8+nb0FakGUGBE5Z1V/jqSKlrG9 X-Received: by 2002:a05:6214:2b0b:b0:696:73ef:39c8 with SMTP id jx11-20020a0562142b0b00b0069673ef39c8mr5612294qvb.57.1711320926975; Sun, 24 Mar 2024 15:55:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320926; cv=pass; d=google.com; s=arc-20160816; b=YkKap2cLRlvrQ+yEVUhrNY1kLGOIvDY61vwq1CUxjDFk4b1HNnobL6yiHqxNGysUVZ ryqlekgT1pWg6IZXnN2yRtnjGZJzhLIhghKbMJvq7wC3t5f5EOYDGS9ehl6OqqXMCvyI oKlHOUgYloN8OuwuMmDs/8DS3CwlTstmP+wqpD5n8wua1Ys5eJG6iW5H8/+/cfyUtfWB aJ7eOn12UdXAw7q0MTB6VUsy96pEYVbhg0N+qOi0931hrKJkUOsBkccU5d0mktbk880J dVA4T4j84ae1OtqDActiECUHVej2NYymFba1iPtVaYTTzR2vKx24bzBQq8SH8Zbq/oRN VwoA== 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=TxF+Z4wOQWHqKoeMB2tIcEve0CCtOQnQHZr/eI9a5lk=; fh=HTBDGJ0RM+NTzncUcIwihEfvJh67r1/EXXQU0dSa+IY=; b=NnfBpep3MbGNEFPGKc42doeZmiKlVhozv9vu+y8i9COD5BIK/ejO63yOSz7cF7B4bS zVOgX+7QxBVItP4/da+Tdo1BY4ytRZIF7z6c6Rzry9OOAEs/gTXCmwvTLL/KiM1ZvCnY ygIs2TJM8ieWVU7N1Pxwylw6P4GS3atxeX1IpnNHEMoaDlb/0tnvglxjqnVaXOUCmepc Wa8R6zWTj1M2PPvB01NczOF0epm4y59Om2GnqWxyWKtU7m1oKlftN9/QsQlhgHUZZMwl aEnf1FYqaI4fRndYUNAZveHx1Vaf6WY2MJzaXChWPGBCAkiZaZIuyIsuECEGN8ldPpsn zgpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lInKEKmH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112972-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 15-20020ad45b8f000000b00690bb1ae3fesi6723004qvp.301.2024.03.24.15.55.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112972-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lInKEKmH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112972-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112972-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A6F011C2125A for ; Sun, 24 Mar 2024 22:55:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D390212AAD7; Sun, 24 Mar 2024 22:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lInKEKmH" 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 00C4312AAC1; Sun, 24 Mar 2024 22:36:24 +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=1711319785; cv=none; b=O86Jn7EA5L3PQlxxTxEZDnzekNGD+/It3PXn/P19lZYIjgqrkCLEwulru048MNVUqzXbnOi3aGKu3Kdy5CXeNeUUl5zxM0MTCg8cavlo8tj0xk5mjXGxwXzaAcntnrUpFK+J8tJoiT8Nfxjtk6AZGSLxQNbfmOpLuwCOmaj4jh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319785; c=relaxed/simple; bh=pX8VyodF2yR/udKJM+Zj5vWSK6HknsYK0yLQhEYqcg4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lh+sAbm8y1TzI3DHyqmtKA5ln2wkpRD+2nH8BEPbI4WtHf2R8Uu3eT9HSAeDHVwwOnDUObMJCKK0CFVEiTkEzGvCRrFDwLRe2N4udQDSJoHpfX1Cu5OxugOoj/y1WLkIy3f4MSyrNydq2K8dfJwd8Bt1RCHzsL8SPBgRn9yF+BY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lInKEKmH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9022BC433C7; Sun, 24 Mar 2024 22:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319784; bh=pX8VyodF2yR/udKJM+Zj5vWSK6HknsYK0yLQhEYqcg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lInKEKmHwKX2XYr9JZ5DgYJYojgRSN9VwWEFN+RzsvGKeMNW+nWn3TKQqoZSzRt4Y KKHpRRvwQTQyqzsM3rL9MV9HbVLIoUmWmOdvCGans7QkGNw9dbep/HoDIkVXO6HVQX 3ITKdgD6PR2LPlUl6BL2eT7MCVf49bTueVVPQBGrKG8wznLB4+DxwIuyGlnmMqrhWI t8+72MBDWpsCI9lKfmBDQY52Rj93p0yaVsjDSXpVoKE9ucoWgxyNGVG6Mvyri+A29B 7QX+iP4P85JT3uglFOocvMJBeeHKPn1Y4ydqIiVBdMy14JDZBober+1Ctd9E3r91KM rMkJhCDPQkKVA== 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 085/715] libbpf: Apply map_set_def_max_entries() for inner_maps on creation Date: Sun, 24 Mar 2024 18:24:24 -0400 Message-ID: <20240324223455.1342824-86-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 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 afd09571c482b..b8b00da629071 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", @@ -5172,6 +5173,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