From patchwork Tue Jun 13 10:28:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13278315 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 5E1EDC77B7A for ; Tue, 13 Jun 2023 10:28:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2C4A8E0005; Tue, 13 Jun 2023 06:28:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADD668E0003; Tue, 13 Jun 2023 06:28:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A5AC8E0005; Tue, 13 Jun 2023 06:28:32 -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 8E5018E0003 for ; Tue, 13 Jun 2023 06:28:32 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 614551C7DB0 for ; Tue, 13 Jun 2023 10:28:32 +0000 (UTC) X-FDA: 80897350464.15.77F3B0F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf15.hostedemail.com (Postfix) with ESMTP id 9140AA0004 for ; Tue, 13 Jun 2023 10:28:30 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=F5fPhSBf; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=+PPBBfWl; dmarc=none; spf=pass (imf15.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686652110; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=EMHePs1faHT6iyB5lSxLCoJsx639PDQbw4C00e95wXg=; b=PRXPy1YX83iRbmPCTzypHhyrB4mfhEBpGbjvRqdE35Pypozz6gVZkPo4WPkNpQqMV204A/ Do3dc7w3GoS3QK0om9zefSipD57Qig+8Ysk9JXNCtZTOD4OyGVnR7fXVZGy7+nAx8BNnCQ i/TK2+Tw5I6WqyeNo3lPZxfK6Vi7/+g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=F5fPhSBf; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=+PPBBfWl; dmarc=none; spf=pass (imf15.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686652110; a=rsa-sha256; cv=none; b=7VDGitanK+4wFvUr13TM87OwneLzrpIo4kTeQeYuL/lafxlsdSxMdlwRgRKwOoW2bXGlwg mtiWzELl6lNY64v93TvV/4aUJMNYVCO6IJ5O1pOCQ69FdFyQvsAHbqYCO+3mfjEI3VPJ/f ok4Pnn76xPtMen2Jcj/M2X9UQB6uR9M= 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 X-Rspamd-Queue-Id: 9140AA0004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ibjxhy3csrph4zmun1594pj4w9trcbw5 X-HE-Tag: 1686652110-573810 X-HE-Meta: U2FsdGVkX18/hiYuSFGLkD8QFVAhF/j2oSx0YZ72y0Z8ILxB6yL+eLYWKEEM/yaa7mnLdr0Mx0d9lEedtIv9r5lPho7qjIPSUGgmWJW5wKuEf/mZQCu6Zkvd62nKPt8c8wnEYru73W4MpEJFvAnTWosJyWrGj2GfDO+WbaeaTr4z9cTBp1RDCpkcxcsuCva6sr8JNMAqDsG0rDXhK1mjCFlJNXTNJAzEerETU7xeVY77OtNIbxDYW0SYGI5FC6A63QYtTRAOeu4PuGIU1MFBmkbR7YQrDqM3foQbur95lVVKri4hi+3EBZl8I6y8UcQ3q0S3Blg1zqVuJq1oMvUkfSuS8gHbrhPVikFzU2TSM965noGyBvCy+IBi4Eqa47Ed1DG1tEDe94OkhVhB1299ZuCDsXPYRcIWCnFViIXimGLCoKfurj2yMJGe0xQ4zcp+PS827MM7tAlgZ0Kzm5YzlyRr2j4jYFTt87p/feCaQqBmm9tRYuQQHleuM8E1puOM+6dq8/kNOyjohgchW+AFW8wDPNoM/MW7z0AwqGqlcw+buupzZtwHwaimpyqWirKglWVoVDPsLwjWo9omTQYcaFrEprOvhwe4v8X575BlILBkVJe6J1U0zXf48AlFc9K730gebmk47vymwa5K8z610VrUJ+hKd30xytIDB4KFBcU4JA3D43iNpZ6fy4FWSiRpLFnZI9/JyCKAmG9fYgmgRKvha84djMB9isn/dlfj8PGp1rQ+eRXFA5F8o88xAbNpYCYJYeY2GgYNi0B151+VChOIlch9HVlotjkyN2AI/zm3Lkz9oDTiKp4PJu2A6pwxHpjUbAhEPxTXQQElcJq9dMPG8bwiQW1N5nSj869Z1MQTXraufCdKeBbrRJsi6dOZnJDhOyf19sdV0S3eN6p+NoLF8kFDVXwzzTYL9TEvkfwbxfDbXHgIsZH/ecy+EG46wkBT4ppnlUPdRLScs2Q gk+41nyU NcsdhUl6XfGfsXJkg7atRf9vU1ATHNeG1oUlyKexvIwIW9E8o7fmLKo9kb2KfcZ9qDycNH1D7I+LCQYiIzOjWGAf2AcM90hO47Bn7z9h3HPD/Hg1lmfk2cfEbizs1Kej67B+gDiaKxINCEpEoC8ZHqgv1L1h9v7cwy/z13Zf7vu41IoW32kKqbyKujtNHDiyXDLoqonP58AJzMyz4sFplqh3m56b496QUV3bemd0exl8HsHJhqI6OMCjzncxTf8NtIULuMwja2g806dz7Et7Yq5zyibO6WQpUPnuKHI7AgQ0Mp/4= 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: 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 type, slab_flags_t flags) flags |= SLAB_CACHE_DMA; } - kmalloc_caches[type][idx] = 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 == KMALLOC_NORMAL)) - kmalloc_caches[type][idx]->refcount = -1; + flags |= SLAB_NO_MERGE; + + kmalloc_caches[type][idx] = create_kmalloc_cache( + kmalloc_info[idx].name[type], + kmalloc_info[idx].size, flags, 0, + kmalloc_info[idx].size); } /*