linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jann Horn <jannh@google.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Christian Brauner <brauner@kernel.org>,
	Jens Axboe <axboe@kernel.dk>,
	 "Paul E. McKenney" <paulmck@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	 Linus Torvalds <torvalds@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH] [RFC] mm: add kmem_cache_create_rcu()
Date: Tue, 27 Aug 2024 17:33:54 +0200	[thread overview]
Message-ID: <CAG48ez0vbcDcv5z7AUSkW2iMDG+ixSbEyS-4i6ipB-XT7fo96g@mail.gmail.com> (raw)
In-Reply-To: <6063be1b-7d4f-487e-9890-7e8f727d6324@suse.cz>

On Tue, Aug 27, 2024 at 4:05 PM Vlastimil Babka <vbabka@suse.cz> wrote:
> On 8/26/24 18:04, Christian Brauner wrote:
> > diff --git a/include/linux/slab.h b/include/linux/slab.h
> > index eb2bf4629157..fc3c3cc9f689 100644
> > --- a/include/linux/slab.h
> > +++ b/include/linux/slab.h
> > @@ -242,6 +242,10 @@ struct kmem_cache *kmem_cache_create_usercopy(const char *name,
> >                       slab_flags_t flags,
> >                       unsigned int useroffset, unsigned int usersize,
> >                       void (*ctor)(void *));
> > +struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size,
> > +                                      unsigned int offset,
> > +                                      slab_flags_t flags,
> > +                                      void (*ctor)(void *));
>
> I wonder if there's a way to do this in a more generic way, we'd now have 3
> variants and neither supports everything (what about both rcu offset and
> usercopy?).

The "pass all arguments as a struct" pattern might not look too bad
(or alternatively, "pass all optional arguments as a struct"), as long
as it's fine for unused arguments to be zero-initialized? Like:

struct kcr_options {
    const char *name;
    unsigned int size;
    ...
};

struct kmem_cache *kmem_cache_create(struct kcr_options opt);

void blah() {
  kmem_cache_create((struct kcr_options){
    .name = "blah",
    .size = ...,
    ...
  });
}

I think maybe we can do this now that the kernel is C11?

But I guess if we want to allow leaving out the freeptr_offset
parameter, we'd have to have a flag to say whether the freeptr_offset
parameter value should be used... Maybe my proposal is too overly
fancy...


  parent reply	other threads:[~2024-08-27 15:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26  9:23 [PATCH] [POC/RFE]: Avoid silently growing struct file due to SLAB_TYPESAFE_BY_RCU Christian Brauner
2024-08-26  9:25 ` Christian Brauner
2024-08-26 16:04   ` [PATCH] [RFC] mm: add kmem_cache_create_rcu() Christian Brauner
2024-08-27 10:42     ` Mike Rapoport
2024-08-27 13:42       ` Christian Brauner
2024-08-27 14:05     ` Vlastimil Babka
2024-08-27 15:15       ` Christian Brauner
2024-08-27 15:33       ` Jann Horn [this message]
2024-08-27 15:44         ` Christian Brauner
2024-08-27 15:45         ` Jens Axboe
2024-08-27 20:34           ` Vlastimil Babka

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=CAG48ez0vbcDcv5z7AUSkW2iMDG+ixSbEyS-4i6ipB-XT7fo96g@mail.gmail.com \
    --to=jannh@google.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=roman.gushchin@linux.dev \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox