From mboxrd@z Thu Jan 1 00:00:00 1970 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 203FAC3DA6D for ; Tue, 20 May 2025 17:58:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B291A6B008A; Tue, 20 May 2025 13:58:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B00666B008C; Tue, 20 May 2025 13:58:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3DFD6B0098; Tue, 20 May 2025 13:58:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7BD566B008A for ; Tue, 20 May 2025 13:58:34 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1C24E120D21 for ; Tue, 20 May 2025 17:58:34 +0000 (UTC) X-FDA: 83464046148.16.0189010 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 1CAF8C0002 for ; Tue, 20 May 2025 17:58:31 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="A2zBW/JP"; spf=pass (imf22.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747763912; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Yn8LhUpmx8w0uFQdaMkKy3vcpOYWqsWGiuWNQGaXQUE=; b=AzfNVhTacjoF5N9/VHR2+J2UiRILaqQhh72csPgnBVSOSvxfDa91pDWDHwiga2i7EFZlvJ qCj7Oa2kigMvQjdr3gOzPVyoPdvPYzPL+m3BaO7D33M1SJRFpB4wDxQHpj9AmsGFMXuS3x O6PRf049itYtOnKjIqinDLFLucNvDS8= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="A2zBW/JP"; spf=pass (imf22.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747763912; a=rsa-sha256; cv=none; b=nlgVJ266owHA5olcsbWCCoS5EdQm6/UVOebawzLOqGXmWr+zOTfTzQ7BueXA48aW+o5X7O pPgC5/DZ9myyqYwPphZURMw6sfmTedPxfcRvk4Pg0xVV2Ik8rieuRPz+XhazRF/dvxZbB3 xY8ziOLUjASDqPhkrtGUU/VRPsu+MzM= Date: Tue, 20 May 2025 13:58:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1747763910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Yn8LhUpmx8w0uFQdaMkKy3vcpOYWqsWGiuWNQGaXQUE=; b=A2zBW/JP0FLdEFYzfQyLA9jGJ7w7vaZxPtHKalVNh4LEElYdVf9p4kIDbpmL+UVBJOB2vR 7XbD2pnL892F0hclYgZGTwV8fOLLgn9WNJ7e5uUp6KG0bhG8zH5J4QHS9wMhvmPKwPIDCK MCManxRT+3wFbv1AWaE521rlLlX2BLg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Uladzislau Rezki Cc: Shakeel Butt , Usama Arif , Andrew Morton , surenb@google.com, hannes@cmpxchg.org, vlad.wing@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 1/2] mm: slub: allocate slab object extensions non-contiguously Message-ID: References: <20250520122547.1317050-1-usamaarif642@gmail.com> <3divtzm4iapcxwbzxlmfmg3gus75n3rqh43vkjnog456jm2k34@f3rpzvcfk3p6> <6d015d91-e74c-48b3-8bc3-480980a74f9b@gmail.com> <22oihuvcrh5sg3urocw6wbop2v5yni7zinuhywbz7glsee4yoa@gzi5v5fcggdl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 1CAF8C0002 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: i688e61h766nxum9pyf8m3fpggx9phcw X-HE-Tag: 1747763911-741039 X-HE-Meta: U2FsdGVkX1+UHIuKD7FD0dKW5Uxw6euw4jvgkv90IqHK4+UMtbDP9cxTaj5KxP1VRq/OuMTDLVT1KoNcxn89Woa0M/neX/nvRBfl51kokZZeS21UDSN+Vz0zLSB9neKLaEMfLFJYdjS4nmLYFdfK57sDnH4RMVKisRWSizr15moDOHPa9D9OHuoWL170pMqlGR6dhKzii1xrD5ttgoFIWGMxFzOoCAmYk1wHDcU3kaIPiJ8D6wr6YoTyjgxff9QCGh0YGSqntMmjyeEQLjTiP8KG0bhfhJwfuq7/p/BCM5zdheZXBoR1XZ6otE2PIPvK9yNkvAJWbivkmQ/A2OJ2ubNIbs6U0XopB+fTSA8K+oSUi6H8THakzP08F6ohLMm50cpBlaeDmnbmLj2i/Cv+/bXOMFMqdE3tRrSW/1qUllOaOcyl9sop7FqWA0PRDPCbCFaGHzeHpN1jfdlIm6ENv6kaYyPCBGZDN32uaDzn1kCknA/8inbqZGrAWw0m7l5KkD49ud2p+ab9ONOGJxLDBhrzIMKnZZAmkFW0a3hshFLaCyQrMniJjkz6KfLVA27xClsk+zcmQ6R/Y712vC13SgAyzsHF2abKqIqF5Y8ytiohaoK9E5bIyQvoe9alsnPKPeKkt3fZLYVrxs6nxr2xbhBGHR1a/SA0otPzCpe/1NHJPCBfBjRkMw0om+4acCXZJZ9BiBkh6ksK4Jw7/MOIMKSSbViTiygs3b8QEubZZ/VlZefCs+XjlnHLmllp7Nd54qEzF8Mf+5eYItbZ1IbUp4Imph9KDwd3xYAreGb6FTWCvtjf1Zh2gsqY3ROUUnApqetK4lkAMLZ1xHHHUFiBpnlFuf9adOKwrpuPdnqU2YJogflxYkMGmqvujDlHxysapmo+3A5lY5k9q/EMvTr1CgWEnlAe3amtMG4h0KO16eHfMfXUqXX1M8t5DKdQW5VshV0VWtPouo8E3PS4W1k MvAWC2Dp q0msDYm3NfOmlW03l2djtdlUohHH1uicD//Bs3EIuRV/hdbHSY+N6XpIJJLGv05wXjGeIAsRRaZ+pRsNUL6MFm3EFEEzYulvh04iqNMsZODVqZJ/b5SQYRuvJffgXvP06D6YNP7Au9OJ3g2teBQgvb8wQ1NtOOrfelcrCgS8cfvkzKQw7IotczJ0EWt4z2RqYouIbbjavXPYRQzEF4y5Loa0Uc7Dk8v4loWJgTVMHnR2bDsVCvbZQvjP2zKb4ghi5cZeZ8U+P4EdhIZx5Lpi+4KrAZaWPjh6TEB65v/0kSJgdDdqGb53s6vpxfxghd6trQK5afgdOnTalcxI= 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: On Tue, May 20, 2025 at 07:57:10PM +0200, Uladzislau Rezki wrote: > On Tue, May 20, 2025 at 01:47:54PM -0400, Kent Overstreet wrote: > > On Tue, May 20, 2025 at 07:44:49PM +0200, Uladzislau Rezki wrote: > > > On Tue, May 20, 2025 at 10:28:06AM -0400, Kent Overstreet wrote: > > > > On Tue, May 20, 2025 at 07:24:40AM -0700, Shakeel Butt wrote: > > > > > On Tue, May 20, 2025 at 10:01:27AM -0400, Kent Overstreet wrote: > > > > > > On Tue, May 20, 2025 at 02:46:14PM +0100, Usama Arif wrote: > > > > > > > > > > > > > > > > > > > > > On 20/05/2025 14:44, Kent Overstreet wrote: > > > > > > > > On Tue, May 20, 2025 at 01:25:46PM +0100, Usama Arif wrote: > > > > > > > >> When memory allocation profiling is running on memory bound services, > > > > > > > >> allocations greater than order 0 for slab object extensions can fail, > > > > > > > >> for e.g. zs_handle zswap slab which will be 512 objsperslab x 16 bytes > > > > > > > >> per slabobj_ext (order 1 allocation). Use kvcalloc to improve chances > > > > > > > >> of the allocation being successful. > > > > > > > >> > > > > > > > >> Signed-off-by: Usama Arif > > > > > > > >> Reported-by: Vlad Poenaru > > > > > > > >> Closes: https://lore.kernel.org/all/17fab2d6-5a74-4573-bcc3-b75951508f0a@gmail.com/ > > > > > > > >> --- > > > > > > > >> mm/slub.c | 2 +- > > > > > > > >> 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > >> > > > > > > > >> diff --git a/mm/slub.c b/mm/slub.c > > > > > > > >> index dc9e729e1d26..bf43c403ead2 100644 > > > > > > > >> --- a/mm/slub.c > > > > > > > >> +++ b/mm/slub.c > > > > > > > >> @@ -1989,7 +1989,7 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, > > > > > > > >> gfp &= ~OBJCGS_CLEAR_MASK; > > > > > > > >> /* Prevent recursive extension vector allocation */ > > > > > > > >> gfp |= __GFP_NO_OBJ_EXT; > > > > > > > >> - vec = kcalloc_node(objects, sizeof(struct slabobj_ext), gfp, > > > > > > > >> + vec = kvcalloc_node(objects, sizeof(struct slabobj_ext), gfp, > > > > > > > >> slab_nid(slab)); > > > > > > > > > > > > > > > > And what's the latency going to be on a vmalloc() allocation when we're > > > > > > > > low on memory? > > > > > > > > > > > > > > Would it not be better to get the allocation slighly slower than to not get > > > > > > > it at all? > > > > > > > > > > > > Our behaviour when thrashing sucks, we don't want to do anything to make > > > > > > that worse. > > > > > > > > > > > > There's also the fact that vmalloc doesn't correctly respect gfp flags, > > > > > > so until that gets fixed this doesn't work at all. > > > > > > > > > > Which gfp flags vmalloc is not respecting today? > > > > > > > > GFP_NOWAIT. > > > > > > > > As to why, you'd better ask Michal Hocko... > > > > > > > It is mainly due to pte_alloc_one_kernel(), it uses the GFP_KERNEL > > > > > > #define GFP_PGTABLE_KERNEL (GFP_KERNEL | __GFP_ZERO) > > > > > > to get a new pte entry. > > > > > > I think we can fix it. For example if we populate some region and allocate > > > there for NOWAIT. But there are of course can be other hidden problems. > > > > No, PF_MEMALLOC flags allow for passing most of gfp flags for pte > > allocation. > > > It is hard-coded: > > static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm) > { > struct ptdesc *ptdesc = pagetable_alloc_noprof(GFP_PGTABLE_KERNEL & > ~__GFP_HIGHMEM, 0); > > if (!ptdesc) > return NULL; > return ptdesc_address(ptdesc); > } I suggest you read the code around PF_MEMALLOC flags.