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 EDD54C3DA6D for ; Tue, 20 May 2025 17:48:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 596386B0089; Tue, 20 May 2025 13:48:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 547226B008A; Tue, 20 May 2025 13:48:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 435BC6B0092; Tue, 20 May 2025 13:48:06 -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 1ADDF6B0089 for ; Tue, 20 May 2025 13:48:06 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 89D6FE5E61 for ; Tue, 20 May 2025 17:48:05 +0000 (UTC) X-FDA: 83464019730.16.5393FDC Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) by imf24.hostedemail.com (Postfix) with ESMTP id A82A4180017 for ; Tue, 20 May 2025 17:48:03 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=bSvUqcKL; spf=pass (imf24.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.176 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=1747763284; 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=Bg+OboCNSdATtjWjZopnjv9353Tg8njJlaUUMAxqY9o=; b=NV3/SaEho2TCfpV+LQ60Motu/mr7TsKZY+EziKPHZK4ZvTjOhFfevAO+uRsDdFmmw4fS7V Hy48u9Bs7sUv7OmXkJpzFn7gFBfA1tNwNC7mkCz8zOf2JhH0NmtnRBCxvUBdWsYPbKvdl9 70EAedd8ILgrKljQdCzx+AJCOfVE2tk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747763284; a=rsa-sha256; cv=none; b=05qGAPzDl2RhKpN+GhwIfrcyLpVqd8M7P8AI0zQ8f4fV7FmgcNnUNyy0KGLA7XSfPynS+c E4hcgPrdeZ7lGxNIwvVGYYVTPBt9TbVQrT+WU8medy+HW3JJ9hm+/eDIKjfd3GKuwSdj2+ bIkrvIvFZOsGr1ZfsrM4ut7/PYH4rG0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=bSvUqcKL; spf=pass (imf24.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.176 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Tue, 20 May 2025 13:47:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1747763281; 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=Bg+OboCNSdATtjWjZopnjv9353Tg8njJlaUUMAxqY9o=; b=bSvUqcKLhkkXUsYx1xW0Wpg6XFKtPrm9uebhnlpHkJ26G//sq9WzRLbde2RsCi2z1hdpah qbBGcPToxj1iY1uxTMivenV4ya40ydiyoAPNLHmMgHVIeC0X6aoZ1LXXDSe3UMxDCLfuh5 s90C5f/MHl+zCEA0eqdNp0j7R2XRaoc= 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-Server: rspam08 X-Rspamd-Queue-Id: A82A4180017 X-Stat-Signature: 45hwco4oe4t6i59oj86nyffkjc77db6j X-Rspam-User: X-HE-Tag: 1747763283-207684 X-HE-Meta: U2FsdGVkX19wToxVjrxTzFFw7dTYrq9UZ2WkIcpJbUDRlJ2EsEcAgmLOKKFg5NvSDUbHJtBDJRJM49OjVZphXztZzLmqwYY6XiHh7EYh3A2SHMWofuk3Jf7HXE8OCza32HA4jgklFB8RLqKwiwz4BqiQn7sk62oF076lyIBMY83jIkfUnQ7MLHHhhhA+jmZITFEaZxi5oYpSUzu+8BEhWUrQVL7LCQTcm8ymWo17hAcRzKiyngoailrcND7bK5I3B1qNjdlELtOlQOsvviSxss8qlOuAbn+bsm38Lv1K6h0H1W2B+Wg8GGYhtHk1SpU/UgFvcDxSlWirs64adW8bg1eye98oEQmZkVWGLGSlAdYVPvU+Uj/Lf42zRUSxDCMiKN+npKYUInfh65xr6sNMXeuHIVxVK4Gpj2rTUT297K6yUXfvavq9A4qYQsZfu+qBmBCs6pG57OrW0PStqwL8gBMDT+YdFpwSOUO3oR2kEVhUCe+FIXJcvvqsuwxSHCsGekmEehS9E1K7VZpF5gmz4EjPxg9LsoCTymFgIy+fMLT/+mHtf8bGZlOfNIHAdOc4YTdcuZy4/myCGqv7vWLJReaZHFKOx9/rf3cZfv5Ued/QZTUKoj2fQoWYqpi9UIirTG3sCocd9lThIvGe9Ot5kr3/pnqEkY+utIn643uS2P+s6siRdBSiffK5T2ftLQ+Ex1bfZ+Xv3DR6zyU6HnYjq17Z5fYxOgLOR2BGGWCZL+Yn/MykK+A+XLEtgo9eVh7nYv3hWMR6si5mzlhm5FU8PRMglGK39nOB9s6YCjPNBPPIWOTPzbvzehCljf8ConxZyoeZeBAKgtC90t8PY4zKiuPe5KzHceabPriyEIxMmylYMsHWoZJF6KIZOjZR9eunfl0ZtQFWw84WZ69PYbrC9uqYFiXe0kHEGF6ddTF25DJlTgP8HUwc9w== 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: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.