From patchwork Tue Aug 23 17:03:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12952323 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 A2258C32774 for ; Tue, 23 Aug 2022 17:04:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DDED940007; Tue, 23 Aug 2022 13:04:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84D1594000D; Tue, 23 Aug 2022 13:04:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62249940007; Tue, 23 Aug 2022 13:04:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2C10E94000A for ; Tue, 23 Aug 2022 13:04:10 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F33DB12166D for ; Tue, 23 Aug 2022 17:04:09 +0000 (UTC) X-FDA: 79831480218.04.CF1AED4 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf20.hostedemail.com (Postfix) with ESMTP id 84DDB1C0017 for ; Tue, 23 Aug 2022 17:04:09 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6CCA033728; Tue, 23 Aug 2022 17:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1661274248; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JfZ2lf4IPa2cN9yBFH4RoSps0msGVmnFikpNpd4PztQ=; b=Rnl+YjY7SCgTUNVAh1U7P+vCo4oewnVjfFMPA0cpH/E08XMHZdaPV/4fccwkGgE5u2h3b1 pByGv9zPvNEAqsnftFt98w6MrlmATr01gCyQP43Fj4v5aU3mjcmqfxd5C0Vu+InUZxrEX3 ryARIz74m6nAI1ksi4ddyUN8va/Aw5Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1661274248; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JfZ2lf4IPa2cN9yBFH4RoSps0msGVmnFikpNpd4PztQ=; b=y1dAxR0HZK0UWhggUZ82p1tDBU2vliJAnKOxh8rojLuk+kCHcoXYyiz5+2H0P0KbRI4Ubn rKpj/qiu++Kr1gCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3518B13AB7; Tue, 23 Aug 2022 17:04:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eJdXDIgIBWPTQgAAMHmgww (envelope-from ); Tue, 23 Aug 2022 17:04:08 +0000 From: Vlastimil Babka To: Rongwei Wang , Christoph Lameter , Joonsoo Kim , David Rientjes , Pekka Enberg Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, Sebastian Andrzej Siewior , Thomas Gleixner , Mike Galbraith , Vlastimil Babka Subject: [PATCH v2 4/5] mm/slub: convert object_map_lock to non-raw spinlock Date: Tue, 23 Aug 2022 19:03:59 +0200 Message-Id: <20220823170400.26546-5-vbabka@suse.cz> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823170400.26546-1-vbabka@suse.cz> References: <20220823170400.26546-1-vbabka@suse.cz> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661274249; a=rsa-sha256; cv=none; b=xjs8uKxOgwho1fnAdyihb5ftPgwiR5vNXxDBgv4pAwVabCgjiXVFZ71UEQ1dhe6Fz0TxIR tf1fUyxSnDY5Xb/lLVRUNiav+CklaQCBjkY3CJygDxloCvIEQ/cwvWvW0ZBhRmzhRuRZNc oy9IsdpCEotuNFXiULgINIhW058b9RA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Rnl+YjY7; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=y1dAxR0H; dmarc=none; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 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=1661274249; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JfZ2lf4IPa2cN9yBFH4RoSps0msGVmnFikpNpd4PztQ=; b=IGCetDVtVrMbqPwt5Mqon5vwub/LrhJqyFiE4sLlapwOjzDVNk3+3OShOEsQJZmSDPiDIf ieMlsIO6g0ijrjZV3zCnUHcz8N35yONDVyoklzn+uBF7+lQNxiJtNpb52PS1o//ckTFzvF wn8e6YFsfQ5mRZAWmLzHWaybKGDLrCg= X-Stat-Signature: oji3mrioiz64gaa3a9qssnxfpp1bc7ro X-Rspamd-Queue-Id: 84DDB1C0017 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Rnl+YjY7; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=y1dAxR0H; dmarc=none; spf=pass (imf20.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1661274249-156372 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: The only remaining user of object_map_lock is list_slab_objects(). Obtaining the lock there used to happen under slab_lock() which implied disabling irqs on PREEMPT_RT, thus it's a raw_spinlock. With the slab_lock() removed, we can convert it to a normal spinlock. Also remove the get_map()/put_map() wrappers as list_slab_objects() became their only remaining user. Signed-off-by: Vlastimil Babka Acked-by: David Rientjes Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Sebastian Andrzej Siewior --- mm/slub.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index b4065e892f7c..0444a2ba4f12 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -565,7 +565,7 @@ static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct slab *slab, #ifdef CONFIG_SLUB_DEBUG static unsigned long object_map[BITS_TO_LONGS(MAX_OBJS_PER_PAGE)]; -static DEFINE_RAW_SPINLOCK(object_map_lock); +static DEFINE_SPINLOCK(object_map_lock); static void __fill_map(unsigned long *obj_map, struct kmem_cache *s, struct slab *slab) @@ -599,30 +599,6 @@ static bool slab_add_kunit_errors(void) static inline bool slab_add_kunit_errors(void) { return false; } #endif -/* - * Determine a map of objects in use in a slab. - * - * Node listlock must be held to guarantee that the slab does - * not vanish from under us. - */ -static unsigned long *get_map(struct kmem_cache *s, struct slab *slab) - __acquires(&object_map_lock) -{ - VM_BUG_ON(!irqs_disabled()); - - raw_spin_lock(&object_map_lock); - - __fill_map(object_map, s, slab); - - return object_map; -} - -static void put_map(unsigned long *map) __releases(&object_map_lock) -{ - VM_BUG_ON(map != object_map); - raw_spin_unlock(&object_map_lock); -} - static inline unsigned int size_from_object(struct kmem_cache *s) { if (s->flags & SLAB_RED_ZONE) @@ -4367,21 +4343,21 @@ static void list_slab_objects(struct kmem_cache *s, struct slab *slab, { #ifdef CONFIG_SLUB_DEBUG void *addr = slab_address(slab); - unsigned long flags; - unsigned long *map; void *p; slab_err(s, slab, text, s->name); - map = get_map(s, slab); + spin_lock(&object_map_lock); + __fill_map(object_map, s, slab); + for_each_object(p, s, addr, slab->objects) { - if (!test_bit(__obj_to_index(s, addr, p), map)) { + if (!test_bit(__obj_to_index(s, addr, p), object_map)) { pr_err("Object 0x%p @offset=%tu\n", p, p - addr); print_tracking(s, p); } } - put_map(map); + spin_unlock(&object_map_lock); #endif }