Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3845522pxj; Mon, 24 May 2021 16:42:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+5Fq+uGB3hS//2Scb8leBLsuuB17ECuW+fElm9HjXWOzX28kCxAFRVjR6grBOVTP9jMuS X-Received: by 2002:aa7:d9d0:: with SMTP id v16mr28678642eds.293.1621899736242; Mon, 24 May 2021 16:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899736; cv=none; d=google.com; s=arc-20160816; b=m8sVSy52Vi4Iq5CAQXzhTHZgWqFhsArfU2oOSzFG7UQh5fnPHU4xJPV4QqZqUoVjc9 J3dFHwQUnMH+KSzFajncUF/E4E4e6YVKYy7W/dbHM6piU/ApsOo0+KM/uZZUfdEi8qX9 xu1u/K41TOLCYn8tvXU2a6jdPNrMNkk/jyd4HiTe7vb3EXrvg5erDcMLgJ0ZkuW83eLt yOyk/rZj+KR5Zx445SMhmv9sCKE1ULeDBGgNEu6Z+PkJgj/ifW41v3xWWrxfma6ssy/V 7nnYjIKZxF8B8fazgFeLtJxOjSuOcq2n67qRPov2xIZ9eSB+VhCeUDJvCLkKRsY5GP54 natQ== 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=m3NM1kan+8I0dQSmYiERLwA5HXaatts/npqSxc2yo1s=; b=kTuJhqv7cL+7mccB0YlzhOo8vFxCB3V5n+pmFet2EfhQJYhQB6Qx4IoP/z9VHjorQD cvU7MmUYHRIH0mZ/yQgPhPtlq0n8tzylSpeoVQ0kwZE3VIWxGFeFrVmQtuadcQUgyLN5 6x16oTRtKXTmOCszMoK5bou3zclV8FndWg75X4USueewVvtOIH72A/MsVCCi/fb+fyC8 0AJL96a/PjD9ToBb/BgKKnLhnU9fxXSL2e4pg2D9FL9Y91LtR4dHS6bGyR1p2gWk/PiZ 2cI1DzXrellg7/IYgnFJMS342pdBcm2IenB/NlPMx4rdv/wDEYzIZOJjb5cipJQzAVps MzVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dxPCSLvp; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 i27si13529924ejh.691.2021.05.24.16.41.53; Mon, 24 May 2021 16:42:16 -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=dxPCSLvp; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S229986AbhEXXmZ (ORCPT + 99 others); Mon, 24 May 2021 19:42:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:50438 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbhEXXmS (ORCPT ); Mon, 24 May 2021 19:42:18 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1621899648; 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=m3NM1kan+8I0dQSmYiERLwA5HXaatts/npqSxc2yo1s=; b=dxPCSLvpV0HPfbtbyyz4WWiXaoqkE+RuEn+3eiYjaPMSUzWdXyvZ/IYSKFjxmR3k8in6UQ UXZ798BVtRDlFUKFIgO5u8WC6Lf3sd0BT5qro9IiUD3pXorxNUueBNlr82RYbNc7e7wnx4 3J/SEZSwsCVDwmJXZORMwxkw8yfyI0E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1621899648; 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=m3NM1kan+8I0dQSmYiERLwA5HXaatts/npqSxc2yo1s=; b=48TzUnVPiJ9rxm8hWdC6qWhZNBRFHpClNS3Aya9Nu3cVdolTLKvs0gNQEYbEBG9+g8s5a0 6u5oefeFnaHusFAA== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E4C30AF1A; Mon, 24 May 2021 23:40:47 +0000 (UTC) From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Peter Zijlstra , Jann Horn , Vlastimil Babka Subject: [RFC 02/26] mm, slub: allocate private object map for validate_slab_cache() Date: Tue, 25 May 2021 01:39:22 +0200 Message-Id: <20210524233946.20352-3-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524233946.20352-1-vbabka@suse.cz> References: <20210524233946.20352-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 --- mm/slub.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 4c876749f322..ed0f2620b19b 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4622,7 +4622,8 @@ 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); @@ -4634,7 +4635,7 @@ 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) ? SLUB_RED_INACTIVE : SLUB_RED_ACTIVE; @@ -4642,13 +4643,12 @@ static void validate_slab(struct kmem_cache *s, struct page *page) 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; @@ -4657,7 +4657,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) @@ -4668,7 +4668,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)) @@ -4685,10 +4685,17 @@ static 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.31.1