Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp803276pxt; Thu, 5 Aug 2021 12:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLXlY8rHvFcG1ETuY8VSfeBtiNjttGK38/bJ95UHmSKRhTj3EQ72zq3+d4WlrTYzhD1GDd X-Received: by 2002:a05:6402:1d90:: with SMTP id dk16mr8470560edb.94.1628190289054; Thu, 05 Aug 2021 12:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628190289; cv=none; d=google.com; s=arc-20160816; b=Dh3QWc6XcYo9LAPnHrWdVUw/fyg1/J6d9z0M0Q0hZQrrWTJ8GeEt14Qx5WBwRRfhYH OlHN+HsOsIxLsFBN+rDmSAJLZOcT3k3MrWznzQObN7HGRFUiIZE9jM2GRhxi7aq2Jhl6 zqi8WuwWoBL82qKMl6d7ngSjmNW9HFsSqHdRIrUcjV2KoabaFD0Njw9w3YDMTxJCmpIT Ydakc2MN33DN1TT5QBtls/iJXftHNQBsC+zTF4e3J23bFlwERYC9d3M2Rcc1TWwzmiYM 0SQJ1LeXZUlRpMy+RMAnWpNt9s4RO8r8yEYPzURD8C9Z6ObS3xdm73laTgFL+CN29oxg HFkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=+MtcQcuDEhAh9t+4qt7WXHGBfICrnJNPjNJealierhA=; b=jqNs40O2aZ1p5oqnX5eD/AQUsVEZnAH9hctbrijohzZqTNfss/Nih4BdCTKViGPgLu rp4C2mkJAfV5l4pVrVyksmvewHxxR3By9RFuw6C4IBNWxinGX1gG/VONyO2hSOB0Y8fn XqDN57Ra8lrsjm5j8ZK+Ld04sAZ7pHW0Pn2FBcV3/O1M3PP+nzzZ/TwLzHDBXEdVaO7V x/xQqBrtir4Rdd/meSbU0grgqi4m6CPBagyvqiWoPhJN4H0/iMqRfoAn/EKxxyc9+ejY 5cDUoO/yso2oC4Nod/pP9BkGNUOhGvKWwA9OfoS4ndNPMr9sOlD9Y5IWE838g9/ovVq4 ZJQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=cIYJjwR9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=QrN2eWuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si6338053ejt.588.2021.08.05.12.04.24; Thu, 05 Aug 2021 12:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=cIYJjwR9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=QrN2eWuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242021AbhHEPVA (ORCPT + 99 others); Thu, 5 Aug 2021 11:21:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33922 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241278AbhHEPUT (ORCPT ); Thu, 5 Aug 2021 11:20:19 -0400 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 A5599222F6; Thu, 5 Aug 2021 15:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176804; 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=+MtcQcuDEhAh9t+4qt7WXHGBfICrnJNPjNJealierhA=; b=cIYJjwR9/rtM5EKHCjmf+2Td+AVCm4z/hmpf8urUcTgXtffjpzZEIHuSTQAsehxuzdk7+L 6KYd0uWbvOdQzviWy8LZiPOrCfM78SEUmraAVstQcE8tq25b9aKsyEx8Ih/72RvrQ5Vu1H rpRj5sdAWC+2bcPrtnX6BMEGoUPjacc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176804; 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=+MtcQcuDEhAh9t+4qt7WXHGBfICrnJNPjNJealierhA=; b=QrN2eWuMaRmbaihzrQgQmHyiQZg7V5Kqb1cbTOIirwNBF37qjtMKWeMNxfHfRwUM6qCyG6 LUOogkBDOUjq9PCQ== 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 7693C13DAC; Thu, 5 Aug 2021 15:20:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GHNTHKQBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:04 +0000 From: Vlastimil Babka To: Andrew Morton , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v4 03/35] mm, slub: allocate private object map for validate_slab_cache() Date: Thu, 5 Aug 2021 17:19:28 +0200 Message-Id: <20210805152000.12817-4-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805152000.12817-1-vbabka@suse.cz> References: <20210805152000.12817-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org validate_slab_cache() is called either to handle a sysfs write, or from a self-test context. In both situations it's straightforward to preallocate a private object bitmap instead of grabbing the shared static one meant for critical sections, so let's do that. Signed-off-by: Vlastimil Babka Acked-by: Christoph Lameter Acked-by: Mel Gorman --- mm/slub.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 211d380d94d1..e1889b26a889 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4676,11 +4676,11 @@ static int count_total(struct page *page) #endif #ifdef CONFIG_SLUB_DEBUG -static void validate_slab(struct kmem_cache *s, struct page *page) +static void validate_slab(struct kmem_cache *s, struct page *page, + unsigned long *obj_map) { void *p; void *addr = page_address(page); - unsigned long *map; slab_lock(page); @@ -4688,21 +4688,20 @@ static void validate_slab(struct kmem_cache *s, struct page *page) goto unlock; /* Now we know that a valid freelist exists */ - map = get_map(s, page); + __fill_map(obj_map, s, page); for_each_object(p, s, addr, page->objects) { - u8 val = test_bit(__obj_to_index(s, addr, p), map) ? + u8 val = test_bit(__obj_to_index(s, addr, p), obj_map) ? SLUB_RED_INACTIVE : SLUB_RED_ACTIVE; if (!check_object(s, page, p, val)) break; } - put_map(map); unlock: slab_unlock(page); } static int validate_slab_node(struct kmem_cache *s, - struct kmem_cache_node *n) + struct kmem_cache_node *n, unsigned long *obj_map) { unsigned long count = 0; struct page *page; @@ -4711,7 +4710,7 @@ static int validate_slab_node(struct kmem_cache *s, spin_lock_irqsave(&n->list_lock, flags); list_for_each_entry(page, &n->partial, slab_list) { - validate_slab(s, page); + validate_slab(s, page, obj_map); count++; } if (count != n->nr_partial) { @@ -4724,7 +4723,7 @@ static int validate_slab_node(struct kmem_cache *s, goto out; list_for_each_entry(page, &n->full, slab_list) { - validate_slab(s, page); + validate_slab(s, page, obj_map); count++; } if (count != atomic_long_read(&n->nr_slabs)) { @@ -4743,10 +4742,17 @@ long validate_slab_cache(struct kmem_cache *s) int node; unsigned long count = 0; struct kmem_cache_node *n; + unsigned long *obj_map; + + obj_map = bitmap_alloc(oo_objects(s->oo), GFP_KERNEL); + if (!obj_map) + return -ENOMEM; flush_all(s); for_each_kmem_cache_node(s, node, n) - count += validate_slab_node(s, n); + count += validate_slab_node(s, n, obj_map); + + bitmap_free(obj_map); return count; } -- 2.32.0