From patchwork Tue Feb 20 16:58:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13564279 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 9DDF1C48BC3 for ; Tue, 20 Feb 2024 16:58:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6C5F6B0081; Tue, 20 Feb 2024 11:58:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF37F6B0082; Tue, 20 Feb 2024 11:58:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD1C26B0083; Tue, 20 Feb 2024 11:58:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9CCFB6B0081 for ; Tue, 20 Feb 2024 11:58:50 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4DDBFA09FF for ; Tue, 20 Feb 2024 16:58:50 +0000 (UTC) X-FDA: 81812791620.27.C7A7717 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf26.hostedemail.com (Postfix) with ESMTP id EE79D14000E for ; Tue, 20 Feb 2024 16:58:46 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=RjcBobBc; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JwFYRXTq; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=RjcBobBc; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JwFYRXTq; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708448327; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=c4OC2yNSKLqgnXzwwPex64d+kZgeSX8gpLykWcl/SKw=; b=5FFOSNKE/J9ZnW0/aPvYwW8VqmoW7S6USYVBH32eA2NRHxyImREuHKDYQ2GO5UTvHG58Ip sJck5P/YH8sG1XT29CC0U9L16m7M+eFTr+DPF67mjYXttchQIgpDr8R9OHgyA1VLScbprh 61kCqGVANo9PzK53+Jps3aY+i3mTg2Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708448327; a=rsa-sha256; cv=none; b=pKT3Wmt/aLixR1NaIlR6VsrxWEoXwwIUpgbzA5R3QJti9TRoNk7OB2wXkdJ7uFgdOsiIP4 s0/j7QLB2Oo0zNinGbshUnEUOrSbEuEV6EmU30jn6vPjqKeRLvwZcKFrB1e0kFbGn/TU2Q m3LNYk1gwYc5tF/DJjYM1R0DUlbqFro= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=RjcBobBc; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JwFYRXTq; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=RjcBobBc; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JwFYRXTq; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 411FC21FBD; Tue, 20 Feb 2024 16:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4OC2yNSKLqgnXzwwPex64d+kZgeSX8gpLykWcl/SKw=; b=RjcBobBcQec/R6BNYj9LVtWzct1RqrXs1Hh50ZzAqswNqAlsoooklOUijnTxlI1nWX3Dco vuH3FfKT6Qa+8jU56MYk0OjiBEuJ4EPlTADsYBwQBRR3tlkxiEuAvZVOq++BoGa7z3lyWR aoDDvqQfuzptU51eGvOW8ET9m4xcNHo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4OC2yNSKLqgnXzwwPex64d+kZgeSX8gpLykWcl/SKw=; b=JwFYRXTqoVvqzk23AIOLXuMzXVHV47mrjeIz+Xwiw3CpIAK0JVphGsnYKwgXL6bz1pSKYM u8JpMqFaG3AeHuDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4OC2yNSKLqgnXzwwPex64d+kZgeSX8gpLykWcl/SKw=; b=RjcBobBcQec/R6BNYj9LVtWzct1RqrXs1Hh50ZzAqswNqAlsoooklOUijnTxlI1nWX3Dco vuH3FfKT6Qa+8jU56MYk0OjiBEuJ4EPlTADsYBwQBRR3tlkxiEuAvZVOq++BoGa7z3lyWR aoDDvqQfuzptU51eGvOW8ET9m4xcNHo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4OC2yNSKLqgnXzwwPex64d+kZgeSX8gpLykWcl/SKw=; b=JwFYRXTqoVvqzk23AIOLXuMzXVHV47mrjeIz+Xwiw3CpIAK0JVphGsnYKwgXL6bz1pSKYM u8JpMqFaG3AeHuDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1915E13A93; Tue, 20 Feb 2024 16:58:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GJHYBUXa1GVKXQAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 16:58:45 +0000 From: Vlastimil Babka Date: Tue, 20 Feb 2024 17:58:25 +0100 Subject: [PATCH 1/3] mm, slab: deprecate SLAB_MEM_SPREAD flag MIME-Version: 1.0 Message-Id: <20240220-slab-cleanup-flags-v1-1-e657e373944a@suse.cz> References: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> In-Reply-To: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino Cc: Zheng Yejian , Xiongwei Song , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Vlastimil Babka , Steven Rostedt X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1731; i=vbabka@suse.cz; h=from:subject:message-id; bh=OddJ5DHeDgks/i1mqhLaA/c2lRjGQhZqtVTweHMQxDw=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBl1No9wmY1D3tW/Cy64eGuViYQaGuyi/p0I9ZML 1aOynVc32uJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZdTaPQAKCRC74LB10kWI mgcCB/9ah3oEc1eVnw/8rJfS4V2CrkLLtkwjbxIk0QO1Y0hJK6fdAYScMioTiqBbFz2fYneiEib unIEdHVvpl+axQ6ErHTm8ti5I3TyU4MWWs83wr4c2KDwr6M1dl/PvpBvMynOrlEipojbhKdzBUG M7r0KCDPswYFY/bWZNDMSglmuV4rdwkzWpAlBnmUSK1ARpf/CL/dLuc8EoPraztYVvBTuVl7/sS yeaXUhG1SHr+j+ewEl+8Ng27ejIu7HOiappS80WyxN0awRxddapuB+uGZB7Oe88F1qMmz88+5/T Zwh17MejM5IUm/PPb+QCsLgpmJBon11M/C4qFpCzuDCoY2ct X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Queue-Id: EE79D14000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: wm558jt7yabzpjy7ja9dcbct6546j8ty X-HE-Tag: 1708448326-511967 X-HE-Meta: U2FsdGVkX184hgnVv9KIeOIzBr1bk2dUSGpwhVGjyj3/YeA1Gg/dJNqp/2LheJ231c51Csc2JrEGvR46i8vzBjMMNzgzaY4fOMPOvkrbPZCX/1bzTWSujZsdTOwcVo+LYbPksX8bsryBohMt4PTmje0RuN5XtKSlyrYTJ1SYjl3L//mmeGlvxnV5AUWZ8qdZFtoHRVbmaBWUMbfl+QltRY34W4NqZQVfgkCGLHiig0+LrYO6JFRqek+oFeHFAX4bbqrzGA5jIv7dmwR+y5ZUxlDdwYgK+tdPM39MXj3rGS9jNkZIDIYYdpTlmwz+OjHiCpBeTDNQTlxt93RxATMACXdu1+BhCYv65uqAo6BXVAHI+5R/jNyVkKcU7FgJPqI/LoFCtGCFR7JErdcQhRaanv/HeqLlcrzJzuwIlJFyGthUKzL9LUGcvGiqBgfAhhfSJ+9m4+6ZOAx65tolX4JEYDiS1tJH0d9WHoy+uzyZj3N0znS58a+Fi/NkNJunOC6aVPRt02PF/rCiWabry0IecwE+WRLQm4Ag0HVCRj+W4Q1orZdW8GJimDDAVQ0Mek9b7L3F/FdGRDoC4oZtXn0MZQyCsJs7WzP6ZPsU7/M9LBivVPRdL1kORbWXGtd1zsmNVwRBAknyg1eh7doKPp8t3jJ+kvEBl7wZhOZ62YzqB4pOYiDhrSbF+iDywrXB6doZsQdEuBo+EnnKw19jYcJtQ74zpBoFhrSYJje/H2MOtOpOb9pztVFHhKhr/eBA9nm0D0q1FCTftG8QiUaEk2m+62Kgw+Xr+APWwtvT4wrIFWw079YygE8REXAVFv9TfRglEHs8oS16Sk8DsMpOutYqgrkMcPEupmNgkfyE6SzkVRTQAvJkftRMPDzprOuUX2t/rxQ1sjwrksNz3re/kL1cYvGPz0wAVmR5P2r5coogSu/mupE2jDXoztiOvIEl5JF5P4UmIfHH17zecwH4yHT jUWQ+j7J a7Momk1svvkzgaeMQsKw5kk02xVEU4yWe+zGsb7qJhHl7VOoa0tNOIRkJFRv20NW/g07qBiEpa5VO5sAdp9UOXPA9+iE0+NrxDU5GbthXWuA5iaDoqA8Ixns+e4PWjroddM8PBdQGlVIzs1Y+uU+53zOWk9PDNwMsjJ2KiqCOhSnYVSH34CJ8gIELqGVzpgYDWKLyLq12ahPFs6wi6bVPDb7ddB2povPMU29EwwQkqeYxvJX2dHopT7YwbEy7JjsoVe593b0kmDiSPNQiW3mt8G36lsKMTaNzUfvwototq2grqa5yXBk9z95ubhByjN1ubL9sokYYX8hQlfEewyDyja5tfW/+/3mwZvew0Cqc59Ql1waRg/b51Fp2ydysac3UIsUFMFcL8XmZ26buLhbbKL8A91x8Seuzn+MqHW5zfOT3dd0qnH3k+hE444trYXvn/SruQIukxjycuMsTcc3cfjS0UA== 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: The SLAB_MEM_SPREAD flag used to be implemented in SLAB, which was removed. SLUB instead relies on the page allocator's NUMA policies. Change the flag's value to 0 to free up the value it had, and mark it for full removal once all users are gone. Reported-by: Steven Rostedt Closes: https://lore.kernel.org/all/20240131172027.10f64405@gandalf.local.home/ Signed-off-by: Vlastimil Babka Tested-by: Xiongwei Song Reviewed-by: Xiongwei Song Reviewed-by: Chengming Zhou Reviewed-by: Roman Gushchin --- include/linux/slab.h | 5 +++-- mm/slab.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index b5f5ee8308d0..6252f44115c2 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -96,8 +96,6 @@ */ /* Defer freeing slabs to RCU */ #define SLAB_TYPESAFE_BY_RCU ((slab_flags_t __force)0x00080000U) -/* Spread some memory over cpuset */ -#define SLAB_MEM_SPREAD ((slab_flags_t __force)0x00100000U) /* Trace allocations and frees */ #define SLAB_TRACE ((slab_flags_t __force)0x00200000U) @@ -164,6 +162,9 @@ #endif #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ +/* Obsolete unused flag, to be removed */ +#define SLAB_MEM_SPREAD 0 + /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. * diff --git a/mm/slab.h b/mm/slab.h index 54deeb0428c6..f4534eefb35d 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -469,7 +469,6 @@ static inline bool is_kmalloc_cache(struct kmem_cache *s) SLAB_STORE_USER | \ SLAB_TRACE | \ SLAB_CONSISTENCY_CHECKS | \ - SLAB_MEM_SPREAD | \ SLAB_NOLEAKTRACE | \ SLAB_RECLAIM_ACCOUNT | \ SLAB_TEMPORARY | \ From patchwork Tue Feb 20 16:58:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13564277 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 49AA2C5475B for ; Tue, 20 Feb 2024 16:58:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85D46B0080; Tue, 20 Feb 2024 11:58:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D57BF6B007E; Tue, 20 Feb 2024 11:58:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC0766B0081; Tue, 20 Feb 2024 11:58:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 93C066B0080 for ; Tue, 20 Feb 2024 11:58:49 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 697E18079F for ; Tue, 20 Feb 2024 16:58:49 +0000 (UTC) X-FDA: 81812791578.02.0FE4ACD Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf17.hostedemail.com (Postfix) with ESMTP id 0C5EF40011 for ; Tue, 20 Feb 2024 16:58:46 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=uUF45UK4; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=OFqlH8t9; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=uUF45UK4; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=OFqlH8t9; dmarc=none; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 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=1708448327; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sZ+8lSmxyKMz7aX7YkStMli4RcGBfBcmvqFztfMzFZc=; b=yZ8XuLkp039ec/AO9MCLL2uAzbyLSxlHwTLOmF+RX/KTnBx62LzO5RLL27bamsoI8gqAND 5wakIkK806jeqJ645OHiqypc4SsThvx7X1v4v6C4tUGEzkjjiMM5OMhSRCJE6pMlK8I0ij rZ0mOKp9l/D8IqaIO24d55Fy2Cua8SA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=uUF45UK4; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=OFqlH8t9; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=uUF45UK4; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=OFqlH8t9; dmarc=none; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708448327; a=rsa-sha256; cv=none; b=rLsLheIri7jymVox1wh9ab7lUyHkZRClSsi3NHrAl8sDIn5yvT7K0ZFh1WA4yYKbPKVbnl ck8I1ged91rjv05jEqbCeslSSAotPvS1ecg/ZbjXYvzRNIMSzHxNV8jMMV3n41ULGeGY5F T4/BreX0/rP0z+QNhDQyIoqdzqJH+xs= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5A1831F8AB; Tue, 20 Feb 2024 16:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sZ+8lSmxyKMz7aX7YkStMli4RcGBfBcmvqFztfMzFZc=; b=uUF45UK4Gg0LF+iJE/VcP7egXwqgT9qiIRxcdAKOPbnKBMHr5e0Kc6KbsY0AADOvwtoseX 8bqbKM62R19Io+mgv3AC8zKACBOnh+ucIdm9sKv734diu8FSMMcfBXmAZx8zgeRmnp+3AC kBzONf6JMFdnjZAp4mpKVa3NNCfjdjY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sZ+8lSmxyKMz7aX7YkStMli4RcGBfBcmvqFztfMzFZc=; b=OFqlH8t9pKEKJdK2N0I8c7Lb3NLXdlRGvN6eB+34GXU9VHPADtBLvFszaOhIkIU4LDVOTV 3ivEka8pFYPbwLBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sZ+8lSmxyKMz7aX7YkStMli4RcGBfBcmvqFztfMzFZc=; b=uUF45UK4Gg0LF+iJE/VcP7egXwqgT9qiIRxcdAKOPbnKBMHr5e0Kc6KbsY0AADOvwtoseX 8bqbKM62R19Io+mgv3AC8zKACBOnh+ucIdm9sKv734diu8FSMMcfBXmAZx8zgeRmnp+3AC kBzONf6JMFdnjZAp4mpKVa3NNCfjdjY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708448325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sZ+8lSmxyKMz7aX7YkStMli4RcGBfBcmvqFztfMzFZc=; b=OFqlH8t9pKEKJdK2N0I8c7Lb3NLXdlRGvN6eB+34GXU9VHPADtBLvFszaOhIkIU4LDVOTV 3ivEka8pFYPbwLBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3A49B13A94; Tue, 20 Feb 2024 16:58:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SA77DUXa1GVKXQAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 16:58:45 +0000 From: Vlastimil Babka Date: Tue, 20 Feb 2024 17:58:26 +0100 Subject: [PATCH 2/3] mm, slab: use an enum to define SLAB_ cache creation flags MIME-Version: 1.0 Message-Id: <20240220-slab-cleanup-flags-v1-2-e657e373944a@suse.cz> References: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> In-Reply-To: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino Cc: Zheng Yejian , Xiongwei Song , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Vlastimil Babka X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6508; i=vbabka@suse.cz; h=from:subject:message-id; bh=QNJRHlmDrZynn1U8943ItQzMzlmVSA/ls2WuKXFCGgI=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBl1No/ygsO500Ssb9XAkmAz2HhpQIKGfJtG4YPQ qOlBzr+WcWJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZdTaPwAKCRC74LB10kWI mr1zCACerO93/YH+0xXf3hmj9+Ly4RkBTkbOhSmsHedvITBcHdJXKdDsWBSKDvHBhaBrbYG/yw4 ETY87JH94vda42AmV7XJhgJazaGSBZrOXYqc7+p6AXMPbIakyeejJaZC3auz5lG1smlQTfkCyzw UguX8Eka+Rs2SfLGYJnTUeWJPVbI1IV3yoymNc2ee2+E53VoW8WEHLnfawSrp9nF54jEEM9kL5r 3RrsKEiI2lbguKI8+3HzLF+PPT5Ufm46y2zTqlcQkchaGnx/pL3wvZRKgiUrvKXLxjXnlsvx83f X+J/gmD8lECXksKyAhTcae7i21y5P2kZEg7iHI6844Z8mnqI X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Queue-Id: 0C5EF40011 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 35t41fbo7rh5mwy5gie7qa7rkuxa6n7h X-HE-Tag: 1708448326-967549 X-HE-Meta: U2FsdGVkX1+vw0o7ToJpSI1PWDVINdQdM7pnd0XVBEIgA3fQzbhZ4vGmccn+3fhrP32EGowqqazvXdLJY5hFrC1Hdzt0k0t/vPtzzoWSQ8a8CkQudT/hcZvFafthFzfBCs61xibcgRfLPVCUw1J+cLcToaMf9QNDHABVCPrcZAhrxkDvRfVL4yPPjxQ5en/tVL3BNxyUoxilw4x6mPcHybKPA+WAetPGX+xTALRryOpM+9HpTekOvygO8UR6PJbtfuHluC2FRmoZONpjprT3CSU0AHLa1sY7KsEucw+vBtJqASe/wIJPRVx4t0x5253V/0LfM3/vlMgRqwgtnf0Rxo/MmCzB7SNlxlKefAhstODewPdsH128joP4GaRXue7qcLmTfGKHS+608K/MzNt965qnReGDwluGKtmoNmlcIIlAbQhnIkN2ih8EVvkL+tg1DrXKsO3WKD1lssIwg7Bx+kJ8a3PU8IcAphiN9U1t5fjB/M56vy60Tr1qEPrDsf6vB2vePfi4MmGcWg1L2ZfDwCt4W/HJbBlCOXFpCzaudhZ3lR7I6g2yhGRLjuyrzEUoiCGpytLryD2T/7YDtjVsD3x+7RYTkGQjTMhnJfEJQux2BptXqKjcn00zEZEaPYmXOcQWvZo7aKdBPJS+Riv/XhdT9fB+5+FxU6EMg8RJJBr8KKLvMwQlXaI09+by4rgmw9HhMxL5+HLlsm2T1cJ4q5kOVtvlzZW9BmLurw4GoOw7VjXcl4jtmpTiyqmlORTYOme2JXLkGiGAV3xCmnJaqO+FqxApzireIWYKcxp5rDjw2KLkT5XBez4N3AIMleBstxki0xcjJmdTDnCYgQTgP8jHnuMsbx+qRnRZks5kujWTMvkUEyOuVsuTa8cce5WV/pWfamKtl4lWOJaN17gAleKmy4BxqlAGu+0vPmhn0pUBIrcZS6OTSqyTAPBwI26MQoGTTzA2fONwaaFPGeL 08cOvHT6 F62GUDe7wSUH+awOX4WWEJ3MtXxy5+as8TkkA+tpC17dZGPr8MeT2Y2ZICBbo6Irp9AkggB7XoiA4wzY3zdbZzyi2+F8aKDlPKPFCw7pnAfVEgU1b/cdnFkfrCuI4CqsoFtB5H6xwXfHQmLempmgh4W6qyVIq2iBOIqNkMD9aThkk/IAnszOl0wC/RQ3q4LL/B9Ka0/xm6Z0Q994ZodOGNzpzaKAlOHKRrCeo1Pz/2xVay7yJ9XPqvQvFjXaAMRLhWUjSSLh2CB5TG1kP2TnOKJCOgsQ5uL/K6e1oIDpwpuoc2MXlHwcrpU4FbyZ6USCnxkU7q5M+EwGqLiQPK00Uqt/tO0mCrRYHj5yj 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: The values of SLAB_ cache creation flagsare defined by hand, which is tedious and error-prone. Use an enum to assign the bit number and a __SF_BIT() macro to #define the final flags. This renumbers the flag values, which is OK as they are only used internally. Signed-off-by: Vlastimil Babka Tested-by: Xiongwei Song Reviewed-by: Xiongwei Song Reviewed-by: Chengming Zhou Reviewed-by: Roman Gushchin --- include/linux/slab.h | 81 ++++++++++++++++++++++++++++++++++++++-------------- mm/slub.c | 6 ++-- 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 6252f44115c2..f893a132dd5a 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -21,29 +21,68 @@ #include #include +enum _slab_flag_bits { + _SLAB_CONSISTENCY_CHECKS, + _SLAB_RED_ZONE, + _SLAB_POISON, + _SLAB_KMALLOC, + _SLAB_HWCACHE_ALIGN, + _SLAB_CACHE_DMA, + _SLAB_CACHE_DMA32, + _SLAB_STORE_USER, + _SLAB_PANIC, + _SLAB_TYPESAFE_BY_RCU, + _SLAB_TRACE, +#ifdef CONFIG_DEBUG_OBJECTS + _SLAB_DEBUG_OBJECTS, +#endif + _SLAB_NOLEAKTRACE, + _SLAB_NO_MERGE, +#ifdef CONFIG_FAILSLAB + _SLAB_FAILSLAB, +#endif +#ifdef CONFIG_MEMCG_KMEM + _SLAB_ACCOUNT, +#endif +#ifdef CONFIG_KASAN_GENERIC + _SLAB_KASAN, +#endif + _SLAB_NO_USER_FLAGS, +#ifdef CONFIG_KFENCE + _SLAB_SKIP_KFENCE, +#endif +#ifndef CONFIG_SLUB_TINY + _SLAB_RECLAIM_ACCOUNT, +#endif + _SLAB_OBJECT_POISON, + _SLAB_CMPXCHG_DOUBLE, + _SLAB_FLAGS_LAST_BIT +}; + +#define __SF_BIT(nr) ((slab_flags_t __force)(1U << (nr))) /* * Flags to pass to kmem_cache_create(). * The ones marked DEBUG need CONFIG_SLUB_DEBUG enabled, otherwise are no-op */ /* DEBUG: Perform (expensive) checks on alloc/free */ -#define SLAB_CONSISTENCY_CHECKS ((slab_flags_t __force)0x00000100U) +#define SLAB_CONSISTENCY_CHECKS __SF_BIT(_SLAB_CONSISTENCY_CHECKS) /* DEBUG: Red zone objs in a cache */ -#define SLAB_RED_ZONE ((slab_flags_t __force)0x00000400U) +#define SLAB_RED_ZONE __SF_BIT(_SLAB_RED_ZONE) /* DEBUG: Poison objects */ -#define SLAB_POISON ((slab_flags_t __force)0x00000800U) +#define SLAB_POISON __SF_BIT(_SLAB_POISON) /* Indicate a kmalloc slab */ -#define SLAB_KMALLOC ((slab_flags_t __force)0x00001000U) +#define SLAB_KMALLOC __SF_BIT(_SLAB_KMALLOC) /* Align objs on cache lines */ -#define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U) +#define SLAB_HWCACHE_ALIGN __SF_BIT(_SLAB_HWCACHE_ALIGN) /* Use GFP_DMA memory */ -#define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U) +#define SLAB_CACHE_DMA __SF_BIT(_SLAB_CACHE_DMA) /* Use GFP_DMA32 memory */ -#define SLAB_CACHE_DMA32 ((slab_flags_t __force)0x00008000U) +#define SLAB_CACHE_DMA32 __SF_BIT(_SLAB_CACHE_DMA32) /* DEBUG: Store the last owner for bug hunting */ -#define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U) +#define SLAB_STORE_USER __SF_BIT(_SLAB_STORE_USER) /* Panic if kmem_cache_create() fails */ -#define SLAB_PANIC ((slab_flags_t __force)0x00040000U) +#define SLAB_PANIC __SF_BIT(_SLAB_PANIC) /* * SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS! * @@ -95,19 +134,19 @@ * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU. */ /* Defer freeing slabs to RCU */ -#define SLAB_TYPESAFE_BY_RCU ((slab_flags_t __force)0x00080000U) +#define SLAB_TYPESAFE_BY_RCU __SF_BIT(_SLAB_TYPESAFE_BY_RCU) /* Trace allocations and frees */ -#define SLAB_TRACE ((slab_flags_t __force)0x00200000U) +#define SLAB_TRACE __SF_BIT(_SLAB_TRACE) /* Flag to prevent checks on free */ #ifdef CONFIG_DEBUG_OBJECTS -# define SLAB_DEBUG_OBJECTS ((slab_flags_t __force)0x00400000U) +# define SLAB_DEBUG_OBJECTS __SF_BIT(_SLAB_DEBUG_OBJECTS) #else # define SLAB_DEBUG_OBJECTS 0 #endif /* Avoid kmemleak tracing */ -#define SLAB_NOLEAKTRACE ((slab_flags_t __force)0x00800000U) +#define SLAB_NOLEAKTRACE __SF_BIT(_SLAB_NOLEAKTRACE) /* * Prevent merging with compatible kmem caches. This flag should be used @@ -119,23 +158,23 @@ * - performance critical caches, should be very rare and consulted with slab * maintainers, and not used together with CONFIG_SLUB_TINY */ -#define SLAB_NO_MERGE ((slab_flags_t __force)0x01000000U) +#define SLAB_NO_MERGE __SF_BIT(_SLAB_NO_MERGE) /* Fault injection mark */ #ifdef CONFIG_FAILSLAB -# define SLAB_FAILSLAB ((slab_flags_t __force)0x02000000U) +# define SLAB_FAILSLAB __SF_BIT(_SLAB_FAILSLAB) #else # define SLAB_FAILSLAB 0 #endif /* Account to memcg */ #ifdef CONFIG_MEMCG_KMEM -# define SLAB_ACCOUNT ((slab_flags_t __force)0x04000000U) +# define SLAB_ACCOUNT __SF_BIT(_SLAB_ACCOUNT) #else # define SLAB_ACCOUNT 0 #endif #ifdef CONFIG_KASAN_GENERIC -#define SLAB_KASAN ((slab_flags_t __force)0x08000000U) +#define SLAB_KASAN __SF_BIT(_SLAB_KASAN) #else #define SLAB_KASAN 0 #endif @@ -145,10 +184,10 @@ * Intended for caches created for self-tests so they have only flags * specified in the code and other flags are ignored. */ -#define SLAB_NO_USER_FLAGS ((slab_flags_t __force)0x10000000U) +#define SLAB_NO_USER_FLAGS __SF_BIT(_SLAB_NO_USER_FLAGS) #ifdef CONFIG_KFENCE -#define SLAB_SKIP_KFENCE ((slab_flags_t __force)0x20000000U) +#define SLAB_SKIP_KFENCE __SF_BIT(_SLAB_SKIP_KFENCE) #else #define SLAB_SKIP_KFENCE 0 #endif @@ -156,9 +195,9 @@ /* The following flags affect the page allocator grouping pages by mobility */ /* Objects are reclaimable */ #ifndef CONFIG_SLUB_TINY -#define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0x00020000U) +#define SLAB_RECLAIM_ACCOUNT __SF_BIT(_SLAB_RECLAIM_ACCOUNT) #else -#define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0) +#define SLAB_RECLAIM_ACCOUNT 0 #endif #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ diff --git a/mm/slub.c b/mm/slub.c index 2ef88bbf56a3..a93c5a17cbbb 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -306,13 +306,13 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s) /* Internal SLUB flags */ /* Poison object */ -#define __OBJECT_POISON ((slab_flags_t __force)0x80000000U) +#define __OBJECT_POISON __SF_BIT(_SLAB_OBJECT_POISON) /* Use cmpxchg_double */ #ifdef system_has_freelist_aba -#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0x40000000U) +#define __CMPXCHG_DOUBLE __SF_BIT(_SLAB_CMPXCHG_DOUBLE) #else -#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0U) +#define __CMPXCHG_DOUBLE 0 #endif /* From patchwork Tue Feb 20 16:58:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13564276 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 16E06C48BC3 for ; Tue, 20 Feb 2024 16:58:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73EEE6B0075; Tue, 20 Feb 2024 11:58:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C9356B007E; Tue, 20 Feb 2024 11:58:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 540C16B0080; Tue, 20 Feb 2024 11:58:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3FC9D6B0075 for ; Tue, 20 Feb 2024 11:58:49 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0D530A09F2 for ; Tue, 20 Feb 2024 16:58:49 +0000 (UTC) X-FDA: 81812791578.08.CEA4D45 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf26.hostedemail.com (Postfix) with ESMTP id 09837140010 for ; Tue, 20 Feb 2024 16:58:46 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708448327; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bDwZLyEk1WMILC8wJ4ZtAG5w+ulImAgRHCRAxEjy7QI=; b=fmY316u/yyDsjLLAZNYd4we8leASwNIOyGvdXJpIc8LzUTyaenw2QIkKvKoWCyq0M02ChA xBkmRfm3cVP/wTAOGEQDZM0eycYrECtRrUfRa2rJeDOf6hChkm2x8aGju8KRUl5k1NiUya zlgHd43P/Th8vWI06irCCO1PtpQ8STo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708448327; a=rsa-sha256; cv=none; b=JJ3xhF72MVqDNuh7iHbzPlVme6bEBfcGbwlJKnMp+wxDhW6q4h/2OO4ATQ4+3agKTEVlg7 JzIyyJZ67vxaoMFtLb6IM9ko1a47/KKVuOjXz2dC4Gi+yVvoFuxcjLApXu6FAchpcIJzM7 Bh/K78AWjie4VNznYyk/HDm2t+0nHyA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7BAC91F8AC; Tue, 20 Feb 2024 16:58:45 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 578FD139D0; Tue, 20 Feb 2024 16:58:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id CEsVFUXa1GVKXQAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 16:58:45 +0000 From: Vlastimil Babka Date: Tue, 20 Feb 2024 17:58:27 +0100 Subject: [PATCH 3/3] mm, slab, kasan: replace kasan_never_merge() with SLAB_NO_MERGE MIME-Version: 1.0 Message-Id: <20240220-slab-cleanup-flags-v1-3-e657e373944a@suse.cz> References: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> In-Reply-To: <20240220-slab-cleanup-flags-v1-0-e657e373944a@suse.cz> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino Cc: Zheng Yejian , Xiongwei Song , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Vlastimil Babka X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3299; i=vbabka@suse.cz; h=from:subject:message-id; bh=8dSL5GfjNj31WZBzU1RArK2AdDIYjJIAED64yK7aPeY=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBl1NpC+Ron5uAKKATthXFJII/xHLgqduJBWbRQt JULEgGEAwCJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZdTaQgAKCRC74LB10kWI mt6zB/9ix1+cbRLwfxeQ4PhmyOPOXIy8AuaLRA62hsETFxjPOeumiQBXsvdbnzwsuTrbTPtKCkZ d9K8yRw2rpCG80loeAT/9uGKYzkw3j1XJrIDpXnpsp8/Jtb8zF38E0za2jDekAKVKziUs+xQQ1c VGAgxP7oyKW/Scrkzja41qVLuoQIjHK0k+XLXLFgkgs+iCPInGvRs4Nw50YuoG4okbZHICuchYX EJ07EGSqae4vCKCv3jipCwptC1gLJZ1gNSnfYu6Xla4IZmsWsXnVgCegTbcY8e9LdmySCBYecUL 5FttxJXT+6E5QTHUN3Tw59fKT1yFq1PkGQFvhgv0TDslB5er X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Queue-Id: 09837140010 X-Rspam-User: X-Stat-Signature: 55qzuw3f3dt1ota44ouo4mcgbza4qh78 X-Rspamd-Server: rspam03 X-HE-Tag: 1708448326-558054 X-HE-Meta: U2FsdGVkX19Sbru8GdILSwduyYCD8y11yJlC8IYYubD6olWcLA9P4IpXtlVDSPRB8lExtR2/kcXGsPF4EMrCvrSlC8oNGj6dJLXA768GMzZVXCE1/BFW7jy9yGgU3MKrhtYGnHqpH5ZBY5IJSl0nHxxe/rY9efVRScWQie/fdzlrcGUuW6DOi+7QkphzJsLoLXqnXNnmprIlQWELnB7uJGewABfVus+CvZ6Sk+s4Pcd7GxK2VX/j/9KS5ebQyKoZWKz58RVwaLjp0HpnohmlvQ8VTUiilTygF1TIMSRFuqhjyFq4DyEWFj4H/CIkgNFOBqswQqQkM7Q9dqg+7G7RIs1OWso2fhKYR1YRXyfT0otNS3LtLPK7GJ0g3qhRG/PEspWQ59LCrbSEW5NU2n/IB+73SPwZ4P+k8kptE2qJ2dYSw04B6dEMoiOOq8fRa5SslaeTA+ILKtSbI9pcT/s4VlvO6YVDgXmzRZxWyFchkdOGdqvKL95sP5coiWigMsj++vd0j5IDNdqpmBskqRARnuZkmFV0AjEWIdf+DERhd6DtOLHWI2NGMz2jvq8pdIkQl06+tocdqGsvM74D2xCnmHVIMaTBEEKUUgXxhFAcc9Yz3lwsvtvu4yy6ODTZgWjv89ByKiGwJKYyKsrQnXWlN5O6zBDySEihMnuChcaaDk4ct82U6WFpHZ+A5DHqgpdRwdFQMmrQAFyUofToWdVqSn8pxfcNHXBTFaaKiYgmg3g3FAPD8EFKKPRvW58aCv4k4I1eHlsgy7C7Sd/b8TYmdF5fYffeIYFgneAsViiCHtlvAzKt0BSKj9XUbJikP6UC/A7tHmdl3zpVzQEtRel7mED4/TnXJ5IVV/MYSeJp5utr1L3UB5nvxtSYV67wv/CJu6UFoqn0avdlUH+TigfUFYoIH9ALdhO0 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: The SLAB_KASAN flag prevents merging of caches in some configurations, which is handled in a rather complicated way via kasan_never_merge(). Since we now have a generic SLAB_NO_MERGE flag, we can instead use it for KASAN caches in addition to SLAB_KASAN in those configurations, and simplify the SLAB_NEVER_MERGE handling. Signed-off-by: Vlastimil Babka Tested-by: Xiongwei Song Reviewed-by: Chengming Zhou Reviewed-by: Andrey Konovalov --- include/linux/kasan.h | 6 ------ mm/kasan/generic.c | 16 ++++------------ mm/slab_common.c | 2 +- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index dbb06d789e74..70d6a8f6e25d 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -429,7 +429,6 @@ struct kasan_cache { }; size_t kasan_metadata_size(struct kmem_cache *cache, bool in_object); -slab_flags_t kasan_never_merge(void); void kasan_cache_create(struct kmem_cache *cache, unsigned int *size, slab_flags_t *flags); @@ -446,11 +445,6 @@ static inline size_t kasan_metadata_size(struct kmem_cache *cache, { return 0; } -/* And thus nothing prevents cache merging. */ -static inline slab_flags_t kasan_never_merge(void) -{ - return 0; -} /* And no cache-related metadata initialization is required. */ static inline void kasan_cache_create(struct kmem_cache *cache, unsigned int *size, diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index df6627f62402..d8b78d273b9f 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -334,14 +334,6 @@ DEFINE_ASAN_SET_SHADOW(f3); DEFINE_ASAN_SET_SHADOW(f5); DEFINE_ASAN_SET_SHADOW(f8); -/* Only allow cache merging when no per-object metadata is present. */ -slab_flags_t kasan_never_merge(void) -{ - if (!kasan_requires_meta()) - return 0; - return SLAB_KASAN; -} - /* * Adaptive redzone policy taken from the userspace AddressSanitizer runtime. * For larger allocations larger redzones are used. @@ -372,13 +364,13 @@ void kasan_cache_create(struct kmem_cache *cache, unsigned int *size, /* * SLAB_KASAN is used to mark caches that are sanitized by KASAN * and that thus have per-object metadata. - * Currently this flag is used in two places: + * Currently this flag is used in one place: * 1. In slab_ksize() to account for per-object metadata when * calculating the size of the accessible memory within the object. - * 2. In slab_common.c via kasan_never_merge() to prevent merging of - * caches with per-object metadata. + * Additionally, we use SLAB_NO_MERGE to prevent merging of caches + * with per-object metadata. */ - *flags |= SLAB_KASAN; + *flags |= SLAB_KASAN | SLAB_NO_MERGE; ok_size = *size; diff --git a/mm/slab_common.c b/mm/slab_common.c index 238293b1dbe1..7cfa2f1ce655 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -50,7 +50,7 @@ static DECLARE_WORK(slab_caches_to_rcu_destroy_work, */ #define SLAB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \ SLAB_TRACE | SLAB_TYPESAFE_BY_RCU | SLAB_NOLEAKTRACE | \ - SLAB_FAILSLAB | SLAB_NO_MERGE | kasan_never_merge()) + SLAB_FAILSLAB | SLAB_NO_MERGE) #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \ SLAB_CACHE_DMA32 | SLAB_ACCOUNT)