All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Pedro Falcato <pfalcato@suse.de>
Cc: "Vlastimil Babka" <vbabka@kernel.org>,
	"Harry Yoo" <harry@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Hao Li" <hao.li@linux.dev>, "Christoph Lameter" <cl@gentwo.org>,
	"David Rientjes" <rientjes@google.com>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	linux-mm@kvack.org, "Kuniyuki Iwashima" <kuniyu@google.com>,
	linux-hardening@vger.kernel.org,
	"Jakub Kicinski" <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Jason Xing" <kerneljasonxing@gmail.com>,
	"Björn Töpel" <bjorn@kernel.org>,
	"Jiayuan Chen" <jiayuan.chen@linux.dev>,
	"Willem de Bruijn" <willemb@google.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v4 5/7] mm/slab: Provide kmalloc type fallback for bucket allocations
Date: Fri, 2 Oct 2026 15:27:05 -0700	[thread overview]
Message-ID: <202610021520.5A076C2A0@keescook> (raw)
In-Reply-To: <arJSz0r5u_78NWKe@pedro-suse.tail5790ac.ts.net>

On Tue, Sep 22, 2026 at 11:11:58AM +0100, Pedro Falcato wrote:
> Big thanks for continuing this effort :))

Thanks for starting it! :) I've had a few folks wanting it, so I'm happy
to help.

> On Mon, Sep 21, 2026 at 12:58:16AM -0700, Kees Cook wrote:
> [...]
> > +/*
> > + * The kmalloc types a bucket set can hold a copy of. This is deliberately not
> > + * enum kmalloc_cache_type: the KMALLOC_PARTITION copies are all "normal" to a
> > + * bucket set, which already separates what they were there to separate, so
> > + * indexing by those would mean up to KMALLOC_PARTITION_CACHES_NR unusable
> > + * rows per set. Allocations of any type not listed here are served by the
> > + * general caches.
> > + */
> 
> This sounds odd. Is there a good reason why KMALLOC_PARTITIONs are kmalloc_cache_types?
> Perhaps that bit should be reworked instead?

I'm not sure I follow. Do you mean the partition copies themselves
shouldn't be kmalloc_cache_types? That predates this series. For a
bucket set, they're all the same "normal" type, so a set indexed by
kmalloc_cache_type would carry rows it can never use: on x86_64 with
CONFIG_KMALLOC_PARTITION_CACHES=y, that's 20 rows (2240 bytes) per set
instead of 2 (224 bytes). I've put the numbers in the commit log for
v5.

> [...]
> > +	if (type <= KMALLOC_PARTITION_END)
> > +		btype = KMEM_BUCKET_NORMAL;
> > +	else
> > +		return &kmalloc_caches[type];	/* No set holds a row for it. */
> 
> Hitting this case sounds like a bug in the kernel. WARN_ON_ONCE()?

The next patch warns where a set could have held the row but wasn't
created with it (an accounted allocation without KMEM_BUCKET_CGROUP).
What's left here are types no set can hold, like DMA and reclaimable,
and those already come from caches of their own, so falling back
doesn't lose the separation.

> Otherwise LGTM.

Thanks!

-- 
Kees Cook

  reply	other threads:[~2026-10-02 22:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  7:58 [PATCH v4 0/7] net: skb: isolate skb data area allocations into a separate bucket Kees Cook
2026-09-21  7:58 ` [PATCH v4 1/7] mm/slab: Mark the kmem_buckets_create() context as a Context: section Kees Cook
2026-09-21 12:03   ` Harry Yoo
2026-09-22  9:58   ` Pedro Falcato
2026-09-25  8:38   ` Hao Li
2026-09-21  7:58 ` [PATCH v4 2/7] mm/slab: Give bucket caches the alignment of the caches they mirror Kees Cook
2026-09-21 13:17   ` Harry Yoo
2026-09-21 23:25     ` Kees Cook
2026-09-24 18:22       ` Harry Yoo
2026-09-25  1:00         ` Kees Cook
2026-09-21  7:58 ` [PATCH v4 3/7] mm/slab: Add kmem_buckets_destroy() Kees Cook
2026-09-21  7:58 ` [PATCH v4 4/7] mm/slab: Add tests for the existing kmem_buckets behaviour Kees Cook
2026-09-21  7:58 ` [PATCH v4 5/7] mm/slab: Provide kmalloc type fallback for bucket allocations Kees Cook
2026-09-22 10:11   ` Pedro Falcato
2026-10-02 22:27     ` Kees Cook [this message]
2026-09-21  7:58 ` [PATCH v4 6/7] mm/slab: Let a bucket set handle __GFP_ACCOUNT Kees Cook
2026-09-21 13:25   ` Harry Yoo
2026-09-21 23:26     ` Kees Cook
2026-09-22 10:20   ` Pedro Falcato
2026-10-02 22:29     ` Kees Cook
2026-09-21  7:58 ` [PATCH v4 7/7] net: skb: isolate skb data area allocations into a separate bucket Kees Cook
2026-09-27  8:24   ` Paolo Abeni
2026-10-02 22:59     ` Kees Cook

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=202610021520.5A076C2A0@keescook \
    --to=kees@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bjorn@kernel.org \
    --cc=cl@gentwo.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hao.li@linux.dev \
    --cc=harry@kernel.org \
    --cc=horms@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=willemb@google.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.