From patchwork Tue Dec 10 02:39:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13900699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B3D3E77180 for ; Tue, 10 Dec 2024 02:40:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A1676B00E4; Mon, 9 Dec 2024 21:40:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 102F76B00E6; Mon, 9 Dec 2024 21:40:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E715C6B00E7; Mon, 9 Dec 2024 21:40:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BD2B26B00E4 for ; Mon, 9 Dec 2024 21:40:12 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 724811A01CE for ; Tue, 10 Dec 2024 02:40:12 +0000 (UTC) X-FDA: 82877494434.24.A06F82C Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf23.hostedemail.com (Postfix) with ESMTP id 6E25F140009 for ; Tue, 10 Dec 2024 02:39:56 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Wv6xw8JN; spf=pass (imf23.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798390; a=rsa-sha256; cv=none; b=gQv8MIjuaRMvda+/x2GwXiW8PAaV8oC2qnqnLUTdTtXNNKEK6ZHYTKNCsfyFV4SCxM9R9Y cTothdcsuukc/5/YrpY+pVmHuwnJZPd/Il3dU6sQK/Es4wjQ2GlMJrMRZp+acSdItSm+/g 7Gx6o7sXLdayazf+2OrmWoHViT883OQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Wv6xw8JN; spf=pass (imf23.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798390; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uiTKIgIWEw4pjiXWRJupFp29ffG8tRf5Pk0epbA95Ok=; b=GJ58vZXYK/v6QozT8GQl1RHMe0ql6EaZZ9ctJY9auDCe/wTjMz/ApDReBb5dztfupWrwrx HMYZTaWl0n45jujRVUCKIYoM6QqXB6ov92BZp6Mhx0C1SI1HH2D4IGet/3GOY97hzqCB0j pSgHy1DA8SiKSJVCuIAQxL31Vntlkxs= Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2ef70c7efa5so2529421a91.2 for ; Mon, 09 Dec 2024 18:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733798409; x=1734403209; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uiTKIgIWEw4pjiXWRJupFp29ffG8tRf5Pk0epbA95Ok=; b=Wv6xw8JNCpBpIVgD7ooev7HESYeCf8fO+rTZVCFn8l8YfKN46zCmQ1C0qJsliRL7vH 6I8z59z3MG1ochQEnHTAmLpBGWHK3ja16JwK6d7XbvRpWy/dmd6C04gapMbM99qNn8VG 3AGWWhAkCW3kCSBW1FsaPUhKvHHUJTz4x2aBFURdP9cke+JSaSd1rCSq6jCdaV43b9Wr OR6S2XrFvThLM5OPFeI9c4LbhhMMzT6abV1OfVuppmKTvRNQUZKA9GyFdqUes+tMEqXv Fj4vniA6ZOCeE9LQghItrNRjVZvGGG8sYaPavwvRwSf0r/4muNj24O9HnJ2GU2S6Js5v sQBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798409; x=1734403209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uiTKIgIWEw4pjiXWRJupFp29ffG8tRf5Pk0epbA95Ok=; b=TCo7wix1fJsAls8KDSU/GIiDJEVkbsfq9qqffnBj3pro3Yxu8kN/yfCNUh/oeev1/E bZ1dg3iLs944BU8e590bb5OnkSi3s0xHh01icw944nq/pidAQJMxB+MFi/L8lSaHtW/F 9Yu0EyBVaSf6oIDu8rpjwTdkt4SIDz5kIUME+KW82CCqYU5HunbC7tx6efF/NWYJK/MF rCTrbAe2fBeMolo6xqdQIKEorqRxSy/Izu4aQgNa2KDTTBI/vPFK0jLtLJRd3Zrv4oP/ uGlBETZip3U4UxXBJgcmmgisqbmbyfg/KWADrfsSOSvI5AI2YcV4bGdgjBnQLKh6PFML hG9g== X-Forwarded-Encrypted: i=1; AJvYcCWF/lj/trdqnngEMx07rBly2nEBY/hnYRWNQ03FE8OyJc28cd92Eul/AMN8E+m6XLnu36txxE3p3A==@kvack.org X-Gm-Message-State: AOJu0YzZgTCC4JSEI9Tswe3Un2bDV/ni6e8x8nNS/jjtSJ0bF95bn4bw kbdDtBq7U1siSpVigE1FWsy6Iq3RhzSrzDPxyBXyFlolLjq/Uccf X-Gm-Gg: ASbGncsj3rU50+Rw68rsauDpp7b2TMEebRtmrTRixaFDqSJGXb+7KIAXwfUStbUAIu6 kp0zoGB1QHjCMwYt9F1sJWlASj1Mmreih4xJTnepXgdXNMbk4lGdTDvPrleZpRir+IotrLqh1Np PpcrgkFdtgsupCktqYm3Fj9Wdy66ZKrlnNnctqe+oKNMSUjdn6lqeiV1UcAnDbLXsNPtw20jhi8 i7WlGy4QRmnDPzq8/fFrDgs1++RmvJNCpXZIN6SOpezBRa1JOYtQylTFgqwQbBa/nBpZuDOwktm 3IWlcQ== X-Google-Smtp-Source: AGHT+IEyaw7MLXSrpLiOPJxXq3UM5b+L21nSTK6Jj0nYt9CgSbssrgPTsovcJ8e9A4v907+avThj1Q== X-Received: by 2002:a17:90b:3847:b0:2ee:c4f2:a77d with SMTP id 98e67ed59e1d1-2efcf16f547mr3957084a91.21.1733798409404; Mon, 09 Dec 2024 18:40:09 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:83b0]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ef1e920587sm8088928a91.1.2024.12.09.18.40.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Dec 2024 18:40:09 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: andrii@kernel.org, memxor@gmail.com, akpm@linux-foundation.org, peterz@infradead.org, vbabka@suse.cz, bigeasy@linutronix.de, rostedt@goodmis.org, houtao1@huawei.com, hannes@cmpxchg.org, shakeel.butt@linux.dev, mhocko@suse.com, willy@infradead.org, tglx@linutronix.de, tj@kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH bpf-next v2 6/6] bpf: Use try_alloc_pages() to allocate pages for bpf needs. Date: Mon, 9 Dec 2024 18:39:36 -0800 Message-Id: <20241210023936.46871-7-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241210023936.46871-1-alexei.starovoitov@gmail.com> References: <20241210023936.46871-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6E25F140009 X-Stat-Signature: 35csusmucw38y1yrj6tsr6j86ddfugn3 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733798396-760332 X-HE-Meta: U2FsdGVkX18oPhsFWqxiwDmz3GWyDjt6ulRw0uj+lXkVAgALDLkbDZJlohK04k9xYmHtjgStKeQYMMVf7xnin3IjUVUqv1wz8E//VM2ydNbOiDXJ0SzkKXxlzFs6Dfcf2vagZmWbHDkCNL/3DMPguZEE9OEzHqT3LAiPvqyXYDwtqZC8sN34EiukMiNQqOW+Dxr4GPkwl9zBSP80hBM01kS+4IQR8THn+NUKvW1zBM3gqwZNRR1I1kkEa1iMZfoCxAnXOZXEJA8NsKm1Wp1VJ31+IcAHHjIlqjaQKuBCf7qG+VzoaTAIvkeCwsuO/nKr+/sZT+BfNH1yU6Kku8yPfGYmc7mFjuWJLnatftZ0wnZSnqtvBFPHSFdJ5az21hbH+Qoo0MQ4/wEbZom7UzdrkxZwyVQWl6jZg4oyirCkK30CEmS7u983RQDevL96zkLJAnSZfA8OyB69BeipIIOpPGik42FE5xGCYhvxMPygyV2/m7MpFZPhw4qZy+da8rRA7DoA4tToJRR925M8fNvmZAOt/WLPLtTXW39wftdkE0njKxqSg0s8Tml57Wu9UxRlMpH6oVhNrQOO8JXcMsQIwlLsClp518nrRKEk67b8KVGGbcOuVO2doBBQD0Q434EDX6ReKzbRo0f8BUYZClRfuyQIN0sqLTTZ3Y81zepwGGfFO5fFZqGB7oLhdbvcLf4uQXbqQ5PtGJptACQ4DmZTwXmC+zHcL9rwph9dRf6slc+spi3RuICb7Zc2aGeNew3SN9n+OhXaG5kNHNBB6oak+fGOYRgPm1w8effp+/FpB4rKkiVdvY61QtmwxQNmR6wM8aIUYNI68tuXdO62iO2t7ZMIj4hX+icm9jrnc7rnL5AWdCFFmPMc0BiGxcYmhf4I7YtvaI7YfS4I5WstQWZN3V4tGtWzeD6Ma/ozFkF/XoemiOIkYFow6ik1zuzWJjsLN6LTfLArbwT3ZPnJxqe zNs4OUb/ SjlDVrGP62SjHhZ3IVxdhM4VlHRtcWNv/4qgcqsx4vgjM26Jemuuxp5Yau62EGXroqxg+VVmuRH591nNnPbgkbj0CECtdGbd86i1oVDoA+Kkf9iMLgLPmn/oiqKhnqNqwU/5s3XgFKs6lebqchMeYv/m9W1/IMJ7Infgy30lrDkXyjUmGbT8NpMAKE8EUpXtW21k/+gC6cBnZCge38Q9U2BtqD5OzmgqI6XwIRlz1T5BRnE2YhuuJw7W0eTQzD1rsvpHlmPZ+Cu1Ue5wrMnUVVsbRAlwTBKEswLRIucyNx8WyfssbxUGG38O/bNrj/oTdqN5AGKC9FX+rxWw1wWUjkxHkfXlBnzho7dXL8DqYU8KziWZhZhkeCHGnXtHaQHIF/Y5jUh79cnJymegOtQBsxqLmS3mYB2jMjTqftNk+ZibtRjvWNbHGFgprZ7Y2sdpyh4jJgl7VMZCery3F6ZNKh3TR+IhQxqhrAKKe+YKmibfXSo3C76G/au2JvQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.026570, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov Use try_alloc_pages() and free_pages_nolock() Signed-off-by: Alexei Starovoitov --- kernel/bpf/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 5684e8ce132d..70589208b545 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -582,14 +582,14 @@ int bpf_map_alloc_pages(const struct bpf_map *map, gfp_t gfp, int nid, old_memcg = set_active_memcg(memcg); #endif for (i = 0; i < nr_pages; i++) { - pg = alloc_pages_node(nid, gfp | __GFP_ACCOUNT, 0); + pg = try_alloc_pages(nid, 0); if (pg) { pages[i] = pg; continue; } for (j = 0; j < i; j++) - __free_page(pages[j]); + free_pages_nolock(pages[j], 0); ret = -ENOMEM; break; }