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 E9BE1569B for ; Thu, 15 Dec 2022 18:13:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63370C433D2; Thu, 15 Dec 2022 18:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1671128014; bh=LmXO+w8lxg4PxS27ws8bcX65p0aXeu40GsDw4SIwn1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tKF6FfJykBLch45SuRusnlEIIf0xeGM+ZGpsl5lP+taurRWR4mtTG0fQbwUsyy4xU jOlK39pYYXWfNE94jt852b0+hZrjADQ357/hfsjjulNMoZJgG/dKodlIHjzONPqm+E F2bdZNI11DcaDyh4ekXuvuNG/RrGlJMyzEhAGBPo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hou Tao , Andrii Nakryiko , Sasha Levin Subject: [PATCH 6.0 09/16] libbpf: Use page size as max_entries when probing ring buffer map Date: Thu, 15 Dec 2022 19:10:53 +0100 Message-Id: <20221215172908.561768558@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221215172908.162858817@linuxfoundation.org> References: <20221215172908.162858817@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Hou Tao [ Upstream commit 689eb2f1ba46b4b02195ac2a71c55b96d619ebf8 ] Using page size as max_entries when probing ring buffer map, else the probe may fail on host with 64KB page size (e.g., an ARM64 host). After the fix, the output of "bpftool feature" on above host will be correct. Before : eBPF map_type ringbuf is NOT available eBPF map_type user_ringbuf is NOT available After : eBPF map_type ringbuf is available eBPF map_type user_ringbuf is available Signed-off-by: Hou Tao Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20221116072351.1168938-2-houtao@huaweicloud.com Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf_probes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c index 6d495656f554..29f7cde10741 100644 --- a/tools/lib/bpf/libbpf_probes.c +++ b/tools/lib/bpf/libbpf_probes.c @@ -233,7 +233,7 @@ static int probe_map_create(enum bpf_map_type map_type) case BPF_MAP_TYPE_RINGBUF: key_size = 0; value_size = 0; - max_entries = 4096; + max_entries = sysconf(_SC_PAGE_SIZE); break; case BPF_MAP_TYPE_STRUCT_OPS: /* we'll get -ENOTSUPP for invalid BTF type ID for struct_ops */ -- 2.35.1