All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Uladzislau Rezki <urezki@gmail.com>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Usama Arif <usamaarif642@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	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
Date: Tue, 20 May 2025 19:57:10 +0200	[thread overview]
Message-ID: <aCzCdraykYULK8x2@pc636> (raw)
In-Reply-To: <dvbvfrj4voyoyoj47ufowpr2sblbtd4wptogx6nnucdz3yrvbj@c7xojwuozflq>

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 <usamaarif642@gmail.com>
> > > > > > >> Reported-by: Vlad Poenaru <vlad.wing@gmail.com>
> > > > > > >> 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);
}

--
Uladzislau Rezki


  reply	other threads:[~2025-05-20 17:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20 12:25 [PATCH 1/2] mm: slub: allocate slab object extensions non-contiguously Usama Arif
2025-05-20 12:25 ` [PATCH 2/2] mm: slub: only warn once when allocating slab obj extensions fails Usama Arif
2025-05-20 13:34   ` Harry Yoo
2025-05-20 13:42     ` Usama Arif
2025-05-20 14:18       ` Shakeel Butt
2025-05-20 15:14         ` Suren Baghdasaryan
2025-05-20 15:22         ` Usama Arif
2025-05-22  0:16           ` Harry Yoo
2025-05-22 12:42             ` Usama Arif
2025-05-20 13:44 ` [PATCH 1/2] mm: slub: allocate slab object extensions non-contiguously Kent Overstreet
2025-05-20 13:46   ` Usama Arif
2025-05-20 14:01     ` Kent Overstreet
2025-05-20 14:24       ` Shakeel Butt
2025-05-20 14:28         ` Kent Overstreet
2025-05-20 17:44           ` Uladzislau Rezki
2025-05-20 17:47             ` Kent Overstreet
2025-05-20 17:57               ` Uladzislau Rezki [this message]
2025-05-20 17:58                 ` Kent Overstreet
2025-05-20 18:59                   ` Uladzislau Rezki
2025-05-20 14:13     ` Usama Arif
2025-05-20 15:20       ` Suren Baghdasaryan
2025-05-20 16:41         ` Kent Overstreet
2025-05-20 17:20           ` Suren Baghdasaryan
2025-05-20 17:25             ` Kent Overstreet
2025-05-20 17:18         ` Johannes Weiner
2025-05-20 14:01 ` Usama Arif

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aCzCdraykYULK8x2@pc636 \
    --to=urezki@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kent.overstreet@linux.dev \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=usamaarif642@gmail.com \
    --cc=vlad.wing@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.