Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp651600pxt; Thu, 5 Aug 2021 08:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLvg8MlfP9Zwg9m5zOXWMvafsrcZ/AKuR+5UbDTznXb3lBm146oJgqlwiTiQdwnx6ASS3+ X-Received: by 2002:a50:f097:: with SMTP id v23mr7355062edl.128.1628177196801; Thu, 05 Aug 2021 08:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628177196; cv=none; d=google.com; s=arc-20160816; b=DOL+X0pCxEWYY1XJ6wHH/gsgErPB3n95KUFThY8W0aoDJhJ7pI5CWpwwx6axVIO+PH UHE/A/tsK8EMRP9G304NbRzX5HdWBY8E/3NdQWQUYo/pkoT5U9eq/VxGxIeC8O3smXqw /m8TiIByoENEP9zjyIKmxNM77GV1ZAwB8KK/o6FHmSXPDa9mRH3Xlfocw7ZttIAoGfxV VGOFio3yfPJ4pWD88VUiyozYWygBsyFSaP9hBZR0sBGAml7YGTvo/fCBamGBXoAy8hDD yc9D++TUVtrnZNda3tplRg4CV6s2WRpSLvW+7OhcZHtR0g595EASf9DGZa/+eyPoGEJo xZNw== 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=wVwqSD2UkO7XMd6ZvLnWg5bsWNDyW06JqdetKKpn3vs=; b=wE83tyH5KVYvoWkqMtbYdQCwfTmbyA3rd+2/41u7yTC6psow994iToRfPEyrHj48WI SZ37P3wDBP1H3m4Jj4hR8c37BLb6NMpb/bEZMIc/HcW/gw+2FAE1h3P93hnJTuz1R1ZI ycYuzLZvoR/+nDHASucnZYlBtjwBijhkYcmGFTpOgSvWNe9taz0LdtKKn68rgxGtLNpm AcD8ILM9tJ8egAJti2PzPs73N9zhobK2d4v/zlVC9mM9wzPm7FnNb12hws+7VM6zydYz 4bkS1R7C0TmNJIsw5DVNC+5/SK9hGT0kvg0BH3uWBlS9eI4r4blRzjy7jS/7fMzYbnx9 AWKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LbSCYX4p; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=UpuJYvRu; 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 a25si5463601ejc.304.2021.08.05.08.26.13; Thu, 05 Aug 2021 08:26:36 -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=LbSCYX4p; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=UpuJYvRu; 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 S242068AbhHEPZA (ORCPT + 99 others); Thu, 5 Aug 2021 11:25:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:34072 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241963AbhHEPUW (ORCPT ); Thu, 5 Aug 2021 11:20:22 -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 C571722383; Thu, 5 Aug 2021 15:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176806; 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=wVwqSD2UkO7XMd6ZvLnWg5bsWNDyW06JqdetKKpn3vs=; b=LbSCYX4pHx/aG+sxdl4kRrrC5uWHO7FNxv+kZKk7UeC4fLJUnt93zPeWa8uRqY0byyAw+J wyjIyRkAjhQdlZjnNnicB6SfcIT0c5ocpjvjK6GB2SDmPKeCj+oy+oz2r8wvT5w/r5S27Z oV9T1YEoJfX8dmrU/MVkpGiq9iYhO5g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176806; 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=wVwqSD2UkO7XMd6ZvLnWg5bsWNDyW06JqdetKKpn3vs=; b=UpuJYvRuhZ/Q2QvnlZwcLO714zF0C4uKc8/9In8CaYAvQdT3V2gol4B7Vpg7kOAw3K8PfM i4Pxm681qRtBUXDA== 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 97E4113DA8; Thu, 5 Aug 2021 15:20:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kMx5JKYBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:06 +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 14/35] mm, slub: move disabling irqs closer to get_partial() in ___slab_alloc() Date: Thu, 5 Aug 2021 17:19:39 +0200 Message-Id: <20210805152000.12817-15-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 Continue reducing the irq disabled scope. Check for per-cpu partial slabs with first with irqs enabled and then recheck with irqs disabled before grabbing the slab page. Mostly preparatory for the following patches. Signed-off-by: Vlastimil Babka --- mm/slub.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 7eb06fe9d7a0..868a782b6f62 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2676,11 +2676,6 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, if (unlikely(node != NUMA_NO_NODE && !node_isset(node, slab_nodes))) node = NUMA_NO_NODE; - local_irq_save(flags); - if (unlikely(c->page)) { - local_irq_restore(flags); - goto reread_page; - } goto new_slab; } redo: @@ -2721,6 +2716,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, if (!freelist) { c->page = NULL; + local_irq_restore(flags); stat(s, DEACTIVATE_BYPASS); goto new_slab; } @@ -2750,12 +2746,19 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, goto reread_page; } deactivate_slab(s, page, c->freelist, c); + local_irq_restore(flags); new_slab: - lockdep_assert_irqs_disabled(); - if (slub_percpu_partial(c)) { + local_irq_save(flags); + if (unlikely(c->page)) { + local_irq_restore(flags); + goto reread_page; + } + if (unlikely(!slub_percpu_partial(c))) + goto new_objects; /* stolen by an IRQ handler */ + page = c->page = slub_percpu_partial(c); slub_set_percpu_partial(c, page); local_irq_restore(flags); @@ -2763,6 +2766,16 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, goto redo; } + local_irq_save(flags); + if (unlikely(c->page)) { + local_irq_restore(flags); + goto reread_page; + } + +new_objects: + + lockdep_assert_irqs_disabled(); + freelist = get_partial(s, gfpflags, node, &page); if (freelist) { c->page = page; @@ -2795,15 +2808,18 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, check_new_page: if (kmem_cache_debug(s)) { - if (!alloc_debug_processing(s, page, freelist, addr)) + if (!alloc_debug_processing(s, page, freelist, addr)) { /* Slab failed checks. Next slab needed */ + c->page = NULL; + local_irq_restore(flags); goto new_slab; - else + } else { /* * For debug case, we don't load freelist so that all * allocations go through alloc_debug_processing() */ goto return_single; + } } if (unlikely(!pfmemalloc_match(page, gfpflags))) -- 2.32.0