From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D996640D598 for ; Tue, 30 Jun 2026 04:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.160.170 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782794355; cv=pass; b=Lfk/vrCl4MvPWZOtcjrK1ITMOFc20woHDv3h8lvSdg3PHfcJkx3VLyfSEKmnir8nknuP0X9osQwVoqFucoye4GtOl1NnPe1z76zKBAqIZCig8NfGSsc68tTSRYdal3LJVgVDP0vnlQ5gjO5wIzLbAEyjP7w4qGHXy43LygnkYNk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782794355; c=relaxed/simple; bh=jepN6NqFeI9PS0ynHye+Gb6CggpJJC2VfKtbREcLF/c=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=rXFvkC3Dtf3ey+BP8cRlPsaQKjqKAckEyERfDyY6J2NoUKU9WNVSnAyMKXCK8Xq3wPJGNHIQrj086HzzGAy+w2O7o7r8eEHzBBywbB7ifBfVseVVQDadZSBTtOahWn4RJh1uU1hAc9Ofhr/lfrqxZp/0wmh6dbJDL4+05SYVgUg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=J2bMjdHK; arc=pass smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="J2bMjdHK" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-51c15a5b265so43261cf.0 for ; Mon, 29 Jun 2026 21:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782794353; cv=none; d=google.com; s=arc-20260327; b=flwbE/Te1T2ncMQAgnSQ0d4A+eV1tVz5ebkHrdTD34wClXh46tZq87Fmt3v5EyF5wJ e4mYOkPg2g+BGSlEISvExHcJzvzHBrvHByQfuVDa3iQFNeGQfWpOXwXGyfcSJRd/Hb7j xyl/vY4UZSTaoxOOsQmTtKSR+jBC6lKY5c6F0JZqdPf0gDbOR6HLAVOLHNM2FUS+TZW0 nb7wJb+/1e1rPWm0z1AFLW6HVMRG0UdvU0s07GCXE0AnJK2hP5qfm/fzW1uMAj1K6z1W UUnVhOKpiATZtOVoO5y5V/ClHGN62zYkgmVJSCLEz3xwuRyeh/NmFRa5lkgCsyh4190v cNAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MvkzfzattQGcZj/xGT4njtzG81mXcFmv+CBP0enhAF8=; fh=Vod/XPFqkKZKl7PhFTmZDVGAIQL8Vbd2vr75I2i9oZ0=; b=DDl4K2G7pN8oNJazPAhmh/OYWlHttrUUdjbtoEUPdHNKu6qB0rPjb8L/kwY7P6xMNi 1hPBwlX/sQLiGBLyaexZfPxTOzdR4I/JMi/PpqevKwHUcYlCfApxa2a78ymGnOuF8Ex/ 18wH3Jq/fhPQ1UsG1rNzGWP5hmcGvkfBpxjQ7zaiQbCfPvdnj2gpemaLixEeYjdtI0+p wlpsixItGn1Rv8TuXcEhj5UYEBF1E/q9bzLJRH+k+1NRxud43M6bddguHt0qcL/K1oCF V5RTUGbekvlxo6EGvdCjdioXTBHk6XK5J+G5eWXw9oisx/DhnDGqTjsS2D2yvcoYGj8v pSfw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782794353; x=1783399153; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MvkzfzattQGcZj/xGT4njtzG81mXcFmv+CBP0enhAF8=; b=J2bMjdHKoOvVrvbUX8pjKgTVpn+cg/CbNcgJqE+ytSnC2Ybp68nXt1kYVGKlPaRMIo hZQRh1sdJJrOADjEw4bnHYqLA47uTcXvY8mh4aEv+Br4wrBK48/uZs3KApFaq0fAQkI4 8lR19ZwAllmGuwzBXZMgfujmPTxS7RY+mPTJMD51M6ttYIk7pds4r3meITgLK8dmQI37 tl2gEO4f41ta0yd1XrjtSO/D9LC3LpjwCSwszvew3O0aSr6jpuPdrI4Xa3f+grIr5omX A4d7PigWUuhFHSHV/2ZG+avBRzuv3gX2fCxtg1DjioU2cOSprUFxpioFePotLZMxu+cY ofHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782794353; x=1783399153; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MvkzfzattQGcZj/xGT4njtzG81mXcFmv+CBP0enhAF8=; b=U0repUNj5Wl/rq47LsimQw9BvHJcpfr2PvRdGGijM40Cmx4x4kLEgGagn24AHN7w16 cEXyVNlW8GLq9zRgQLjpwhn/I05+jkJOXHFF8H8bqXTAqE++DMBV4BtTZ7dofsoeqksK /jmo3NWYiYIp2tTi0icqfhgwf24seMb1IPV+rTYuGTkiQVu4MHp84soVd4/N0k82dAsK Sg/eCbrOJJ1v/TetkDzE0E534YOthXCImO3/pQbrabTnEGLv+MP5CZ7G1PrFbS3sXU/T /7PtmR9hlthPJ4XPLD2gp7l3YntOXTylgXYjdQ7jcs3HHAvedcm0e8k8/oNda1RaCent C2Rw== X-Forwarded-Encrypted: i=1; AFNElJ/RjK/L+g0RfqR2WW7CE3WoLVf6CfGurUlBOc0EfJubJfmHzr0SHs+qJ4qwffb3BqduttWfxSNvEqZs80k=@vger.kernel.org X-Gm-Message-State: AOJu0YyTtpROiBy4DGAi55qaDzWog7RRZYnZOuuZSc0nfTjDRVfTDCGl FoQCJNAG0Ied3DirCFK4KjMNUTbmuz792QT9JjrWfW3DbKPegEqTNbnYaU5nfTY1SNOuVd2gfr8 t+KxwWSGXNYVAgLJuCV/iGS3mY1hcctW337jYLLxu X-Gm-Gg: AfdE7ckMfwJaNFKbJrOMIbLNGaIfB+unK4IQuwY2qqi6nBfKwA8A82ypmAgbB8Q68F/ jSo7+N23b18YsayRa2SywBdgMnPL9vKiQfQezuy5KR6rH3iM2AzSdlekRlFi/gL4StQZeXfAw0B Vy1FWtlLaMY7urWyhgzUL+VEs67PisqKPc6zFA58Yjio19mHRF/8x6nGmmDWtCYw9WQ+NeXWev+ qgOBFCgA1HrJQ4bNS4VGYFp/8fBNApsAhaVzccQ5WR0a71aTbdiHi0W/VK0HDb37SenCso= X-Received: by 2002:a05:622a:4d4f:b0:51c:289:6979 with SMTP id d75a77b69052e-51c15c6ad57mr2694461cf.21.1782794352086; Mon, 29 Jun 2026 21:39:12 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260625230029.703750-1-shakeel.butt@linux.dev> <62453403-954c-4cf1-8924-6d38184b0810@kernel.org> <09267187-6c85-438f-8791-4cce8d07892a@kernel.org> <68122038-e8e0-47ed-82f8-cb6a23e4658e@kernel.org> <62969830-4b1f-483d-8fa9-9ce487568570@kernel.org> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 29 Jun 2026 21:39:01 -0700 X-Gm-Features: AVVi8Ce91qe409wtAt-8dDcpKS-nxkuJwHPbZqlJj2AUXB_x1rxhTzpVNZUiz58 Message-ID: Subject: Re: [PATCH] mm/slub: serve slabobj_ext array from a strictly larger kmalloc cache To: Harry Yoo Cc: "Vlastimil Babka (SUSE)" , Shakeel Butt , Andrew Morton , Roman Gushchin , Hao Li , Christoph Lameter , David Rientjes , Usama Arif , Meta kernel team , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Danielle Costantino , Kees Cook Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 29, 2026 at 9:38=E2=80=AFPM Suren Baghdasaryan wrote: > > On Mon, Jun 29, 2026 at 7:31=E2=80=AFPM Harry Yoo wrot= e: > > > > > > > > On 6/29/26 1:28 PM, Suren Baghdasaryan wrote: > > > On Sun, Jun 28, 2026 at 8:57=E2=80=AFPM Harry Yoo = wrote: > > >>> I think adding a new KMALLOC_TYPE would be the cleanest way to fix > > >>> this recursion problem once and for all. This size bumping and the > > >>> special case of SLUB_TINY are quite confusing. > > >> > > >> As mentioned by Vlsatimil, in the long term, using SLAB_BUCKETS > > >> infrastructure would be more straightforward than new KMALLOC_TYPE > > >> because (I think) the kmalloc type is decided purely based on GFP > > >> flags and we need to somehow work around that. SLAB_BUCKETS provides > > >> a nice abstraction to do this. > > >> > > >> Luckily, SLAB_BUCKETS is introduced in v6.11. > > >> Unfortunately, SLAB_BUCKETS is optional. > > >> > > >>> We could define that> new KMALLOC_TYPE only if memory allocation pr= ofiling or SLUB_TINY are > > >>> enabled to avoid new caches when not needed. Does not seem too comp= lex > > >>> but maybe I'm missing something? WDYT? > > >> > > >> I think we need some enhancements to achieve that with SLAB_BUCKETS > > >> > > >> 1. Rename SLAB_BUCKETS to SLAB_BUCKETS_HARDENING > > >> (w/ SLAB_BUCKETS being a transitional config for _HARDENING) > > >> > > >> 2. Make the SLAB_BUCKETS infrastructure unconditional, > > >> but the decision is made at runtime: > > >> > > >> 1) actually creating a kmem_buckets vs. > > >> 2) falling back to kmalloc. > > >> > > >> 3. kmem_buckets_create() creates kmem_buckets only when > > >> SLAB_BUCKETS_HARDENING is enabled. > > >> > > >> 4. SLUB decides (not) to create kmem_buckets for internal use > > >> during the boot process. Use the kmem_buckets for obj_exts > > >> array allocation. > > >> > > >> Side note: this would unconditionally add the kmem_buckets parameter= to > > >> the kmalloc slowpath. Probably it'd be worth introducing a dedicated > > >> entrypoint for kmem_buckets instead. > > > > > > Yeah, this sounds quite complex. > > > > I think it's not that complex, but quite some churn, yeah :) > > > > > Maybe we could use the new> kmalloc_flags() introduced by Vlastimil > > > in [1] to avoid using GFP > > > flags to indicate that we want to use this new KMALLOC_TYPE? That > > > seems simpler, > > > > That indeed would be smaller changes. > > > > > though it's not backportable because kmalloc_flags() is> brand new. > > > > Right, I didn't seriously consider that option as I was (mistakenly) > > assuming you or Shakeel would want to backport it. > > > > > [1] https://lore.kernel.org/all/20260615-slab_alloc_flags-v3-0-ce1146= d140fb@kernel.org/ > > > > > >> > > >>> If it is more complex than I imaging then I'm fine with Shakeel's > > >>> approach as a temporary fix. > > >> > > >> Since above requires quite some changes, I'd say let's proeed with > > >> the fix (since it's one line of code change that fixes a bug), > > >> and then see how we can make SLAB_BUCKETS changes as minimal > > >> as possible for backporting? > > > > > > I was thinking Shakeel's approach for backports and > > > kmalloc_flags()+KMALLOC_TYPE going forward. > > > > Oh, I misread it then. > > I was assuming it's critical enough to bother backporting. > > Yes, it's worth backporting, so we can merge Shakeel's change as is > and then once Vlastimil's patch is merged we can implement the new > KMALLOC_TYPE as a replacement. And Shakeel's patch is easily backportable. > > > > > > Just throwing this as an> option. I haven't looked closely into > > > SLAB_BUCKETS yet, so that might > > > be indeed a better direction. > > -- > > Cheers, > > Harry / Hyeonggon > >