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 90FC8C3064D for ; Fri, 28 Jun 2024 05:35:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFC556B008A; Fri, 28 Jun 2024 01:35:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAC646B008C; Fri, 28 Jun 2024 01:35:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B25816B0092; Fri, 28 Jun 2024 01:35:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 94AF06B008A for ; Fri, 28 Jun 2024 01:35:46 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 276721A163B for ; Fri, 28 Jun 2024 05:35:46 +0000 (UTC) X-FDA: 82279185492.03.1E6ED39 Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) by imf11.hostedemail.com (Postfix) with ESMTP id EFEC740020 for ; Fri, 28 Jun 2024 05:35:43 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OFspZlXE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.217.43 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719552924; 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=BD+z54TW9IfkYnjMzOI9a5At2j/hB/YpkVnnQF4DGJY=; b=nir8ZVpE50uQBvrZNqftNHuHEDK8hbtrUF0SZBzSD5ad3XLOHgdAkATLw5e+JmiGAfy+m1 UVa204GFWZrDnIpw6r7IzQAa89yHwupnmBFMDX67V7uwG7kHDUcyLkon6LPifFHTaTaHhj 5BXEKSWvhqS6TjIcyJqQWQNfZNVXGrs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719552924; a=rsa-sha256; cv=none; b=jdL9ukGL5IoNTEYWyEdIeqMcnDcX03dgJERP3sIupkYAec8lUnb7O3xYzRGQ9qJBYJhHDX tUPgG3hcEY4V9/FWHWh7xkUuvh5jP+rq9s7rLSdW55kLPE6lqHN3IUhVyP7qyTZWfFXcXA OX9vQEUmDvpjKwTmP7ieAdxgGx48S5g= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OFspZlXE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.217.43 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-48f4709e146so80869137.1 for ; Thu, 27 Jun 2024 22:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719552943; x=1720157743; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=BD+z54TW9IfkYnjMzOI9a5At2j/hB/YpkVnnQF4DGJY=; b=OFspZlXENsDEZsGGRBFU20H+c9f5O1tN8fvtdgokN7+fS2XzxzZbB8n/XffWuJAsTL jfCnpiY+570HPfl/7M6dDNLDys2iJMjqfAOmLduN/zLjtiNfy0E2McgNyh7YmuCKZJYD k6tXvffGgXO5YswhZfcr+B4JhwGPhoGfH5yXNYdEzRZH31Y4O2VQTpsnsf6HG6wPyzoH eVIdDp1vIqLYz+HeeaNfMFXUNVJDFoGa9wOdeUvlhcG3i4EsnMYLs/qxeUBqewUV5cWk D37soyyPolGy2HxrE2ivgh/HxCu90g5GqYh4KYVzUe2+omVhXs038NKOgFduboBmzZoc KCzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719552943; x=1720157743; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BD+z54TW9IfkYnjMzOI9a5At2j/hB/YpkVnnQF4DGJY=; b=fOG9rVZEjuJMElB5WmK6h1KDktvBuhTvYJ29jyHns3s0lQI8ox/MWu4pOEwc/BV3as 8wTMODwSa/ekaVKqn2yW7uRl/l4KnH3xCarqMACUh98/kV7cm0a+KpbZAZisCB766QBy 35qhJ5Fyuw2hCukS8aX6lpjt9RA6TYbxDDAXxDuPILY4TBtnZP2WpvknALRhGfUIDlJc jUoVxYjuLysO4TAdP/Scex2N6sjfthICDZGZjlSdy7PNqpK8mNIeijGd3Oy4HbTHTutV mFbOuk4g1Pk+n++t3Fa/0h6zcTooYoy6o8vsXNTG4rxq73Ep7r+lozm8fPsKrBJpDkuB VTiQ== X-Forwarded-Encrypted: i=1; AJvYcCVbNj3Fe47VHQDrsO6LozLTB/fwzB2o/wgJ9+AfpC22BA9caOiB75hhMW7FEheWYFxgFdYeQ+BhrAxf4djJirkc38g= X-Gm-Message-State: AOJu0Yy4vLs27mizYxSA/AONDxpiQM2302cGCq1q6Qwd5QHd+M5hTmHT k0bCGSJ+9jcmA8GQmxlO0digSppugwguPrrtKjDNd8U8Y4mamQ5K X-Google-Smtp-Source: AGHT+IGghsZyTtJONCT4wuQZ86eZ7o7Mbz4W7tvHc+RnW+oKueDx7rXUJ8zzubnuKDPNXOVbgLb+UQ== X-Received: by 2002:a05:6102:3585:b0:48f:6581:c16c with SMTP id ada2fe7eead31-48f6581c945mr15269960137.6.1719552942915; Thu, 27 Jun 2024 22:35:42 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d69302057sm44472385a.100.2024.06.27.22.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 22:35:39 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id EA24F1200068; Fri, 28 Jun 2024 01:35:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 28 Jun 2024 01:35:37 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtdehgddutddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Jun 2024 01:35:37 -0400 (EDT) Date: Thu, 27 Jun 2024 22:35:36 -0700 From: Boqun Feng To: Vlastimil Babka Cc: Kees Cook , "GONG, Ruiqi" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , jvoisin , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Xiu Jianfeng , Suren Baghdasaryan , Kent Overstreet , Jann Horn , Matteo Rizzo , Thomas Graf , Herbert Xu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, netdev@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH v5 4/6] mm/slab: Introduce kmem_buckets_create() and family Message-ID: References: <20240619192131.do.115-kees@kernel.org> <20240619193357.1333772-4-kees@kernel.org> <202406201147.8152CECFF@keescook> <1917c5a5-62af-4017-8cd0-80446d9f35d3@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1917c5a5-62af-4017-8cd0-80446d9f35d3@suse.cz> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EFEC740020 X-Stat-Signature: jud8a3u5st6fyrymxqb6e34tp79if3ry X-Rspam-User: X-HE-Tag: 1719552943-491858 X-HE-Meta: U2FsdGVkX19Gjbs3uXGW41M1S36BdStM3fRaoLqhhQQ3/nYsJiQfoz0D1Zv6VzB5qwA5l+aS+3Uzm9aKN82ecr2wAHn4Zq/h1tL7nnzKZCNuSr+Wxq2u/3+mi1+rOsavhODkgSjaTEagOe064ad70jwjQa8D4IdvHv0NzOIIFIqk2QSb96MhiOhIkaLKkyG7TiPerqINlF+aQ9zxdN9aTxWgiITeCnFmCAsz5zTKPTjYOlF7NDxmXXSY1aCTryxHHgI3Z6FuCDPPtbpLzXiSn6uSXFHUpvu88i6MTY20JjpbwjXOky8VpE9TVAFJhVXnSJBIsXhEvuQoxruqefn0PJ3ZutwNbuqYSJCwB6W+bP4nG1MVSnihVcC2tLhyViiv4QHdqJ5fsd9ZbHFbREintBA2pu0mymC18OR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tCmU 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 Thu, Jun 20, 2024 at 10:43:39PM +0200, Vlastimil Babka wrote: > On 6/20/24 8:54 PM, Kees Cook wrote: > > On Thu, Jun 20, 2024 at 03:56:27PM +0200, Vlastimil Babka wrote: > >> > @@ -549,6 +549,11 @@ void *kmem_cache_alloc_lru_noprof(struct kmem_cache *s, struct list_lru *lru, > >> > > >> > void kmem_cache_free(struct kmem_cache *s, void *objp); > >> > > >> > +kmem_buckets *kmem_buckets_create(const char *name, unsigned int align, > >> > + slab_flags_t flags, > >> > + unsigned int useroffset, unsigned int usersize, > >> > + void (*ctor)(void *)); > >> > >> I'd drop the ctor, I can't imagine how it would be used with variable-sized > >> allocations. > > > > I've kept it because for "kmalloc wrapper" APIs, e.g. devm_kmalloc(), > > there is some "housekeeping" that gets done explicitly right now that I > > think would be better served by using a ctor in the future. These APIs > > are variable-sized, but have a fixed size header, so they have a > > "minimum size" that the ctor can still operate on, etc. > > > >> Probably also "align" doesn't make much sense since we're just > >> copying the kmalloc cache sizes and its implicit alignment of any > >> power-of-two allocations. > > > > Yeah, that's probably true. I kept it since I wanted to mirror > > kmem_cache_create() to make this API more familiar looking. > > Rust people were asking about kmalloc alignment (but I forgot the details) It was me! The ask is whether we can specify the alignment for the allocation API, for example, requesting a size=96 and align=32 memory, or the allocation API could do a "best alignment", for example, allocating a size=96 will give a align=32 memory. As far as I understand, kmalloc() doesn't support this. > so maybe this could be useful for them? CC rust-for-linux. > I took a quick look as what kmem_buckets is, and seems to me that align doesn't make sense here (and probably not useful in Rust as well) because a kmem_buckets is a set of kmem_caches, each has its own object size, making them share the same alignment is probably not what you want. But I could be missing something. Regards, Boqun > >> I don't think any current kmalloc user would > >> suddenly need either of those as you convert it to buckets, and definitely > >> not any user converted automatically by the code tagging. > > > > Right, it's not needed for either the explicit users nor the future > > automatic users. But since these arguments are available internally, > > there seems to be future utility, it's not fast path, and it made things > > feel like the existing API, I'd kind of like to keep it. > > > > But all that said, if you really don't want it, then sure I can drop > > those arguments. Adding them back in the future shouldn't be too > > much churn. > > I guess we can keep it then. >