From patchwork Wed Dec 18 03:07:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13912979 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 705D8E77187 for ; Wed, 18 Dec 2024 03:07:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2D626B0099; Tue, 17 Dec 2024 22:07:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EDCA76B009A; Tue, 17 Dec 2024 22:07:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D567B6B009B; Tue, 17 Dec 2024 22:07:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B7AE66B0099 for ; Tue, 17 Dec 2024 22:07:56 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 40F59A0B2E for ; Wed, 18 Dec 2024 03:07:56 +0000 (UTC) X-FDA: 82906594428.12.14F06CF Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by imf10.hostedemail.com (Postfix) with ESMTP id B1B1CC0010 for ; Wed, 18 Dec 2024 03:07:40 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=k7Ne29aV; spf=pass (imf10.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.53 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=1734491259; 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=e77ZoQKvlnjPoOZm7mn9NDRKoW7hQ+ydIa8Wb5hZHHY=; b=XB00fmPUelBNUkVaCdgoAbqrB3h4K8dTvigKR8v1VeoStqY3xSAObKhK42UGhKbcIMi13c 9Jmb+npC0p/9rnjaYe2twUn1Lx3R4aunq3jDOmkeE9N3s+PHMwISlIH7o+1r9W9gvJDGfv XzhjAHSlFuse0Ox4GML6axAE3yxdt0c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734491259; a=rsa-sha256; cv=none; b=oNjFZ3NUW7v4Yt3SfZxJsFmfiqsJ0CqeU+XodQNDEPe4iGLSgkojMZS15vkOJv1poR3MhR K7LZctUGuKYk9agLeUmCBBB8yK0FYQHJ4noljY9674wJBdSzBLIIcWqx+0IDl7adL9Tgod Fc9ZMTj/sH9WLNnjB+SpiGYblUur1Ow= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=k7Ne29aV; spf=pass (imf10.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.210.53 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-71e3005916aso1066771a34.2 for ; Tue, 17 Dec 2024 19:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734491273; x=1735096073; 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=e77ZoQKvlnjPoOZm7mn9NDRKoW7hQ+ydIa8Wb5hZHHY=; b=k7Ne29aVi/8yNEdBb18uW8IEMcpvm3b4+GLXqluVveb+nrg1MZgsiWKKiMQ1LI2yM4 8ErEWMPCwpMCws3CQPN2ZL5SbmgxRjNazjxHgNGdgbwake+L1NJ9BhNyQCC4YjsSdPhn tPjGqzO1SpL3SokoVfTeIY/n8sfWhjKSupOOdnHw7UNYExyUjkzyGhMOYhl1b8sSOEPs OIzYx6WbG8FMnoE3ImFpzkciXIW3kiax1YxpEbjTorbmNRnrDrQbUajbi3S+p0ge9BOU koMvAZb4m2hVH4/LuZzPnNoKnENNjUyMFtsxj7E+6r4OpHqGaPsdOYwLOR1Ci48hGgET 63rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734491273; x=1735096073; 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=e77ZoQKvlnjPoOZm7mn9NDRKoW7hQ+ydIa8Wb5hZHHY=; b=KVTRjOqwA/7r2zxw+iGvnkVLUYcwWqgFTTgmd5pDeldL4vUuhTjRANndlYPOsRlH1Q n9SqugfJlqb3SHMdeHuljVqM90YUTga7mPSjjBjLkoo/5Yo7IyElOE+sennSokT+ulQ4 OhE9bzlPGeYltP3ab1kfeJDg0bqcnwpC4a316GfBrABN4ukICplCAmve1tUxNupd4Ibc 43rJw4f3mtjW0GGg9Zdj7cF3UXyH0UxpCfJzcxBlUhL4teV6DdWy/VUVz9X/kQaC6pNC rO+iS/7/9aZ3p7WL9+SAJMHt5aLPx82R7IaWc2GGjvAtjp2RYU2NOeJ3dSUeia44MDWJ mPwg== X-Forwarded-Encrypted: i=1; AJvYcCU4dEasZ4VhQ1R9+mbWb2TUfNfDBCt7Gy6U10rnBOttOhOPj0Mltdf2ngRm7e17sY3swjIbli2OQA==@kvack.org X-Gm-Message-State: AOJu0YxFWiyXUaY/BSDQO6n4r3B/lDst0UnqIn7/Fm/IjOXAqljsl0Jl DwYx7KDMlCu29G3SDfj1XIshEu5r9L0g4u7qJI4lqahJoGq3KgxK X-Gm-Gg: ASbGnct+eP4I7YTiplv/0PS4jR8rkKE8702T//Z80MW+NLwSfPHcy+/OhuWLutVPvDN rA3LFDhswOXi+E/M3422WTXrAu+UVbEobL1EOClszEC0cilzWUqierAnRVdA5mXkxUveufsNWxU GVfcxyF1oO2gD2TD2ta0jHwTFVVgwN33tR+a/v0Kz09yHfmVFm0XQnHdjLFJtM0tUAzpAFqI0yO dGiP04X21zaWG90vQI2/4TtYzTZNcepRSUircNYo5ooWFJ2IV1GNDRD58FsyA== X-Google-Smtp-Source: AGHT+IHi/o8gjZtYzcre/yxStX7zDbYufL6oPcWXItTfKnkU83y7CXItnrrjbp8U2xtfjDPf2FnqzQ== X-Received: by 2002:a05:6870:ff06:b0:29e:684d:2739 with SMTP id 586e51a60fabf-2a7b35c8056mr580007fac.32.1734491273379; Tue, 17 Dec 2024 19:07:53 -0800 (PST) Received: from localhost ([2a03:2880:12ff:7::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2a3d263b839sm3295077fac.14.2024.12.17.19.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 19:07:52 -0800 (PST) From: alexei.starovoitov@gmail.com 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, jannh@google.com, tj@kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH bpf-next v3 6/6] bpf: Use try_alloc_pages() to allocate pages for bpf needs. Date: Tue, 17 Dec 2024 19:07:19 -0800 Message-ID: <20241218030720.1602449-7-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241218030720.1602449-1-alexei.starovoitov@gmail.com> References: <20241218030720.1602449-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B1B1CC0010 X-Stat-Signature: 1te77omx4owutyn43fst8jf39uhr59ft X-Rspam-User: X-HE-Tag: 1734491260-459435 X-HE-Meta: U2FsdGVkX19yM3dIqZCTsGr8EOIG3Mq47Mz2agsAMEfZiK91jBMlFqq8qC8lYgfFuRP7KICWDnYOn6h2+Ovbrex7gqJmLzekeZKBoLvpNWw1l97hZLAYKbhOTlS7Jzr5ExYqoDANSS2PLVWDVHq9Kj3oOB9grhBJ128aPqqz9Z+GweCZGM4exGwPAhiE0dFrqFqvC1wCLpF0ZE3XDjmzFvZdlhEVNWQPGUB/0iJg69gLpBibqPHFrmNG/kelDn0LUSVuNLPNhHtF+gs/6BhvFichi5UP3levqOyYW5tKUAeaDQWO/6n5wLm7qVg1FOPv2MJVd4pxou4qY5mYMcJXAP6pneDz4Pti3MynPdp0Q7jv/ASk4kR+WCfoTsNnA1S/vXRdOixnnFG9ZwqV00yz3/c4gmkMgfyqsvYyfWZfOYBxAd+EuwA0RfzcvdhwBLwOszqDxp6qM4Sjbsv9TJJ7YktjpJDHyYRdNWJKsHqBybYKmmUsdWsEw9FgNOQGHhhYQKjWEYkJSdbXYXcDOYtThK7mM/QFDux3dwF6iKemcmqn41JdDP+tthxRXHZSqWJ0sjRL16F22nu5yq2a6wZ+sYk+ocR0ZyYKPnar2+CYCyhqX6QR/eViz2wZjUOeXDpWwKxNcnH+sBUJVN5mdp+gN4+4evXr5ZqW7vTbdq1FhmJ4KLR61hZHzDNH55p4rpOn43Ab7+W3SMX7K+nbJG/pawBl3OhDasSlx+miyd283j1cqQsQP6JeNtb+fw7JuPgbcg5whPasfiIs4QztrHDzA4OmdDz2FyIEiW501W4K99/lprKEOj1ik97F70bpbA0RluAAhvwqaGi0JdVVcCGsKv/6f4RLQB2jJIAtC0y3ANmNudJlvhBMDJyOwzF7Ea1oHgiG4sebwEEMSv0LKcgJWmXqisiR2Bxp1/9WOkep7sMy6wsR8K3Z86jq9UptJ0+JNeyaAU8P6GEmhWvRTiG FSxk9i6I Ul10nStOzH+ChXpBud3iMCunSzY2d/08szch5rww6dUta6/hmdpzY/FPw6FkKj2dNvjyeveGhAYZFwi74cjES/B8Fmm0QeeKUhTng4TelW3lqS+MGqHUWkFQCsezW7lNCMCach2UbFzA+TWty1+Ax74CoE36GTKXSMtpc7BoC21W7bYllrjHHGJ27GSpt2zGh5lupPSonS1n2WgjxcLnnZrUOJyelOX3WSxau5YNXoyyW0hu9Qr40hjLEnhToXe3vYz8WSMdz4aXr86tzcCPT+9mxFJIHkQlljVijthJoBHG89etHWNclKjyNv4qjCiHjuv337U/WDN4MXjIqRu2EDpap715CE2nHpEY3+NkyEGoR1xBY+RgA4JeB9g772md31fdTZxvHIXi4hqPaGzIDD1akNPiWR3m06+adc7cgkNZOhzHsxnuD19ZDWHdv9daVggNyPAsPsw0/h8EKW1avkHH2RCKw4cVHfphA5s/kQuC18ArumCiIJsy6YQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.134461, 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 4e88797fdbeb..45099d24909c 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; }