From patchwork Wed Jan 15 02:17:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13939764 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 CF989C02185 for ; Wed, 15 Jan 2025 02:25:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54AE7280003; Tue, 14 Jan 2025 21:25:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F8F1280001; Tue, 14 Jan 2025 21:25:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C23E280003; Tue, 14 Jan 2025 21:25:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 19971280001 for ; Tue, 14 Jan 2025 21:25:09 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C2C631C80AE for ; Wed, 15 Jan 2025 02:25:08 +0000 (UTC) X-FDA: 83008093896.15.A475988 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by imf22.hostedemail.com (Postfix) with ESMTP id D7ACDC0006 for ; Wed, 15 Jan 2025 02:25:06 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AnNzTgkN; spf=pass (imf22.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.161.47 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=1736907906; 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=6YPnFtJFai+0xFpNHgKwg1vEFPjmUMGue3EQsxvwhos=; b=kzB6MzX3olnIGm/H4F6FMgWU7bOYbBqbVnKZedG9JTTdGolppWmpZQ9li/fML8FiVI3Cip jd26UJbTmGXEMZI+g/nOlA2wm3+xtKQ5YCcYXCnffFULoJLQ4JcHpOYRZBfp6saOaYtQRa HXbCqq9SSdJ1PvO1E5SaZ9DJSK8t4SQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736907906; a=rsa-sha256; cv=none; b=3DOByXmTXBXWZtKkrHkSZlGmmxelEyyJCAp3MmGftUr4xoZlFq1jsAu+co391WgssYoNxl Gf4HRoTWC8kUl7W1JQaYa1KUcGPgYfmAfRt+0/t8Rdg3J6lik9xxzE6jt2bw1UwfFWbcgF SqdUVpyys4upIDUrQdHJSjWbJti25zU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AnNzTgkN; spf=pass (imf22.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.161.47 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5f88a93dceeso1385489eaf.2 for ; Tue, 14 Jan 2025 18:25:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736907906; x=1737512706; 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=6YPnFtJFai+0xFpNHgKwg1vEFPjmUMGue3EQsxvwhos=; b=AnNzTgkNIFVhRGBOoxTArBMSs4+mbJBZX4lusi51JQMGe7Dxl+jl//YjFemG9/HuJm kBPXlv7wyfkn7o3ZN15fcZy6Ob9ezWV9nkxDAiEWNBw1C3ZdvXTr+iwZWA5sWPjVR1+x NiG7onoWdchYVyxO0xlxd9QKUMUZGPdhZnHYQ3BuZB4/AzWmtytTAghK06YOKuEGwDdT VDstocV6LCZ6kRXFn1EKRI5ZEKM6QiuHTgRQISNK+VrJKItSRUHich184vlgKVnAQ21i 6njz41QHahjvV033MN0Nm71ZquSwsguiYI+sf0xPe6JSPDNy5tfAApJ9b8t+412gsAhO JnAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736907906; x=1737512706; 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=6YPnFtJFai+0xFpNHgKwg1vEFPjmUMGue3EQsxvwhos=; b=wGNvVzsSkeWwzG31+UsXxW0R3SLlQrr0QShjFlVtIvlFIC2FlcNAIigmZ4vAsYPjbP 6RjnyWuV7xqb6nDHaNuOpX4+mnzLuVNT2Ozu2E5J0cubWWDDYi9LVUt0Ku/6e4R4LLJY DK+Txy2xUIA2NfmmaGUoHuavIFbIIBFDduVHNFSgxBe5W8Ok4i0ul5waD3SIlumBZjfh O4CB1CPly4MDtW8/MBsFFBu23FRnO/NKBYV5C9FMxxjBMyeGKAJ9pCPXSpoLecjfQ1lK t1Tei/yMyEPPr4ohCLpIkwWZoQVYZtb2XqTB6IM4WjgjGtKJGpjFIjNC/Q2NHGfkrZY7 +xIQ== X-Forwarded-Encrypted: i=1; AJvYcCVjYXiLcIPgnbQ7Y0+3Ab4ePYq6N7NbQeQXq+qeFUrSKV6m3XsE2ADGDFoimImjWfGKj/25NREcfA==@kvack.org X-Gm-Message-State: AOJu0Yy2Uad+aRgZbpcth8opa0RL1ypEc8mfCDvuECWhCDmX/T6EyPOU G4RX2TJC4sfDIS+42jHaXYjIi9iphzNiD28Ndc0r9qOLXDFAYw9OTEEQBQ== X-Gm-Gg: ASbGncsuFg7VLvjtX9u2uf9/KhNINBBYyTnJ1nnD4yR+m1DWBx3bIX1SE2thtHfZ4gN W8AIhfQDPzHnvG5vkivaW9LN/EzH8kXv1YhB7gMfVhS5p74jI/QG3HsZ50yqTP+D0oM5OqmTxk9 3RIo1mrJLvyQ9msPnUmf0XOWynoC71S2uiqJuARwYgU4SA+xYv8kRdWvQzDzInBiFryHL0V8LVi EBYITcG0AJjeKxoncPseCA7J0UvkJZuW/Z/xNjoSGfWEH5Z73gtuQPr9J0gG549js3ViafWApOH ruY7qMY+ X-Google-Smtp-Source: AGHT+IHp8XYH01n8SuhXDCfKih1NoDPtrNmfatMAx4uMkp9I9uvhY2pzgjGZtQiUuw/WiH6P6RobmA== X-Received: by 2002:a05:6a21:789a:b0:1e1:9bea:659e with SMTP id adf61e73a8af0-1e88d3612e6mr50844644637.35.1736907505893; Tue, 14 Jan 2025 18:18:25 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:4043]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72d4056a5c3sm8349229b3a.62.2025.01.14.18.18.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Jan 2025 18:18:25 -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, jannh@google.com, tj@kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH bpf-next v5 7/7] bpf: Use try_alloc_pages() to allocate pages for bpf needs. Date: Tue, 14 Jan 2025 18:17:46 -0800 Message-Id: <20250115021746.34691-8-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250115021746.34691-1-alexei.starovoitov@gmail.com> References: <20250115021746.34691-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D7ACDC0006 X-Stat-Signature: dpwetpo4z5ei961w6c87471fi4tabmqo X-Rspam-User: X-HE-Tag: 1736907906-166386 X-HE-Meta: U2FsdGVkX19q7vMQAkXSr5yFIGxBTp2fdIGi1T1j+9ZvIb4Hxs7qgrVQGZ/nXQVSWIWWloq7qOZ44oaMOI+SpPezLo5qj57x/ohqbh0MJpMhM5EsD9vHKL0K5Z+Pw/GDLgJHiD1CWYQIbF8GCZcyH386myuQ2PNomj2ZNq+VilYgUTWZQRD+EHndzEWGIVO6VVE1rolfKSSyXYhn6jyuaw6PA/2i5W703vVFUq8uEVxWvunV/D0/+92M32wjy8PJX1PdiiX98ASqa8Yjeu1/RbrTVnF7u2jnS3GvnZvm7jw5dU605cOMTLkkoFut7bBE+Gtjuq25wnpVxjVJv5BCw872Sp5YOmD1OIKfFZahTim6l0PPSyWM1uQXhZtsu+KdPIHxbA8zk/GiB6pDrNFro/qWwhkh4kSaswP9WIymmmgKeQCAtJCzurzS0N/NzEkuXwkpKMK0DJt3/uyk5CtR2+V0DlYIrw+jW7HB0zeIZiJ3wOSMiwj2S8XvL23w29QFppreKaTQSlImbi3qITqE3RNPz/a0y9KFXQwRlYwIFMSV6ShYqQhJy6DtlKcCHJBO2Z9Z9EzHxmi0OdDzJENGYits2b9tt6dwbduhID40U3Nfj7XCgkPAwbadFSD/Lo/GIJqrjc7wXtuS3Xne18df5gUYHGy0b4j6HMnUotstegMTtR3cmhDlRTHFTGn6hwrlc1O9HV8CjcIDqYt3npbcqLU1mUrXC4bMMus7wcWN2TdgXs1Vmz9knAyUmw6sn6tE/X1CCMxYDArMVHicrPwmK84hAdhhYBU5P8UPsgGP0RSl1HzlEyfIT4upZBI5tDbFJpqfEOc53Fj5kzAeATdIRQ+LI8l4zjbzwxlei+BVDotRig4Fh+bK1rH+avZEVKPQQwobcOQzAPTV0+Pvj53liMFTXJY+TLCtvglUVfJTI5sdlOq4UGbZ8bSrRiqJkVC3yehcy4qUH/o8t/ZGiRe AWNrwrYB WJiPJAaCNJ8gBI9mWvgyafWrPpeZpIoPIBJSrBFBvs1bVahLO0tlKgdjG0SSAsN+3ia6b4GmR4hl7RBr0yjnv90xqalagM9pkhrgGQgwbfrskzPy2IvUwazFklwFTdNusl2FJ0hq/+iBK7GIV52Gx+3vkBgnd0K6gSqekoqBq8pSmQl6S12nb/28Pcg6pdqcn20F8OKWm/ckEiJa30f/hOMfXPS0UTvIsSUt6ZEsvv8miy77pxmAa0Qs1friRJn0X1NVz2LWrY0miq2i8BVPh1jZdCLcOwK31gVruXrggS2hwecti0FG+7zs7FMCsDdZx/32EizlIDk/yB8hM3PwTfXdHz5wX4Sj6BoObTzjImOb9tGroS447mpZYr2haFyKAz/24L0h2sgNpp7+JDz9Wtqxiy1bPXUj2Gwynl6mTtvnj84tFUZHV5R98rIqKuy1boS5zgQErTaYAvHlFCOJZhZrJ8RQo/c/J3wCg0zQ07gbu0oTzxIbYKXj8OQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 0daf098e3207..8bcf48e31a5a 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; }