From patchwork Fri Feb 23 18:27:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13569861 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 B67E2C5478C for ; Fri, 23 Feb 2024 18:27:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0319B6B0078; Fri, 23 Feb 2024 13:27:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFCBF6B0075; Fri, 23 Feb 2024 13:27:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9CEF6B007D; Fri, 23 Feb 2024 13:27:43 -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 C69956B0075 for ; Fri, 23 Feb 2024 13:27:43 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7452E1C0F69 for ; Fri, 23 Feb 2024 18:27:43 +0000 (UTC) X-FDA: 81823902006.20.2B0ADC1 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf07.hostedemail.com (Postfix) with ESMTP id 1A5FA40003 for ; Fri, 23 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="nMZra/aK"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="nMZra/aK"; dmarc=none; spf=pass (imf07.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=1708712861; 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=7brqYZxmuxrRKSYQEeacefCe+ctYuF6xWTXM5McbA8I=; b=hvA1yNTUhc1RBvMHvI5JqhYlfrsCwEiwPo/P/dJpXF5R0KUCoJatdh329uZFVuIXMnYxsr /eXPWp6F1zNHz7Y+f58FFW6GdaTjGtR5w1M513L6EDDhMbRG5ToM644PVEHF1UCKLQbB/H FR2cjcH4lOSOxNv08h+I7nVXHi/sgjQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="nMZra/aK"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="nMZra/aK"; dmarc=none; spf=pass (imf07.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=1708712861; a=rsa-sha256; cv=none; b=ZzaYPtMb9XGdUvT6h6hmD8yKeM0wiTTvH4pjNDPX987QjZ0AhIUKUPncaJYQihakblpu2+ 2FILxapq7JUMe0Yp4PwoLHwLbcordVZWTXV6vBqBYAiAxJm5yRPsjxsCzi7x+RxXemCQwN zfOyApuyryf0pqZGfxDdiq5IhnzyP8s= 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 28A201FC2A; Fri, 23 Feb 2024 18:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708712859; 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=7brqYZxmuxrRKSYQEeacefCe+ctYuF6xWTXM5McbA8I=; b=Qd8LsPfVNYRjMhedMtLQ9mEmCVsypU2uQh2vZjA/HgXPPaDR8h6Ob8cd8kWmdHVkIEyWc5 tZICMKAYYO83n5ZTXm+kGImHl31S91luqmF99uGMQrY23pYLrC8FYIbz+5qVyYmtbNCrKw Ow1WIWaUaW6G1ZKB3a3lruEOoFTS/EA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708712859; 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=7brqYZxmuxrRKSYQEeacefCe+ctYuF6xWTXM5McbA8I=; b=nMZra/aKnnlj9lkcc3nn6p3CDtjcpzXA6pWZ7RKjeB9Du6opgh5HJm8+D3P0y4LF8SXZOz FXDZgr9xc/wiCJCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708712859; 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=7brqYZxmuxrRKSYQEeacefCe+ctYuF6xWTXM5McbA8I=; b=Qd8LsPfVNYRjMhedMtLQ9mEmCVsypU2uQh2vZjA/HgXPPaDR8h6Ob8cd8kWmdHVkIEyWc5 tZICMKAYYO83n5ZTXm+kGImHl31S91luqmF99uGMQrY23pYLrC8FYIbz+5qVyYmtbNCrKw Ow1WIWaUaW6G1ZKB3a3lruEOoFTS/EA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708712859; 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=7brqYZxmuxrRKSYQEeacefCe+ctYuF6xWTXM5McbA8I=; b=nMZra/aKnnlj9lkcc3nn6p3CDtjcpzXA6pWZ7RKjeB9Du6opgh5HJm8+D3P0y4LF8SXZOz FXDZgr9xc/wiCJCA== 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 008AE13AC1; Fri, 23 Feb 2024 18:27:38 +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 gJluO5rj2GUaTQAAD6G6ig (envelope-from ); Fri, 23 Feb 2024 18:27:38 +0000 From: Vlastimil Babka Date: Fri, 23 Feb 2024 19:27:17 +0100 Subject: [PATCH v2 1/3] mm, slab: deprecate SLAB_MEM_SPREAD flag MIME-Version: 1.0 Message-Id: <20240223-slab-cleanup-flags-v2-1-02f1753e8303@suse.cz> References: <20240223-slab-cleanup-flags-v2-0-02f1753e8303@suse.cz> In-Reply-To: <20240223-slab-cleanup-flags-v2-0-02f1753e8303@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=1937; i=vbabka@suse.cz; h=from:subject:message-id; bh=xj2FbXNZUF1ZX1Yi4h91pRFSVKXZaW8ItJyLfGmRRuU=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBl2OOSfAZ6NhpOQjvkRl542eUJ71NZdn+YC7Mu6 stXO0E2hXKJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZdjjkgAKCRC74LB10kWI mib0CACG+JmJHKxWWP/7G2u05sgQbj5Lct25lOvrv1QuCza7ZVTLPiTE2iE+BTE0PtH2dbdAYA5 sl5xS/B71qhL1xjxpXhlT48vuelChx7oiMjOTPC1tbcKaU3HM68z420oR4LMO374DAlIaO5zlXu 3UBG5MbidRfJxcqpQ8bWT8BUApwBuLjP1/psufGw7UGhM8uOii58OmE81DqIaPf9+9L0upk6xw9 TNwRePi/w3rAJw42PoL6BkGJktvFbYpMLsDlfcPtjayFWVLix+Fwxkw09xUv4ZmAHSNjBDIMLjm HUnykdE/UgcYH0yBCAYi+6kvrVWPQw9wvQU/PWokxe3J3Ive X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Queue-Id: 1A5FA40003 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: na7somo3uwd1qnjw1d77oscxj8gaq8kj X-HE-Tag: 1708712860-480305 X-HE-Meta: U2FsdGVkX1/CBxkESL3jpoDTLMtkG7HQRSlaJgDsvWf9Iy+MfsFfzLBGBQC890OKfqfjR0NshB3wJ6C/nfIf8MganwfidkfYzLMn6jW9RXyU9REjM/GFIw+ow8epL+Djf8IFyBP0dbRkNHYa7V1vTjpEJwY618w77dPJMkiP1kp/HUHpAZeUEBxUXdCtHpvzGqGDmyYAmQFhpKdaWJFbh71gdD3Zhk64+5abshF3wjDLMBN1g8EUBr589yK79JV+vIJlAcVVi/vCWL2dXxnj9rwC8H1K/X6anQD8grTwqL83Y9UxiqmFJY5mIM1/8dI8cXbGYoQGQ8Bs6funcjktt4Q9Dnl/JzEGiqldMC49qCJEJWKczIpMdtZ1P6JpnswLOagjR3LAWHZWOZpheDCWeRuL8z9CpRzpJ7ZQxcGX+ZrIKnpD/LXzWji/nlDZFy7CIbZXrdRnHQszBDlL9kleXcdNoGsso+B4x/GUSivt3knTR1e9+wHCwOZj68S7duphAFmqiT+0ZNveeYiUam7tNeJb8rZ3m9HKReDIWrsIsurj4CMShyS9VROSh/GRjS8xt6+4K0saUvUD9EppV/qQjs9ZgixD2UPIFPgYMTpzgCOORpoQc4w83eEXBZhsCf+IUNGfBJQBGIWRogqpLfrY9a5fDn3GRt9pqh+vN9uX6pfvTzuH5IRxWv8j+sZCoQEj8xqw9xDEgD+/t+6tfm3o2KIduj3pMMSDvWNFu0KDTFdxW7mvc8yc6C7oU+SE0ak1Zo5dGha1in9CrL0ketVYWplO23za8djQ0TiF9nxnJhJ9R0JkW6VUWhKQIheIubU2oDISgq2PN0uUcyw7ijFChvofHaGHX84LKLhHKe9Rjw5nE9uYls0cr4kVk7KTgGmIZzc9Zb2QXIFzxFCc/Em8tLohz8/5yfUHfhKdsj9OQ/aIjTT2Qejl0e54YLeAAaoH4jPAlkNq5ylRjVDfT4k nMunwUKZ 2L7p8UCtV7Jo59oshs8d26I+qh96lwXLJT4dj8dJirOLU6F5i2/LqMBw6ux/LHZODrjhQqDV1SV5cNfQckO+HLh9QFYjRSV0rl7kuiVHA8zlvzL+5b1jDWh2epj+jBWTSMnEtk2vW/+J49FbE7NR/frtdVeNOVzLSFc14Gluh097v6xn3BfTz1yu0EObZh4Rnpr1XYSQBk18q0ArpXS/XeIp+aBMo8akktdKj5JWidoRcPlSYW2Yu7Q+enVkJz4Qk4kbbgnoNao4XDGBZzZx+SZYudUE2dHiD2bsO3P7CTGzg4Pe8vjbGfXiESx5+VtaQbWl6/6ExHsMK2NFLxvJ5mFaIr4odpKPrUjyJOMzdHhfL2gp6rjRGc+xLWCW3wZQCdLWQBjn0ws+fDBcbKIy8x/ignJPjocZ4qaOaosJEZ6m15iqftJ9ktC82Dn9HZbLnoUBSeLhiYFMM+yCwGwncV9hoiYuIUunOG0BeY/50RicBsBljE0tJRwJBdvwMJS/OjUMUPSvMeq+oNpQ= 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/ Reviewed-and-tested-by: Xiongwei Song Reviewed-by: Chengming Zhou Reviewed-by: Roman Gushchin Signed-off-by: Vlastimil Babka Acked-by: David Rientjes --- 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..b1675ff6b904 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 ((slab_flags_t __force)0U) + /* * 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 Fri Feb 23 18:27:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13569862 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 EF770C54798 for ; Fri, 23 Feb 2024 18:27:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A28F6B0075; Fri, 23 Feb 2024 13:27:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 281366B007D; Fri, 23 Feb 2024 13:27:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E86E46B007B; Fri, 23 Feb 2024 13:27:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D05426B0078 for ; Fri, 23 Feb 2024 13:27:43 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 87018C0FF8 for ; Fri, 23 Feb 2024 18:27:43 +0000 (UTC) X-FDA: 81823902006.21.BE8FCDC Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf23.hostedemail.com (Postfix) with ESMTP id 14E6D140008 for ; Fri, 23 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ii0k7MdE; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ii0k7MdE; dmarc=none; spf=pass (imf23.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 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=1708712861; 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=gdIIkjKNjW91Ug8+r97lNpU6eko4/0lhYa/nSEYrEFs=; b=DF6xPCNyMpH8amXShycJ7vICA42goQJz/4U8wVFBJbZwUT+r8CEaa/V1BTiErASuXbJK8C 5IJkPzMUYQIVHx3zdHxoslaFAAJTHHm3XKFi1xJKI5gTxDMu267gRCaSyHk419AlTgvbZG x0bvILe/Iz5ZKrJtBP289LszJTlK5DA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ii0k7MdE; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ii0k7MdE; dmarc=none; spf=pass (imf23.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708712861; a=rsa-sha256; cv=none; b=vtkYbjtqpq1HhleqX/w9k5GNtf10PqlMX71yipJlcUn3welMccXQyBGQGS9kU1G7THxS9B c11ptvYLuoQeamwX4RC1HJlRGWAvbcKhwW+UQMXqQg9WSS9X6eRMCgQh4cdrD7a0OUptRD xbgNFwR0IqQKvcq2zbcTitsJ578/myY= 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 46C87210F3; Fri, 23 Feb 2024 18:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708712859; 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=gdIIkjKNjW91Ug8+r97lNpU6eko4/0lhYa/nSEYrEFs=; b=ZmoNfrpCH0PEjyxNf8PJt4n07L7bZCydKQCWOYz8oz5GEYBsG6QDve+ZSKACVvSj31/vKA vnb2X4s6QiQsu/x8dg2lDrCZmmOs1S/ccPJnUsV6EUPCw+G8/F46WLQJEk/68NmjeqSxTA 0gy3a3suP8/Navh+ix+feX4bWYdSdmg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708712859; 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=gdIIkjKNjW91Ug8+r97lNpU6eko4/0lhYa/nSEYrEFs=; b=ii0k7MdEIfYFYmfXmE8fBw7rzdXV4rSipcrqSj2SYPJGx78peHrM+PqQzyVUbVhNQUTjWu eBu2MnLZnDDk0YBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708712859; 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=gdIIkjKNjW91Ug8+r97lNpU6eko4/0lhYa/nSEYrEFs=; b=ZmoNfrpCH0PEjyxNf8PJt4n07L7bZCydKQCWOYz8oz5GEYBsG6QDve+ZSKACVvSj31/vKA vnb2X4s6QiQsu/x8dg2lDrCZmmOs1S/ccPJnUsV6EUPCw+G8/F46WLQJEk/68NmjeqSxTA 0gy3a3suP8/Navh+ix+feX4bWYdSdmg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708712859; 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=gdIIkjKNjW91Ug8+r97lNpU6eko4/0lhYa/nSEYrEFs=; b=ii0k7MdEIfYFYmfXmE8fBw7rzdXV4rSipcrqSj2SYPJGx78peHrM+PqQzyVUbVhNQUTjWu eBu2MnLZnDDk0YBA== 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 22A6913AC7; Fri, 23 Feb 2024 18:27:39 +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 GOwlCJvj2GUaTQAAD6G6ig (envelope-from ); Fri, 23 Feb 2024 18:27:39 +0000 From: Vlastimil Babka Date: Fri, 23 Feb 2024 19:27:18 +0100 Subject: [PATCH v2 2/3] mm, slab: use an enum to define SLAB_ cache creation flags MIME-Version: 1.0 Message-Id: <20240223-slab-cleanup-flags-v2-2-02f1753e8303@suse.cz> References: <20240223-slab-cleanup-flags-v2-0-02f1753e8303@suse.cz> In-Reply-To: <20240223-slab-cleanup-flags-v2-0-02f1753e8303@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=7536; i=vbabka@suse.cz; h=from:subject:message-id; bh=Pwf3NzcoQQwCRBmd+qMj8XBoxm9DrwZf7S0mWjV+OLY=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBl2OOVBVULzhmkRIvmLB8VcoT8BDIxH1Iid/dmv SrNByJn3OSJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZdjjlQAKCRC74LB10kWI mix4B/91x98pri0nNwjdaIAvA0K80Xqlb+Ml7TNN2Kn4iCVaFEU3o+qL1kk2atqnc2Vr0QICmzo IvNPMcWRhiPc3oROrosQ4kYcUjO6sjMm3mYp99TavwSmBrdiPUltaY9UNW82evycsXiwESqgeV9 F55WmiAtDFq8aRweNmizy9g6Ro1bWuAWFed1CHPiWBiQtWTtqrrz7ID1P+/TCYLqLKV02zPKlPe PypXdFNkBJd0G6hK9VmcZ5FJTs8/zlV6X3XI3Z58E14hErLUDVEqSROpPcTQ2gtbh3RlFQk2tYw XmSmzimiGjvjKKM/XW9Phq5UONbYVTDorTF12wTzkJ35NiVY X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspam-User: X-Stat-Signature: 8agdd7xidrkwk8pbzg6ebfjffxwm8yb8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 14E6D140008 X-HE-Tag: 1708712860-107898 X-HE-Meta: U2FsdGVkX1+YhoZVkMrmW4CG9wf8Wtj+txG16Tkp1fV48G9lFpng1RPxQsbwD4iDhU9tHWucQSIqGAP3lBfZ2QawFv2BhqTtHymgcjh+Kxn5WwOAx7nJQuwuDM7tFHJxXc3uuHVH2eWq6REo5lUtGz8DS2DrdArnZSaHaGJQNtERUGbyi8V0UtwIrFDpbI3T3Aa962q7WBrKH0raOCHjbhUElZQbz66l37sxxl1XPKgj2tHu4oZP9FQt23+1zVaNAeIc/PJg5VBXCVRCiTW04D0GsPIC4x+GG9BMmbjTBbbAMtwmyXVmkrva201cWNpxDHeE+O64K4DO4A9yQGIEK+ZkLWjJZttdyk0Otqm+WtfrUSexzMQJ9GDpb3xm5v1TTUyskaPSOiyUDQ7eXUEBUb950WQBPbVLxMAHRCMzbn7RxUXPWoAptnpuEwnZRBHybJi1mjBtpjTlenbQBrJezPF+pWdaB2NZiRGbc19V4ASs5zVplQr9Xv+sN35wc/wYb9XFDcS3zjAVZndqREkIoQWLiDJhBTJI07l0BeGPx6o39F5AepPRMKz/jzNwTnxCDsjNVXcWT5LrKVSx7Tnn2NkRv8/7ZvIK7Sr8c3iStmx/F/OQ+oBi2zdaCIE/9Az53BBqQgCoFg1LwUEEBkM5Qo4xZipt4whAeyfftX2jtUbSoIluBw+MOG5KTJwdYHQ7hgDf+hzpQ+JlMvM2wfDtq/EFgFAdA02peeNglunRTA4gcfrygcGKCLD78HuJyvD/O2yc4VD+HFwuPDLcmWcQDpcz+dYWNH7E20avUUMd6l0hiwYTLEEnPP0rUznpFx/Epqtwn4HxFtZ9uTLao+2xrtwF0pgNHCQaHVp22mlrdw0JJB5pjtOLYYSeHTIRtjkkk+sIsi/7T9TcHQx6TRfShi13arK6qOPPi+0mlF1DmQavedJnqtlfqjIVuAfBagzdOE+yS2lxtgVESIBukrg p4dBMCQA l3TjxAnMmnmg29frBz98LQPwCudU8WpwA2JseWmZ+/CYHLQ8FtrxCwbKgWFqrCgpjouiN+HdbX7GGYJwPnPjMrq5LEX3u8y/HuIYnrCpu7uaF5k6Fd9O6sj5H1gAQ/D6L/njH3IUMvlRCRbgAjtwIkzDo066Ag3TVJ/CSQIN17pcchQEjiKbg/ctm6oj0S23b7MVSi3IoOI//CGTTNkhnhGzEuLYpySywG2U8K2yWkUCsvO+t0Z0Ggqp+hsoWQQTu1pI9ROVJxqD9z31KClkD0I7BRP3SCPtFxhHuClLhB+GbOTuJ9zIX2Zj/KM4ypLlaQf/5ONV++sCQyB39VIHKiBS4+D01Vcye5xa1XCRFsJkyyC6szsPH+E8tHSa3woymUVLcDgN1dNisFet6oimJik3PNw== 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 flags are defined by hand, which is tedious and error-prone. Use an enum to assign the bit number and a __SLAB_FLAG_BIT() macro to #define the final flags. This renumbers the flag values, which is OK as they are only used internally. Also define a __SLAB_FLAG_UNUSED macro to assign value to flags disabled by their respective config options in a unified and sparse-friendly way. Reviewed-and-tested-by: Xiongwei Song Reviewed-by: Chengming Zhou Reviewed-by: Roman Gushchin Signed-off-by: Vlastimil Babka Acked-by: David Rientjes --- include/linux/slab.h | 94 +++++++++++++++++++++++++++++++++++++--------------- mm/slub.c | 6 ++-- 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index b1675ff6b904..f6323763cd61 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -21,29 +21,69 @@ #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 __SLAB_FLAG_BIT(nr) ((slab_flags_t __force)(1U << (nr))) +#define __SLAB_FLAG_UNUSED ((slab_flags_t __force)(0U)) /* * 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 __SLAB_FLAG_BIT(_SLAB_CONSISTENCY_CHECKS) /* DEBUG: Red zone objs in a cache */ -#define SLAB_RED_ZONE ((slab_flags_t __force)0x00000400U) +#define SLAB_RED_ZONE __SLAB_FLAG_BIT(_SLAB_RED_ZONE) /* DEBUG: Poison objects */ -#define SLAB_POISON ((slab_flags_t __force)0x00000800U) +#define SLAB_POISON __SLAB_FLAG_BIT(_SLAB_POISON) /* Indicate a kmalloc slab */ -#define SLAB_KMALLOC ((slab_flags_t __force)0x00001000U) +#define SLAB_KMALLOC __SLAB_FLAG_BIT(_SLAB_KMALLOC) /* Align objs on cache lines */ -#define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U) +#define SLAB_HWCACHE_ALIGN __SLAB_FLAG_BIT(_SLAB_HWCACHE_ALIGN) /* Use GFP_DMA memory */ -#define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U) +#define SLAB_CACHE_DMA __SLAB_FLAG_BIT(_SLAB_CACHE_DMA) /* Use GFP_DMA32 memory */ -#define SLAB_CACHE_DMA32 ((slab_flags_t __force)0x00008000U) +#define SLAB_CACHE_DMA32 __SLAB_FLAG_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 __SLAB_FLAG_BIT(_SLAB_STORE_USER) /* Panic if kmem_cache_create() fails */ -#define SLAB_PANIC ((slab_flags_t __force)0x00040000U) +#define SLAB_PANIC __SLAB_FLAG_BIT(_SLAB_PANIC) /* * SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS! * @@ -95,19 +135,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 __SLAB_FLAG_BIT(_SLAB_TYPESAFE_BY_RCU) /* Trace allocations and frees */ -#define SLAB_TRACE ((slab_flags_t __force)0x00200000U) +#define SLAB_TRACE __SLAB_FLAG_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 __SLAB_FLAG_BIT(_SLAB_DEBUG_OBJECTS) #else -# define SLAB_DEBUG_OBJECTS 0 +# define SLAB_DEBUG_OBJECTS __SLAB_FLAG_UNUSED #endif /* Avoid kmemleak tracing */ -#define SLAB_NOLEAKTRACE ((slab_flags_t __force)0x00800000U) +#define SLAB_NOLEAKTRACE __SLAB_FLAG_BIT(_SLAB_NOLEAKTRACE) /* * Prevent merging with compatible kmem caches. This flag should be used @@ -119,25 +159,25 @@ * - 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 __SLAB_FLAG_BIT(_SLAB_NO_MERGE) /* Fault injection mark */ #ifdef CONFIG_FAILSLAB -# define SLAB_FAILSLAB ((slab_flags_t __force)0x02000000U) +# define SLAB_FAILSLAB __SLAB_FLAG_BIT(_SLAB_FAILSLAB) #else -# define SLAB_FAILSLAB 0 +# define SLAB_FAILSLAB __SLAB_FLAG_UNUSED #endif /* Account to memcg */ #ifdef CONFIG_MEMCG_KMEM -# define SLAB_ACCOUNT ((slab_flags_t __force)0x04000000U) +# define SLAB_ACCOUNT __SLAB_FLAG_BIT(_SLAB_ACCOUNT) #else -# define SLAB_ACCOUNT 0 +# define SLAB_ACCOUNT __SLAB_FLAG_UNUSED #endif #ifdef CONFIG_KASAN_GENERIC -#define SLAB_KASAN ((slab_flags_t __force)0x08000000U) +#define SLAB_KASAN __SLAB_FLAG_BIT(_SLAB_KASAN) #else -#define SLAB_KASAN 0 +#define SLAB_KASAN __SLAB_FLAG_UNUSED #endif /* @@ -145,25 +185,25 @@ * 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 __SLAB_FLAG_BIT(_SLAB_NO_USER_FLAGS) #ifdef CONFIG_KFENCE -#define SLAB_SKIP_KFENCE ((slab_flags_t __force)0x20000000U) +#define SLAB_SKIP_KFENCE __SLAB_FLAG_BIT(_SLAB_SKIP_KFENCE) #else -#define SLAB_SKIP_KFENCE 0 +#define SLAB_SKIP_KFENCE __SLAB_FLAG_UNUSED #endif /* 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 __SLAB_FLAG_BIT(_SLAB_RECLAIM_ACCOUNT) #else -#define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0) +#define SLAB_RECLAIM_ACCOUNT __SLAB_FLAG_UNUSED #endif #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ /* Obsolete unused flag, to be removed */ -#define SLAB_MEM_SPREAD ((slab_flags_t __force)0U) +#define SLAB_MEM_SPREAD __SLAB_FLAG_UNUSED /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. diff --git a/mm/slub.c b/mm/slub.c index 2ef88bbf56a3..2934ef5f3cff 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 __SLAB_FLAG_BIT(_SLAB_OBJECT_POISON) /* Use cmpxchg_double */ #ifdef system_has_freelist_aba -#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0x40000000U) +#define __CMPXCHG_DOUBLE __SLAB_FLAG_BIT(_SLAB_CMPXCHG_DOUBLE) #else -#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0U) +#define __CMPXCHG_DOUBLE __SLAB_FLAG_UNUSED #endif /* From patchwork Fri Feb 23 18:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13569864 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 D507CC54798 for ; Fri, 23 Feb 2024 18:27:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CE6B6B0080; Fri, 23 Feb 2024 13:27:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 980776B007E; Fri, 23 Feb 2024 13:27:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8C16B0080; Fri, 23 Feb 2024 13:27:46 -0500 (EST) 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 695CE6B007D for ; Fri, 23 Feb 2024 13:27:46 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 32F771611C5 for ; Fri, 23 Feb 2024 18:27:44 +0000 (UTC) X-FDA: 81823902048.11.0B0544D Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf10.hostedemail.com (Postfix) with ESMTP id 0B872C0005 for ; Fri, 23 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mbWlmygY; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mbWlmygY; dmarc=none; spf=pass (imf10.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=1708712862; 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=YO6OeAHEfcyOnMDaYbuFQtLgT98NdTKboW4QLF6GI08=; b=DaRWII7kafswJQPt2NE4aCnCnJzCs3/oUtzHe10CE9dswASeTCyQD1HxevyHS9OIMEMv2V ftWc1rGYztkvBZzzs2CxbNaj6JckNNg5ZTxaUPGCv2huH3bUAHzxWSJ0GFyoCYGk64N0Sf 44OtLn/7AmHW81lST4jHbbi6ex+lDCo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mbWlmygY; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mbWlmygY; dmarc=none; spf=pass (imf10.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=1708712862; a=rsa-sha256; cv=none; b=OJqGtGCuWhiYfsk9hCJaoIsUMEkTj8K0HTK3KkFDViLcOPkJgjFpIgD3pk3lrZy+J0C9o+ 8UQ6tOhchGOogTZlCwSGlXA8oF9A7g75sgR5k90GFidfCSBfQ8RP03EPznIaTgpHy13vJR eNOtB4NypEE23wuW/OZm2jBBNgQIqT0= 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 73D011FCDA; Fri, 23 Feb 2024 18:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708712859; 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=YO6OeAHEfcyOnMDaYbuFQtLgT98NdTKboW4QLF6GI08=; b=TwrUziIBFL2uhqrYSUuzeqP1mcryO/cH+SQcX9cKxgX421rEJSZDVz8bSHpKcIKnaFXAh7 m/RoZT+NLMEfqrPdUKV+abvPpKptQvBy7Dt+kmk6EXfEPzlRYZKphP3d1AKg9uxSttWO/D ArBfDXSAO52TfrFGDOXnhm2KRxQboxE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708712859; 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=YO6OeAHEfcyOnMDaYbuFQtLgT98NdTKboW4QLF6GI08=; b=mbWlmygYPYsRAT01nQRdqI8oW+QZYkRiQuVUxB9vdh0Bd/jgLEHbcWcPEeQzTFvH+NA7WE vhzuuiS1Yo9j3vAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708712859; 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=YO6OeAHEfcyOnMDaYbuFQtLgT98NdTKboW4QLF6GI08=; b=TwrUziIBFL2uhqrYSUuzeqP1mcryO/cH+SQcX9cKxgX421rEJSZDVz8bSHpKcIKnaFXAh7 m/RoZT+NLMEfqrPdUKV+abvPpKptQvBy7Dt+kmk6EXfEPzlRYZKphP3d1AKg9uxSttWO/D ArBfDXSAO52TfrFGDOXnhm2KRxQboxE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708712859; 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=YO6OeAHEfcyOnMDaYbuFQtLgT98NdTKboW4QLF6GI08=; b=mbWlmygYPYsRAT01nQRdqI8oW+QZYkRiQuVUxB9vdh0Bd/jgLEHbcWcPEeQzTFvH+NA7WE vhzuuiS1Yo9j3vAg== 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 41879133DC; Fri, 23 Feb 2024 18:27:39 +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 kPmxD5vj2GUaTQAAD6G6ig (envelope-from ); Fri, 23 Feb 2024 18:27:39 +0000 From: Vlastimil Babka Date: Fri, 23 Feb 2024 19:27:19 +0100 Subject: [PATCH v2 3/3] mm, slab, kasan: replace kasan_never_merge() with SLAB_NO_MERGE MIME-Version: 1.0 Message-Id: <20240223-slab-cleanup-flags-v2-3-02f1753e8303@suse.cz> References: <20240223-slab-cleanup-flags-v2-0-02f1753e8303@suse.cz> In-Reply-To: <20240223-slab-cleanup-flags-v2-0-02f1753e8303@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=3708; i=vbabka@suse.cz; h=from:subject:message-id; bh=oc217rqjv84A6cygyOWMLvkkVYYlf8fIgIHPUe4CqEI=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBl2OOY129UnZyUFxvKzDcfwYdqEhJtST9zIVQhR OzNq64oBqmJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZdjjmAAKCRC74LB10kWI mm6xB/4/euNwci9dIao8KK+SBBEedcYnZYBkvv/tfVj0jHJLbQRkDU7o18IDmCMksxzsn6GOBXY hWU77hCw7WZR01TCB62xaMRW0zCLIA0G06bqY9dvz33jRvBJCH9VBwzyNBAfZ/LcGTpL1GR/5sx zB/Zgky+tvMiAeSElsMcqFukRRZ++nF6UNa9NdGkSbr9Ox6qkWHuEPN96iNvR5yTCICx0egsZcj nd017gUj/VcmHvW3qxXHRIigA5JksKXUSLxXyaUT03QrYIfSlFxwFjslF2KknX6AGoDV7kJWqCo 9nYV61PnjZAKDEeC69HZCBItCBliGzH3GGI89D6yycYnxU83 X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0B872C0005 X-Stat-Signature: jnqxswin7hrq4qsba6hy4mgrzyqzc44b X-HE-Tag: 1708712860-538814 X-HE-Meta: U2FsdGVkX1+vedgQ68aApUPjfrb3Elo2X9IpJ/9sq1MAyyVBk3+TSsQ7V4ziiSNoAkBhJttPorKC/xOkIix2/V+xxg4D34OyjFyQMSY4PlHEeUfUiO7lYEWmuJ94+GmtBNZziJpC2PZnzFSStEoSnbJogY9pfI0KeDkOz6TC0yoKBO8ObtoLxU0MsUZTILtRRhWTlRBvn7az+yW4rqJS5oItpDR3+CDYBxOl7WBUNjAEAeXCVTtJKz2DvSOphAJHUUNmL+TpId253bEu7Qx+3KmVZyg8f0F6Q/hSyW6UZdTS0BWvLmxL7MJ2q6b46hYTYqg7XX6U7hGKPd6ZV25LoHyJF7psxuAoLWshkS5+H6TdNtD73J6aj/pQLY4e9RxbYpFjNgsqhuayF/RmK9AddAyWtlaZtMXZqtyopTmDsIN4r8WrKVpkG2BibmznzF06qWAfWJl/ihyby2+Eyaq7B5lMNk6mLXtuFzl+kWeMDrfDtjfG++hOPiZNzLcrBQ3c63zO5zNkuMZi0RH2XaCJWeiYZBMz023SPMN426kSH2f9WDqHgasXWUfw2gnw9SCBZ6H9lQ8QqgA6Qma/sP4fjdCaNIdgjjHOI+HKMQHsF3O1ww/APp62MmEO5jT9k94yp0jq7a/C7Yrb3Odf5VaPfLkZ7gKJu932bFUV9wo9Zp9VkMbjN0ksm1iMepOtE45fjEEOCFIOL9FnmNBVgps72RkZ9q2Bj+cL/Mk1GqdMaw6UQj26zFhn5aW76AGIHhkRtd9FL4Rls9ntAlRV5OHrdTVkVMs4Uh/kUIyyUPWJUtXRayfDalnw2rFvX/H2DXwWc2aNja1eyaMqZ/Lv/oQ+qfetva1j5KJ768atKu9qdVm2ED8naKUBv3LAZ5lYfdPyQPfxXRORS6K1KpMdTbCWJnGaXyiL4hPhuumX/44wpMy08U8SyipxgEoBbfmr68H1q4lD+rEsEkDqOSWdxiX NSas7lbL VoIZS02G4SxBTIo4BosF+fB4e8cCGNaup97T4fJeCPNQCOKE= 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. Tested-by: Xiongwei Song Reviewed-by: Chengming Zhou Reviewed-by: Andrey Konovalov Signed-off-by: Vlastimil Babka Tested-by: David Rientjes --- include/linux/kasan.h | 6 ------ mm/kasan/generic.c | 22 ++++++---------------- mm/slab_common.c | 2 +- 3 files changed, 7 insertions(+), 23 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..27297dc4a55b 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. @@ -370,15 +362,13 @@ void kasan_cache_create(struct kmem_cache *cache, unsigned int *size, return; /* - * 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: - * 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. + * 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 + * slab_ksize() to account for per-object metadata when calculating the + * size of the accessible memory within the object. 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)