Message ID | 20250115021746.34691-6-alexei.starovoitov@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 9EA49E77188 for <linux-mm@archiver.kernel.org>; Wed, 15 Jan 2025 02:18:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28482280003; Tue, 14 Jan 2025 21:18:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 234EA280001; Tue, 14 Jan 2025 21:18:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AFEE280003; Tue, 14 Jan 2025 21:18:20 -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 DDE28280001 for <linux-mm@kvack.org>; Tue, 14 Jan 2025 21:18:19 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9784080EF9 for <linux-mm@kvack.org>; Wed, 15 Jan 2025 02:18:19 +0000 (UTC) X-FDA: 83008076718.12.9575D96 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf06.hostedemail.com (Postfix) with ESMTP id BA2F518000B for <linux-mm@kvack.org>; Wed, 15 Jan 2025 02:18:17 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JG4VS+qL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736907497; a=rsa-sha256; cv=none; b=4AaD+B2Sdwyx1DyKv55k2TQHYsHCzvdW9JPIpW+ZoePc1LdTd1a6xkTuqtPkJCGwxyG5xD ya7htJCgTajIYGMHOU8tDw/RQyHVU+rHhTEfN6Crxw+bXz3GmmMiazMeY66fRp7u4hogvP Z37ulj8GzSRjOigjIBrxjyuSZIcEp7Q= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JG4VS+qL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736907497; 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=9FG/FEC6x+yVU1JM4G4OAfpXBrpZC0py7nMQcVE3sTc=; b=A75rpzON/zFkmGISdLtvTN1o0NUHnrWEDMlO5TztWbEsxQIpxoD0KH2lDCufj2T1ZynWEm DmvEnN61sacaIiJ4FUBS6HTStc2dqcJ6ze5t/YLEVsqUREq6txrCLf1Zvw0jOOhy26ViE4 gbs8r0c7wKEbh9eTwovdiyg5kc0wbHY= Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2ee67e9287fso10271812a91.0 for <linux-mm@kvack.org>; Tue, 14 Jan 2025 18:18:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736907496; x=1737512296; 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=9FG/FEC6x+yVU1JM4G4OAfpXBrpZC0py7nMQcVE3sTc=; b=JG4VS+qLSpJD1DWI84G792pWAkl1gcr3u8vcjWOyGVlHv0yz40tyVRNgUkWuL4iQs5 TS+MjA+Vj7+5D9Hx0t5qYIPsdun0F0fPIFjGnsGo+A0PCbiCwfhJA+SDE2g3B/ST6CyV R4xjuJdNq6AN1NlkNl6bsk8EmoFcO42geMyyapRngllIFVm0RfG88HDQHOsdNuE2/aSG f+G+Q7xL0Z7Q04kL5IPf6g9A+0KKsOA5sM5lSKLF47DI/c8QG5/LcG0w+q+EJmYREEWF cTH6dm6u65tkTXX0o/tpNFVj4yYpbQK7FCpiufVLeUd/ZLIlVZDkBCqUW05N5UTv6LC9 orJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736907496; x=1737512296; 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=9FG/FEC6x+yVU1JM4G4OAfpXBrpZC0py7nMQcVE3sTc=; b=L3CB3cWWCQaQnQw5DMr6C1D2AvkxvhZ0g0f5MPmVYnK+CKOidq9xp8NhqtGoUZ7133 LJuY4mTQ8LXKEzIHNts7Lev4puwKz8iBaG5wy0aWvSiHuFnIk1k0K10KFiqNoHqbAU0l u17Fp/+qaVBfY1BkhDhwEIB7cPxubh6NG1oGI3eKWvDe/wZEooaThMVZkNDYjI5Kc8Ev dUuCt1An6f52S4aNbUhHkcoxwcznrlKmzGSkrxT86KAdp4ZUL7eQu6YFXs79oEie/Tc7 9CMd6jZx9o5UmNA3jnOFgqtVyhF8nz2s/oihzDcBJFlMpEc5oge52ld7Fd3jaybZyojh 5urQ== X-Forwarded-Encrypted: i=1; AJvYcCVRDzLNPLddX1/gTd1oFTgSe96Ak4rRpxc3MY/UYiJ/3jimoQpPalOhn9saVsi7is4LoWbuVenVbQ==@kvack.org X-Gm-Message-State: AOJu0YynTTrQSPkUP9CsO0+c8YFpe9ntkVGHgyS0QzgBw5kBDFki9QFA zqNuCn0o9VKoJZmf28oiwKbasYCFMGWNUlTAOF/80smTBoJIOfdg X-Gm-Gg: ASbGncuPGf7/a/65YOP+ImpG9sOmhufWDtsPvCx7ky3MTgJB1TXj7nbd4zChjkd6d29 15DMS/7QXoAKzGx+H0x1ijMUrQXsgUm/XXrEkEL26GNiQXbjFnHKHFVpnR9EzVxDsxmO9jQTOgf rdFRK9kwwiZQQzWVP4mBtVyzd1TNv+stK1wGGjvV15cFNiW+K7S4bNpILo+TX1FuBE/rNiXVTZr v5VNEaZjjhT3qXXo/1q82zxCou+JLqUPLEcXiSR8g5AvyMYfE5brD+7JAdb31SLwjmbhkb1kK4l y9ZShw2o X-Google-Smtp-Source: AGHT+IHNs63EfYlrVfU/fJaiMNGL7uVjWhVVtEL4nC7WmO69hxtGaNlrKdUTNVZudJVLwEfNIUiYFQ== X-Received: by 2002:a17:90b:2f45:b0:2ef:2f49:7d7f with SMTP id 98e67ed59e1d1-2f548ece7afmr43528398a91.18.1736907496611; Tue, 14 Jan 2025 18:18:16 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:4043]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f72c157a09sm231999a91.8.2025.01.14.18.18.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Jan 2025 18:18:16 -0800 (PST) From: Alexei Starovoitov <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 v5 5/7] mm, bpf: Use memcg in try_alloc_pages(). Date: Tue, 14 Jan 2025 18:17:44 -0800 Message-Id: <20250115021746.34691-6-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 Content-Transfer-Encoding: 8bit X-Stat-Signature: uweyqg6hfgtj3z4o3gc3p36zeiwgqxfj X-Rspam-User: X-Rspamd-Queue-Id: BA2F518000B X-Rspamd-Server: rspam08 X-HE-Tag: 1736907497-902736 X-HE-Meta: U2FsdGVkX18O4iQgyHLLYm2P2Z92Iwk5JWfEc2tqVHMowwWsVUkNEyO12DGvqKimbris/7qNu7Ftfy1moQpLS08HEp87xg/a8qLaUQltuyv3oviFY1Xrp3NLn5lCGuonLcGw7ja/Yu6415O5yuQsvgz/JXgpP8B1Y2YPEeBIv4iqZ9jr3piTYF6URyruqI4X8k9+dUt/TBgGc61MtfaylyPIM2xddkeuk9o+0tF6HgSvLkOFsGCWMpQTPilN57r+ePKIlCUqcwDNfzQMrOnJOh0qJsszHbQhC3vpgzIMd5ULf9Va8HhDQjX6qbPOrm6p7pthNDVNNQj2cgwQ1AZ4F17BOFX0odpVP3/cLSNGnxb4FN7SVMFNcBNNW9Wo56RSERlOc2fVPAYQ3afNADgUJbS7HEzOfnYoGVKPN0s1PlwXettE5V+JtIJcVhyyGTQMEc79Sxo9yBcOJSfks2KcCiRDoRC96reJnUXgItMA1Wujw80qX/benbx2x+uEjmPkmoUsvxBlqGDtkQH8ZzmW35Bj0uIW2It08gzs3gi+gOCsE8EWn2wyTPdzzRhQQFKVDR79pD/djHK6tfXauaWLYQxp4lD1STdIB493j0L/C/WdPnJeaGnsx2Fg4W257SdUEIH1GD15Cd6GGjbrBqWtNfIaWOEn3P/ZWMUsU6iAbgJNTndIqm3oGlzqu2KrttVJAI8b0gC5jdc+Nn69I83+/QhiF24S9wqaLGPZsKkprTr7SXjSr8+UP4x3634XO13O+zuQEhuiKM5jKr0NAZY5h5bqk2uMz1Cp1KreFpt4Ue69PkUwYkRn7V9Z1+mplFGpfv0ZxFI7fnsd+bb0owIZpCukgh9PYYQrO5Yz2964c8MOKmuc4N+gB8+pugo8NL+mqFe/u+Wq7nFRsLziQ3ObAYuRIoI0Traen/sQ4glFYzMZMg+AtwNLUPne1Th4X3roIClA/F/vKRkegCfqOMK tg8bPNGe nJyJFSTGhRSShAKe1Wrn8LNAyxDwl+TjGkbcO6/nBTyVx+oiNAEz5nK9lBFK9QOVT7MgmyNCB9T0qTBXU39L2WTaH9ANtm82IrB0w0vtZJyownEOYOkU7qCbrf2yCgqNYHJWK4yrrNbFZSlykCqIgFNQa8p+iS+OXyMpZdDdq9Tw3JUEjDQU/VfCzUGee0Rufkrir8xt9zSf9IGUs6/fApVj2oGTUXkgQ3MHOKKFPdvOOqW3a2DsFcbJpxLCzKkd4nhK9Ob90tjhjvMMc3/BaiDdPXfnPWDRd1srstIE3FMqVB9Fb6aVvT2hroN5ygaco83rfnfcHQshH0WRVbIdA7EACKKusCR+Gd1mIPsBL3rYyI4NnhAYNKOLIBwBDsEy7Pf1rL2W+clcun4MqyKvWWqhd1dgBcuTwqUu7B3h/POrFB9rikDYfWy++9RMlKmvzzhXzu4vuSxu8SRdBdm45trxDNzVMuzJNzq+vfem86XqakyxmylK6vxdK7g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000092, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
bpf, mm: Introduce try_alloc_pages()
|
expand
|
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a9c639e3db91..c87fd6cc3909 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7131,7 +7131,8 @@ struct page *try_alloc_pages_noprof(int nid, unsigned int order) * specify it here to highlight that try_alloc_pages() * doesn't want to deplete reserves. */ - gfp_t alloc_gfp = __GFP_NOWARN | __GFP_ZERO | __GFP_NOMEMALLOC; + gfp_t alloc_gfp = __GFP_NOWARN | __GFP_ZERO | __GFP_NOMEMALLOC + | __GFP_ACCOUNT; unsigned int alloc_flags = ALLOC_TRYLOCK; struct alloc_context ac = { }; struct page *page; @@ -7174,6 +7175,11 @@ struct page *try_alloc_pages_noprof(int nid, unsigned int order) /* Unlike regular alloc_pages() there is no __alloc_pages_slowpath(). */ + if (memcg_kmem_online() && page && + unlikely(__memcg_kmem_charge_page(page, alloc_gfp, order) != 0)) { + free_pages_nolock(page, order); + page = NULL; + } trace_mm_page_alloc(page, order, alloc_gfp, ac.migratetype); kmsan_alloc_page(page, order, alloc_gfp); return page;