Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2380459lqp; Sun, 24 Mar 2024 16:51:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUoMq9QL7eDzV0tP3HTdZ38lEwC6JsewJNkp2Qdt/y63LOI8WQ7XRLFYh6MdFi96PBIzECIhVrJhgNtJoizbYaNfAPlTcjDYaRIGBXS9A== X-Google-Smtp-Source: AGHT+IF21/g7wWw1ktsj5Xqp3xYLPhYiq8323WGfSXjVcEwxi16fVLmR4IPeloBaaITYu6s3eSMF X-Received: by 2002:a50:d5d1:0:b0:568:d6a2:716 with SMTP id g17-20020a50d5d1000000b00568d6a20716mr4514383edj.7.1711324304340; Sun, 24 Mar 2024 16:51:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324304; cv=pass; d=google.com; s=arc-20160816; b=OA/+Bof6qzfMNCbnYLO4KPI3V0b2NoGa2tl+RWXmgTfefLVC8Mhds/uv3Lt9YrLTev buglfILWCuFb8mKneKAWRsX/G6qa/0ktVITM5u+F9V25Y6Vecgo3ZO3dSlW2ySk/wiCa KfGARjl0wfCcfxMyqXhoFKIvb6QqO337dmt4JGxl/JGBtZ1gzyR4+2jx5xnlOiS4+BRj ke6245oeIladJ1kpQcFgQ6kKVXb3A/OzvgC7p03r1/q4LotQM+5iPIHdOocgsP2e1Xnu Z2qaDEso1VjVr5ApYvt5X/xV/g2Lm5j9RxHSSUj5Bz6WIJf4VnKf36C+XLEwMwlhdybu 43LQ== 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=uKZBlddnEhC3c5NhqQvPJMLjX1s1neeOLsokjDPpaNM=; fh=dZWiIe61AhqHwyQeYFfF+FZpJ0C2H1pqZaRRmR1xtMM=; b=GDvEpcxMwKHJlewX+TDUujMD4TJZK6uXWWNLIXXrxjJLwkEgm5S4SiBnG2PKHkhBOD AW7F8urpsXWVPwDED/pn8Ps/yjDGz6c87r6Ly4uI7AV6pNOYFqg04FuYvob8CtgInnZQ 2gx+Azm30X1elTIO8wDlQHs+XHJNRH5DEiEhLjOoXcCv/YSOO5BnHPsiBpXriby6H1vl sTUSsTopavThe1nHuL4xk+dx0avHIRciasRs4avLy3o++28h3YbGyTgARVxIb4+awIJG TMPJVqMBJE6YHFmHuVgJL5+XeLtL0hod3PfuTbFDQVKrrp4E2NXevRGOB6TOc3kFeUd9 lKPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K4sQJZML; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113237-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113237-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d2-20020aa7d5c2000000b0056bf3369081si2067500eds.535.2024.03.24.16.51.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:51:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113237-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K4sQJZML; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113237-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113237-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AEB7C1F220D6 for ; Sun, 24 Mar 2024 23:51:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46D9C1327FD; Sun, 24 Mar 2024 22:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K4sQJZML" 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 2A5DB5D74C; Sun, 24 Mar 2024 22:40:38 +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=1711320038; cv=none; b=keWVa1IUzLB02PnQ8fK68mkiwM/lhUhatDxUxkDxg9hL7waoAS0MGV2Dj9laEE5Mmh8rwjBtLRFw55L8uT8jJXX0miztWfkf/mQK2RuIyOxp5Dr4ddF6RhK831Ohfm8fsJsgL8shbX8mvr5KguINqXXRxELNQtUQ8TNK0TyNQxc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320038; c=relaxed/simple; bh=Hf/0iSxlOyzs7Gvuy/xTK00B0B5wdp+9ZWqBR3qUq8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kg0Wqdqn4FVOWiWlh1qhtQVDFghU2szVVK57LNsdkix6I65KtmMu4884rKrxvO57m4xjR3xVeJGYA7lBOM43tr0HYNWt9J4lxrJS2jiGDBO5Rw8I/ZQcaf5LYE47ei70QLCu7idYZw5sRf8hUE0sld5hfPgSctNGCFb5q5I69P8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K4sQJZML; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C6EC433C7; Sun, 24 Mar 2024 22:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320038; bh=Hf/0iSxlOyzs7Gvuy/xTK00B0B5wdp+9ZWqBR3qUq8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K4sQJZMLhGgM4vowtTq7J3L217VGbc3cj1HslyNTh+Bzrc5Z0imcAKVCMGZnM2LW9 MkFXAF9OfzBdz+RxUNhoDdgUDHfWw11iRnZwRA5WJFqfIZ48D+Z++UzUrBrDFRgj3C N1mTICu2HCLLdZYG8tz7Tr1ftIwM2WIRC1d3H8iSgG2JWgaOobOs0uVy+D3wqUzLhO 8YRCWhF2wGvALRD5yy//5D7mdJHyvMjTJKi1knsqQNx8VJzhfnw7wVm4rfC+FGiH0M LleuC1dmFwTingPH+GMNCEwwsAIGGmtW+G+3khNMAoj4kNtbeB+Nv9hwYYCf7ep+Jv to+zKl/3PDX/A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Puranjay Mohan , "kernelci.org bot" , kernel test robot , Song Liu , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.8 346/715] bpf: hardcode BPF_PROG_PACK_SIZE to 2MB * num_possible_nodes() Date: Sun, 24 Mar 2024 18:28:45 -0400 Message-ID: <20240324223455.1342824-347-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: Puranjay Mohan [ Upstream commit d6170e4aaf86424c24ce06e355b4573daa891b17 ] On some architectures like ARM64, PMD_SIZE can be really large in some configurations. Like with CONFIG_ARM64_64K_PAGES=y the PMD_SIZE is 512MB. Use 2MB * num_possible_nodes() as the size for allocations done through the prog pack allocator. On most architectures, PMD_SIZE will be equal to 2MB in case of 4KB pages and will be greater than 2MB for bigger page sizes. Fixes: ea2babac63d4 ("bpf: Simplify bpf_prog_pack_[size|mask]") Reported-by: "kernelci.org bot" Closes: https://lore.kernel.org/all/7e216c88-77ee-47b8-becc-a0f780868d3c@sirena.org.uk/ Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202403092219.dhgcuz2G-lkp@intel.com/ Suggested-by: Song Liu Signed-off-by: Puranjay Mohan Message-ID: <20240311122722.86232-1-puranjay12@gmail.com> Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- kernel/bpf/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index ea6843be2616c..026627226ec48 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -888,7 +888,12 @@ static LIST_HEAD(pack_list); * CONFIG_MMU=n. Use PAGE_SIZE in these cases. */ #ifdef PMD_SIZE -#define BPF_PROG_PACK_SIZE (PMD_SIZE * num_possible_nodes()) +/* PMD_SIZE is really big for some archs. It doesn't make sense to + * reserve too much memory in one allocation. Hardcode BPF_PROG_PACK_SIZE to + * 2MiB * num_possible_nodes(). On most architectures PMD_SIZE will be + * greater than or equal to 2MB. + */ +#define BPF_PROG_PACK_SIZE (SZ_2M * num_possible_nodes()) #else #define BPF_PROG_PACK_SIZE PAGE_SIZE #endif -- 2.43.0