From nobody Sun Feb 8 10:49:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A2D2C7EE2E for ; Tue, 13 Jun 2023 10:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240184AbjFMK2e (ORCPT ); Tue, 13 Jun 2023 06:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234648AbjFMK2b (ORCPT ); Tue, 13 Jun 2023 06:28:31 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52693187 for ; Tue, 13 Jun 2023 03:28:30 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F36191FD83; Tue, 13 Jun 2023 10:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1686652109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EMHePs1faHT6iyB5lSxLCoJsx639PDQbw4C00e95wXg=; b=F5fPhSBfKnZ8R9XyblIDCqW8XJ9JEbYDManCJo9ZK9XECcqxpPMJlEd9SFpBJgjsMANLwX T3Lil5t/R42BBzMEOOyUttqmj9YRDHCCk5o1Y0cfsPwd2+brd4CKa7p7u5DZmmAaE2CCMX CEezipqJXD9nqpF+BH/fSa3MqhvEwKc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1686652109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EMHePs1faHT6iyB5lSxLCoJsx639PDQbw4C00e95wXg=; b=+PPBBfWl1DCFRirIRgtsqZQWJIDcrnftO/0rC0cYIe10gpL97/LGIgLC9npBEnPRm4foQ1 cLNgEouTzYKy+HDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CB06613483; Tue, 13 Jun 2023 10:28:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id tYjRMMxEiGRWcwAAMHmgww (envelope-from ); Tue, 13 Jun 2023 10:28:28 +0000 From: Vlastimil Babka To: Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Vlastimil Babka Subject: [PATCH] mm/slab_common: use SLAB_NO_MERGE instead of negative refcount Date: Tue, 13 Jun 2023 12:28:21 +0200 Message-ID: <20230613102820.19153-2-vbabka@suse.cz> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When CONFIG_MEMCG_KMEM is enabled, we disable cache merging for KMALLOC_NORMAL so they don't end up merged with a cache that uses ad-hoc __GFP_ACCOUNT. This was implemented by setting refcount to -1, but now we have a proper SLAB_NO_MERGE flag, so use that instead. Signed-off-by: Vlastimil Babka Acked-by: David Rientjes --- mm/slab_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 0e0a617eae7d..67caf0bc3194 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -878,17 +878,17 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type ty= pe, slab_flags_t flags) flags |=3D SLAB_CACHE_DMA; } =20 - kmalloc_caches[type][idx] =3D create_kmalloc_cache( - kmalloc_info[idx].name[type], - kmalloc_info[idx].size, flags, 0, - kmalloc_info[idx].size); - /* * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for * KMALLOC_NORMAL caches. */ if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type =3D=3D KMALLOC_NORMAL)) - kmalloc_caches[type][idx]->refcount =3D -1; + flags |=3D SLAB_NO_MERGE; + + kmalloc_caches[type][idx] =3D create_kmalloc_cache( + kmalloc_info[idx].name[type], + kmalloc_info[idx].size, flags, 0, + kmalloc_info[idx].size); } =20 /* --=20 2.41.0