Message ID | 20250114021922.92609-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 14B96C02183 for <linux-mm@archiver.kernel.org>; Tue, 14 Jan 2025 02:19:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C7F3280006; Mon, 13 Jan 2025 21:19:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97751280002; Mon, 13 Jan 2025 21:19:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F114280006; Mon, 13 Jan 2025 21:19:58 -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 5F124280002 for <linux-mm@kvack.org>; Mon, 13 Jan 2025 21:19:58 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1A3381A05B9 for <linux-mm@kvack.org>; Tue, 14 Jan 2025 02:19:58 +0000 (UTC) X-FDA: 83004452076.28.3504682 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf02.hostedemail.com (Postfix) with ESMTP id 416C980009 for <linux-mm@kvack.org>; Tue, 14 Jan 2025 02:19:56 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jFzjlOza; spf=pass (imf02.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.175 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=1736821196; 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=ygT/gYIDC88MbRDeBH2BI6HaB56L95edS8LxJJawsPI=; b=kkjQMLhKjYUV5tFffm56q8P7COCUIhQMP7ToPpb0e1GJMg188P00FpOk96oFjsgWBSL4Qu MUoeoNXuVGPuY52rQMpScu0BKx4SIKg+eR7CrVh0Nzn2fTMsA2VuMsSNaXtwM1aqD+Zf+D +62/reijbzdpWloOcMdnhI3LQqzP+q0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jFzjlOza; spf=pass (imf02.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.175 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=1736821196; a=rsa-sha256; cv=none; b=sNDcl2M+DO2PzIY/8NVHPpUAk1BZws+w4Xr2ofmdMHgUrS3GEbtuCLlR6y0W2J8oXRAX13 Yq1xMJfy9s1Zsw/lPpvi+EOh8P1I8Z7ff9RZBNK6XpYTgTb97i/W/1uzFLouCQXbX0mf0f J5OYV/SUT/g+A8MqZj3VAvOjryRJcoo= Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2166360285dso86649865ad.1 for <linux-mm@kvack.org>; Mon, 13 Jan 2025 18:19:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736821195; x=1737425995; 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=ygT/gYIDC88MbRDeBH2BI6HaB56L95edS8LxJJawsPI=; b=jFzjlOzaU68H+quU0yRm+cx5zMN1F5871DoBbphu7t9JIecrzMlXCj/blI1Kulstug L3GngetX6ertKg7XnSbTotRITxtjMCMVv6gw6NYcBSQcM7gdwynUQEJajdSo6SnWxmiK BGW7xQauBOiGd/3Ab5uBVffYXDRb86boC4Oqm7PXYcbLLr0i7beE8Lh3WUgEXXMWBGIq VkA90vhlJTZu9Sp/XO1rFBbVxpITma065KGDNZ+syJzkYKZvtIUUGYfCvPZCpXNcYyyi Ia2PFIKvW/k/4FTsdneqvzD71ENnI9TGOtRn2TEBaqDRtKBAkJkxEgB6nB7LMAV5QL0w unqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736821195; x=1737425995; 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=ygT/gYIDC88MbRDeBH2BI6HaB56L95edS8LxJJawsPI=; b=fOiE//GKnXo6ziV04lZxj5TUR30tb1ys3gJoKfnqKw2hOtkoOOZrKAPfI/ZJl3Y5Aj lsMxwfqvujqUg0kxLFjxl0UfolKiAR5GtqArzabe+4ExlniDMC0y+5ewYOlsgMwcDwUN A7s9WJ9zjVCMDiqBtmK/WqWU4+iSJHC4MLVdWbJ76MQ7y6xx+Xcahl9Z+gsDu2Wwx5NZ kOEHwRFJKSiBGSzO99Hcs/zDjDzh3t0QxcrzwPcimAoPKsGy8r8q+V+SuVOIDZJFoodj mthN7PitPMh2eDkCPyFDBdGb2OnnyG5kB2no7i/nUYdvRDHrPn/WxzaARHooe6z3rOTg IJwg== X-Forwarded-Encrypted: i=1; AJvYcCVX/ql/RcCcbc70xiYJpm1+PHUwjrhHYEld4u7v2moEmY5em+GoqyK7S6NLsWtn6x8+gJspU90+xg==@kvack.org X-Gm-Message-State: AOJu0YyYYQV7UNeIb4NYsAvDmaXaZMWlq5EEPToOXI6gqRb7tHR8uE+N 5sCatMAGf1N485a9uSghcDBNyPzpvze5UHiARszILTKodkgPseFn X-Gm-Gg: ASbGncsc6mo7MZopvxP0BRJYihXCXL6I/xqqUb0/3UHlFMZWdw9yQtK/rH0tXIw1BsF wilGnHUISpFCGiYmKTeeO141pxnLsta7VDHbwpCI6iEPO2T/7+7EPKUksvIzo7DIdL5qc4F6bbL B2VLGPXlZ8yJY3bqUevFls8jLbsxj3clKoHbWIjVRXB2QgjuL48jbIMOX9Xsqu+5HuQeN98gX/L Yx1nmO+k5Jt7760pmp1DnsyAyD5+W2U9LfZDY4t4t9DZqpjvJyRwUkMRktLNBGvlxuPBPvBk3GE iqeKRiA9 X-Google-Smtp-Source: AGHT+IFgYqVYLd3bJ1uye+mrUb8xwZqUFfTGtcoiwxRHlc9JoDBAT6ZJfA68H0it17/fmR3KmGQU5g== X-Received: by 2002:a17:902:f54a:b0:216:2426:7668 with SMTP id d9443c01a7336-21a83f4bce1mr257464125ad.13.1736821195029; Mon, 13 Jan 2025 18:19:55 -0800 (PST) Received: from localhost.localdomain ([2620:10d:c090:400::5:4043]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f22eb8esm59444185ad.166.2025.01.13.18.19.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Jan 2025 18:19:54 -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 v4 5/6] mm, bpf: Use memcg in try_alloc_pages(). Date: Mon, 13 Jan 2025 18:19:21 -0800 Message-Id: <20250114021922.92609-6-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250114021922.92609-1-alexei.starovoitov@gmail.com> References: <20250114021922.92609-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 416C980009 X-Rspam-User: X-Stat-Signature: y7cbjmb6qa6af87moj1g8mxxs7z184xz X-HE-Tag: 1736821196-723965 X-HE-Meta: U2FsdGVkX18ScH30p4NQ+v6mhNUn9It2k/XF/haPf4xS7Q/GqVy5OQs98UcqgVCcGx2N3m1dfwFenjVzJHwj8/qlg2RnDcHAXRd/+EfQyyem83dl+hSruqX+aALT0rkp8XaP7CyAqhUAe2MLkVN2ugX0pa0xixrz/3Wb7nEJ+20+Lle8w9siEvF8NPsxd+bz7OjBtw8V5UrXirWGduVnQAmW/dMoYGC5cGlC6FQIoRDebLbM3V9vORl+OoGfi92e7nLrm5KLYHOKoXrJJt31zAQyo6CpZxN7Hs/galAG62kFyYmN2/4bIT74zNxP94j+hbUXhIXrXBw25SIFU9cJx/T731YJEUSVMUPXqdWpPn/u3AVUBVxrkNvOFfpHAzQ9lgDJv3gbz4kLNDMeBX1Au6111IvNOdSJZwlAdRAyYsCZ3+ne6/jZpW8YvQQkovreJZi36dEF2pCNfI98W3mimUtFoIwTqPUbWWxSDFPmC4c23pAZ/1DUiMuxZNYMe+ILcpICxL/tMja2Z3UG57x0Zm4ItEYfpY7i62uPT0iBT1jay+mX+sC4U80KR9R8z54zdfzJpEQHtwHwZgrNsElf5fkRM09Ey+heo0cl0ZkqkQU8a3RHKmVvGfISyFwTdWl5jx4MypIc4r7hNHdLgCJ8mZPkStXWuMLxh6VTR335yz3HRMwia0TWMKHZRIbrtcxXnhzD5lGA+M8d3n1lv1t29S1DqHf2C0b/P07pPrcVtzpL/c3LWEqvUH57wNUtoZQ5IezDcfAKiokMH+SKWdcNda9klSjQvmEeL7fLpxvZxvyC9r8brnidSacRqnCUoz0jcFDOYAo47Y1rrly9sPHsv5KVYMIAdqWwGTaheLPpGzxZHZgA6rgaXT/j5NZilVOa2M6fGq1Ojy6e7ezeWTJ9Ow4y9Ocr+6IuTW4/nclD+VlpnAybWvzedKH5BjLty+6vLQhb+Gu7ckKBT63J2rE PIaEJehr 1RxZS8139NRbO1YUfYDaoM53Rn54+TwLuZcHbARIk42yjGttVoxixHShRV1HNUyAVP0/kz5K1+/SdLSkb2xtjqSTXvL1skZ33ZBPlmH5gBmwBS/UcMA4ZwzZuyj24E/Pk+a9N8OROJ6r/K10rQ3bsCLrfNVlCo/l0HexuLW1kvz1jR1kadP3m7nwmjtH3R6ONxZ39TdtihdKBwVTDyrHyQ5HzB1CJv1C1tp4RnLG9M00m4MYRCi6D+Hdrnz7RnhosEyw9sYrmg+a7FUZ1mHTeYKF2DH42ewPv8kadK4Hdgk1nDInljK62oz7n4vot1nNEXs97xNQZzvzzV8iZTetCOivBT1JipFfxFjK9yh+oPZaqqJAY6/Nyz6ieNWNZ6lMTNEoUUVKDMLrOiz5EpU1YaX0QaixcFKV+rULBFN56xzB1/PC1O6kEmPhuzVLoadko0dKabjbhGgpRGx6W3QlLSMkpZH+TE0+Nbb1p4OGwbSc57temAs0NdnPC5w== 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: <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 f967725898be..d80d4212c7c6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7118,7 +7118,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; @@ -7161,6 +7162,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;