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: 205616 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp768151dyb; Fri, 23 Feb 2024 10:28:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXfIP+EqQDQn9imFAsELnEn/7V7YUawvGk0pXsWmipd0XbGk4k6qls5PWBBwafSmzg8Dpvpj62xlxX51blPJ8ZpkGOLFA== X-Google-Smtp-Source: AGHT+IH6mvY5oRT1rZhjrRdsycSyJFOBKuNG4TUDymuEa1KO67IawYlJpZXp5lMhyoTrulWDMU1F X-Received: by 2002:a17:902:cece:b0:1d7:2e86:fb2a with SMTP id d14-20020a170902cece00b001d72e86fb2amr749005plg.65.1708712908560; Fri, 23 Feb 2024 10:28:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708712908; cv=pass; d=google.com; s=arc-20160816; b=Fj07EtHrB2CFgDEkpprYUl3P1kqTlnL8cPlVJ9SUpvOJf3X63atc1iSQiVYniWyDE8 d2u4hFhCn0c4rOfWWIYDDN6lB2/iD0x5+1Lgd2w0mU8y/h/SDx6c65su0prwVWvSkcc9 gGFUFLuoHAxGkb+GrrSU6uYD3T4WeOQQYjpUjY604F4/eNFOdrgM7ez/0cLNvzuummpV 5iCmE2UgiMe441csEutSqlnRwUNvvA6xwUsP/iAXOUfbm2VKHmtFhZesZhD0O2KvEibv p512z4XJkaqLn8GZYbRp9yhECE2gkOXF6ufvHDTDcbS1m7FcSCx3j6qAAvD+UdxLhq3/ WS8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=7brqYZxmuxrRKSYQEeacefCe+ctYuF6xWTXM5McbA8I=; fh=H+kigXjdCOVpCxcHPaVg6SgkIx4KR669HTfmciEICLo=; b=ICZR0roJl3tuiAS4y6W7M5YIeTWO38DNYyaWAfLeyeNcHVfWb90motN5KqjkpnIH3+ ECys+due0URJHO4h9IDpl8e+WCbgtV5Ra3/3D9V5YfsUZhQwPetRjwt/pUR1iutGVEQl 8s76TksEOeBu9uAh9sLTi725df3nBiUrJr1i7oJNEjgI55gK00FsuVYMmqxRL1HG9NUT LSmBeTuURtdOh+oaYXuu2zqBrxNmg6KB0R91dzVNBexVToWUhPh+clcfrFV6m4lRxT/N k3pYpqRon4UB3iv8HACx1xkB9FV7lG9mARyzRSf8uaMsLjHEHBiQEsllG7kGU8Xs5caM JwQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="nMZra/aK"; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-78977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78977-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s14-20020a170902ea0e00b001dc38eaa5casi5273290plg.74.2024.02.23.10.28.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 10:28:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="nMZra/aK"; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Qd8LsPfV; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-78977-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78977-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6A0FAB23061 for ; Fri, 23 Feb 2024 18:28:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EB48145332; Fri, 23 Feb 2024 18:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Qd8LsPfV"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="nMZra/aK"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Qd8LsPfV"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="nMZra/aK" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 31B8A14264A for ; Fri, 23 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708712863; cv=none; b=OHVjY/povfi7md8mPLBDenz0o5bV0rUOpQ7Uf1Md+64afR5vw9N5FThrrNmmQnCLL0R1FVuRhL0a6vHPVHFCoR7HmiFSYhmDI7Al6KIIlpz+qkZlvmYAx9v9/2WVlGXCxh8c64XFjtQ7s9s4xCqgHQnXqXH+2dxL+gF5vHT95uQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708712863; c=relaxed/simple; bh=xj2FbXNZUF1ZX1Yi4h91pRFSVKXZaW8ItJyLfGmRRuU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DyIr9fQh3GtFbQHC1567sF5XltmO7Cx5kZAHrayC1Q6xnUFQ0BN7tHPrGA7fk5MHzSO0MeMb14bjrjSE7DpAjIdYkp36zLRf2UcUCEMttNKKjAsEz7no4iHtXFtRwSUBU4OPb3chM9X5gA64RlcM9zWSOx8u4kanRi2fTkJpIFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Qd8LsPfV; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=nMZra/aK; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Qd8LsPfV; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=nMZra/aK; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [1.40 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BAYES_HAM(-0.00)[42.50%]; R_RATELIMIT(0.00)[to_ip_from(RLqdadssyy1w6u3twx3pq4jyny)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_TWELVE(0.00)[20]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FREEMAIL_TO(0.00)[linux.com,kernel.org,google.com,lge.com,linux-foundation.org,linux.dev,gmail.com,arm.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Level: * X-Spam-Score: 1.40 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791715346850578037 X-GMAIL-MSGID: 1791715346850578037 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: 205617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp768271dyb; Fri, 23 Feb 2024 10:28:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVnjFGsV1UIdAbKWadFO0WmpvlpwTYzxBDfw9or3sMC3gnI3wxmiKvyUrP/aYC1Chl/z2YwtVYNVg0MGl+HRK2FXpqEBQ== X-Google-Smtp-Source: AGHT+IFfCfl/cgpAgc/a/fdySYZ3Kf7JupdGN+PaSPBNublKdhcnc+lZjsHdESl4T82X6achhn6F X-Received: by 2002:a17:906:394:b0:a3f:48c1:9b9e with SMTP id b20-20020a170906039400b00a3f48c19b9emr435854eja.20.1708712921021; Fri, 23 Feb 2024 10:28:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708712921; cv=pass; d=google.com; s=arc-20160816; b=fpAlwOA9SaR33Gz28ZlcS03kXGREatQN00rvseKxAiXOJtvDVKf4Dj8usGPeaX+jWD cizuG6rkVsvJEc5ckI1e5vesBu5LS5c+Msr4CMmocszy9J7Mw79ZCmPjqxz5OOV6y1mj AhJtw8XPXuVsBra/5ZPARYo9ySh1qmqgreR1j4yshl8RSARdoXMMJexgNqrQjX3wRvg0 wOQuA03i7beh6DJs2pdEaqjoxh1Gq/FlQ0AUdAaAczxdiBCkurDrMMch3q4IaQixROQf eGkw4SxzxtqYD1uG83FPuKLBwjiWpXuM8wFqP+RTUBtgiUFHNbXopo2D4vqtuZTcb3Kq Mz6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=gdIIkjKNjW91Ug8+r97lNpU6eko4/0lhYa/nSEYrEFs=; fh=iiw6AxRn834Rp3X3mGFcQcmYTlAscmlxQxZZCAoI+ts=; b=EtSWFdOPgtXzY4ZnH/YKwYrphaRuh1V0Lm2/BHsrvFgJlDw6gXj98LOR7VRcXmtemE cyFLOHJTfLCqWzMacPgTw2HQObQgCGkS/oQtrtE89SFmhJKn8d7xW+vrkrdmsHiM3dQS n7dh8FwsDbN8ajyb5wJ08NhMxRqR7sOiL9v7/9LRm5k86jxH6BzvrcQnI0bW6ZWdiXFx HIosOuU6Vm4yz/GAQ1unKwS6XICizZzbeDS9bNtcatdfU2Tlic3eY3ZM766dkDu/9sh0 kIRoo1dDMlL1O6j8wGiiuV4x0OU7f8p1UqvnL8EKRkkLdi31qjcGSE/NYYFjdxBmMaaD 4UjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=ii0k7MdE; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-78978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78978-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qc21-20020a170906d8b500b00a3ee758e479si3959956ejb.193.2024.02.23.10.28.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 10:28:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=ii0k7MdE; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZmoNfrpC; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-78978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78978-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 78DC71F26726 for ; Fri, 23 Feb 2024 18:28:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBD25145B33; Fri, 23 Feb 2024 18:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ZmoNfrpC"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ii0k7MdE"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ZmoNfrpC"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ii0k7MdE" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 3F2C614265C for ; Fri, 23 Feb 2024 18:27:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708712864; cv=none; b=KtlrYuuQmwaVZswZhgM3RjNUlHQG77OCKMFqV0cDcFZlRsT57n0+Mz2Cbw5lIhZQd9SuMzg19PM0AP8kZqWEjgBSSvQ09X6Lk6U54eE++oCiPnSiJD2UpbWNLuwddEGXyeigxQlbyYkoa5XFKzRKAaeL5p2tpYZ70M4xURgytKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708712864; c=relaxed/simple; bh=Pwf3NzcoQQwCRBmd+qMj8XBoxm9DrwZf7S0mWjV+OLY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d/VeHnBrGxNeCwDWoFb8lQ4d52ZtYKp0RbpE/M3jYhFIje1zaOu95PUmUdfLNp0uMLEUpz6edbEtn72wtF4fDweW2x4SUH8FnrZgBslyeD5K1dbyxelfRcfZWfYGJkRS0qKtHB467oz8XvIeyyZHMjaVRk9hmnFGF9w8DvEnGfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ZmoNfrpC; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ii0k7MdE; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ZmoNfrpC; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ii0k7MdE; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-3.00)[100.00%]; R_RATELIMIT(0.00)[to_ip_from(RLqdadssyy1w6u3twx3pq4jyny)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWELVE(0.00)[19]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FREEMAIL_TO(0.00)[linux.com,kernel.org,google.com,lge.com,linux-foundation.org,linux.dev,gmail.com,arm.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791715359846197830 X-GMAIL-MSGID: 1791715359846197830 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: 205615 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp768142dyb; Fri, 23 Feb 2024 10:28:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWHI8S2CQM5woi/sg11kb41f05dlAdm0uMjK4DMUqDohK26G30Io8eTQTQ1D6X5j7Qcgg+T8J/yB2O/5TaRVlh8Mb9S8A== X-Google-Smtp-Source: AGHT+IGbFn8qYvVEfB0ZD2Lt84Xwl3sCdZ0W/52QC2l3LN279GeHDgoS0iE38rYiv/iwqB2Wk1Ny X-Received: by 2002:a05:6a21:3990:b0:19e:9d92:b6a6 with SMTP id ad16-20020a056a21399000b0019e9d92b6a6mr817410pzc.44.1708712907963; Fri, 23 Feb 2024 10:28:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708712907; cv=pass; d=google.com; s=arc-20160816; b=UlttAv7PBnLkSAKwzCL8wPz2zP70uiSHyYvCVn7jB9jA2ls98DS9bZXjSOzFJgA3wB SSQLoFLICojNjmQOADZ8LucTYp2LTmXF410Qmp8+aolqfZ6MdNvTEIIZMqQQG4vpnBm5 GTgM7potH2AP6n+BdyGnQ6qb6Y2ttuoTGytpOCS7aScwxGsw3ml32oKW9VoBDEmb2ND5 pZgCmPcwVDDQtFuPjSBWegePR/inT/0jY2Qezw+izoqiSRkGhcROTKUGoS9X85Q8aMEp 4xx2owexsAiTGEWEXIAY3vPGrwRzliNJNcVDhXnJyfe0hAo5y6VqVBsgXqjD8qHhfP4m 5VWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=YO6OeAHEfcyOnMDaYbuFQtLgT98NdTKboW4QLF6GI08=; fh=iiw6AxRn834Rp3X3mGFcQcmYTlAscmlxQxZZCAoI+ts=; b=UtJD0czAVkkQHG0m1cm5s17aPYqCClX34hmFa3tQhqQCHHQJsTsn0xqTR9VnT0YPff 9WXtMc9InYIQFA1T7M8qraJ+WZlsXHEB0KoQweJfrTLkFd/eBKgzfAIyRR5u0C/YHeDa T75W9P8XmrwBWQZ6DLm8ht2wbWvyru+s3MrP+nuamN2zWAi69JvNv3ZrvfUL56JVCrhE +or4YMcOrby/DE4sy8YQHDTtav1rk6Wtx4UaXniaFSooqVtHsL9FCNMZAbIWtM+YQcp/ HDE/F1lxw964NK02cNz5k2/Dl32Ssd0gN0aRffWWrmHFlw+2ErTGNqNSRJKy6BSYYRf2 xRhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-78976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78976-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id se8-20020a17090b518800b00298dd9da549si1572628pjb.23.2024.02.23.10.28.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 10:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TwrUziIB; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-78976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78976-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CC1A6B22F9D for ; Fri, 23 Feb 2024 18:28:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 334CD14532F; Fri, 23 Feb 2024 18:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="TwrUziIB"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="mbWlmygY"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="TwrUziIB"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="mbWlmygY" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 57EC0143C43 for ; Fri, 23 Feb 2024 18:27:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708712863; cv=none; b=fsjYvVbgczAHACpTM921PDRutaXPGJ09Wcy4LJ8p+7f4Wg/CWWmx4Zl8UO98twYLMZeb74+U0dffVUsTrnjemHsO1/yek1g8GMplSvt3rdABJ+obD0rbARKy8s96Yhxa/GiZwPVX4+T3snzH2A+44yUG9ssKGCYD4D4h0Hn4CGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708712863; c=relaxed/simple; bh=oc217rqjv84A6cygyOWMLvkkVYYlf8fIgIHPUe4CqEI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gQx8tQt6/sGt4b37+ZhoH6/s+1VLGkS7XV9gCiceZehQeyj8kodwxOSoiQHzi8K6rEkK3M854QhHLE1J/WuYEzF26qthAFBxuzthVdz6j4ybAWBPJT4TJralj4XNmuVJg3fkBEpZTUvDbbWzuYReVRfhGs1hl5cs5mw4h5UEZyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=TwrUziIB; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=mbWlmygY; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=TwrUziIB; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=mbWlmygY; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Authentication-Results: smtp-out2.suse.de; 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 X-Spamd-Result: default: False [-3.31 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLycmwa99sdzp837p77658kns5)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.cz:+]; MX_GOOD(-0.01)[]; FREEMAIL_TO(0.00)[linux.com,kernel.org,google.com,lge.com,linux-foundation.org,linux.dev,gmail.com,arm.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCVD_DKIM_ARC_DNSWL_HI(-1.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_TWELVE(0.00)[19]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:dkim,suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_IN_DNSWL_HI(-0.50)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 73D011FCDA X-Spam-Level: X-Spam-Score: -3.31 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791715346043821738 X-GMAIL-MSGID: 1791715346043821738 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)