Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp654414pxt; Thu, 5 Aug 2021 08:30:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt5fYQH0Z777a3ueKb8vtbhkrxrHfUK+sLw71rQc9QCWAEYCsRVJu8Jfj1xJSyLNuLCblq X-Received: by 2002:a17:906:410a:: with SMTP id j10mr5594055ejk.167.1628177432758; Thu, 05 Aug 2021 08:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628177432; cv=none; d=google.com; s=arc-20160816; b=osgv2jxHQiJE99tnNCx/WqcjsBxwV+I2Y24iiF4Ur6TsTaWz+ySdlQk/sWEUedApFt n1U+5JdXja3Ma7OyLo4i9LiYiGy0qbH1GOiwFQd3TDqUbIVEiyUaRylK673V1lWgCKvh ZlWp9ATzzxgjLpEQVVhFlzW0pQ0rKRXVchhudZ2bw4+I2GnRkyzUGdcpKE4l3OVpaFGc Y1+HfMtwuXaBhqDTyQST9ciDFqUQX+K7aALaeVWKfiUf30+cZh/yp8XHIF6M2Qc1i6Qv yjK7iAN25QeCVmuU4hDn7XT6vjsXo2eyonAcx1UAEXDnVupRuN2iPZoGB9G/4bWAEmZS 2d8A== 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=R8OF9oy48H16sGSYglqcUPzXTNP66A4yq3Yxy1FwsOU=; b=NHCphMBObsfWRhsi1B3OH5x/uVmW7SptGNRLcCgp6GUGSVeJ1nnBRJ3EgN/ckKsgM+ nZT8sDoIzNnzTSxAU0nr8ghlwm+cgs2CKRxk1Pk+VIqf7cVUaiQIHJYyorwOtErt7lDv IslHntv+Xd1tgiuYwUiYVveXWh0dK7oucqbjn6cNNZ7kQP7V/0whHoW+0q7IXC64NJYZ M77dtiC1uIsqI05Ulrt71/m8aQLhoS1N0xezdAyxUU+UKUKBsyvFufzrM9VwKYTTJK7e 12xeQASI9CL9B+tAFH4Sa2L0RT6e5Ohiy2HXNve+jCz/wStOFbJtJYiIpf2CO0ms5wml /ZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=00bC+hQR; dkim=neutral (no key) header.i=@suse.cz; 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 b16si6414666ejv.305.2021.08.05.08.30.09; Thu, 05 Aug 2021 08:30:32 -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=00bC+hQR; dkim=neutral (no key) header.i=@suse.cz; 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 S242270AbhHEPZx (ORCPT + 99 others); Thu, 5 Aug 2021 11:25:53 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:34154 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241978AbhHEPUX (ORCPT ); Thu, 5 Aug 2021 11:20:23 -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 8820E223E3; Thu, 5 Aug 2021 15:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176807; 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=R8OF9oy48H16sGSYglqcUPzXTNP66A4yq3Yxy1FwsOU=; b=00bC+hQRHgzZSkTWTXEs56t0xtklqlRUEiemH/Dgc8LgtPwSqyhHBfA6QZ8zFjusUI+T08 YxGhnDKJ47AxleAA163qRTLl9CR9GhtqG5zsMsBtX4DzeGF65mQUn8chhvxXJE1RSXzEZR m+03KL3/a4pad3qGBLQcvY0XsHYRGrM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176807; 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=R8OF9oy48H16sGSYglqcUPzXTNP66A4yq3Yxy1FwsOU=; b=XWQ4oGlLYkwiMepVoUqnPkh9rBN4sb20t8bM1tXp8SxRyR3C3g2IJg7207xJgggjjeveVI nCklxk5Y9hMAKkCg== 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 59CA513DA8; Thu, 5 Aug 2021 15:20:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ECAVFacBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:07 +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 18/35] mm, slub: stop disabling irqs around get_partial() Date: Thu, 5 Aug 2021 17:19:43 +0200 Message-Id: <20210805152000.12817-19-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 The function get_partial() does not need to have irqs disabled as a whole. It's sufficient to convert spin_lock operations to their irq saving/restoring versions. As a result, it's now possible to reach the page allocator from the slab allocator without disabling and re-enabling interrupts on the way. Signed-off-by: Vlastimil Babka --- mm/slub.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f7c6cebb524d..b4a62aa00ae2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1993,11 +1993,12 @@ static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags); * Try to allocate a partial slab from a specific node. */ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, - struct page **ret_page, gfp_t flags) + struct page **ret_page, gfp_t gfpflags) { struct page *page, *page2; void *object = NULL; unsigned int available = 0; + unsigned long flags; int objects; /* @@ -2009,11 +2010,11 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, if (!n || !n->nr_partial) return NULL; - spin_lock(&n->list_lock); + spin_lock_irqsave(&n->list_lock, flags); list_for_each_entry_safe(page, page2, &n->partial, slab_list) { void *t; - if (!pfmemalloc_match(page, flags)) + if (!pfmemalloc_match(page, gfpflags)) continue; t = acquire_slab(s, n, page, object == NULL, &objects); @@ -2034,7 +2035,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, break; } - spin_unlock(&n->list_lock); + spin_unlock_irqrestore(&n->list_lock, flags); return object; } @@ -2749,8 +2750,10 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, local_irq_restore(flags); goto reread_page; } - if (unlikely(!slub_percpu_partial(c))) + if (unlikely(!slub_percpu_partial(c))) { + local_irq_restore(flags); goto new_objects; /* stolen by an IRQ handler */ + } page = c->page = slub_percpu_partial(c); slub_set_percpu_partial(c, page); @@ -2759,18 +2762,9 @@ 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); - local_irq_restore(flags); if (freelist) goto check_new_page; -- 2.32.0