Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1221374pxb; Sat, 4 Sep 2021 03:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/kGpqzBOXrxpFn+KOZmNmmCGcDF0yMldoAwWb6RCh0YQFF6OQveR9isX6+OI7wMOYmZ+i X-Received: by 2002:a5d:9693:: with SMTP id m19mr2505936ion.181.1630752778635; Sat, 04 Sep 2021 03:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630752778; cv=none; d=google.com; s=arc-20160816; b=qAwRnOhAGxyQuIH5CW9bzbPQc08oJoycKkrwiz944SZcN+yQRQTanaq00c0jBSyoUZ R7rNDI1RSwvtelR5pNQAURaHjbhFwM7F1gt6ekdp7MwG9KmiLdNmfXezOYQvtRRsl5Pk IqM6SMcYd/a0rXGnlru1S9BzEFS9GL2yYltDpeGKvihmUctAoGxIDQ3hk6Fe26Uvcfjc /mOkuf/42ojyuR639PJGLxAy2yUdLlmdwuK5gvWxH1/cZ8QwS3tTJF9jlioPo/SgV6y2 n3gcjX2ag0BwZdWTQdfatyzM60Ue4/0HEC6NcmyaRGg16Ss0pl6OjQTh2FwgLTONw4T8 bTZQ== 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=tFMhySTaq6YX9S5AT4glg+2GS+e5+3dtX0MMjEGbNOM=; b=j6byFj6TUJU7ZWriGiM84hje/PB/BERFToH+QYsNoAuloEsBd9k01afs5KYgagE052 Ii/egRtpGVoIC2dw9wd4WKgKX3o+IHvmpqxbdgWWFgn/zDGnoElcd9YoLcCubwaWX74d hPcZphnHwERBvbNPyiFWLfrFouB3RDtcDcogANw3l273llEpD/T+8A135DLCF+7403YE GAjBm62hjNWcdNaoLsPdPV6tFEbfzcrd3VkpZMaE6mfdGw3Zhzoc/VXHMPH+Eu3WUQsX ScUG+wC7UlcmexMrkhM0vFS1PTJ14+XMxyamNhV1/7xW8CWPP5xg0MyhTHDbs/DP0Z/B ARrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=n0Y9nH5x; 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 k8si1847537jaa.51.2021.09.04.03.52.47; Sat, 04 Sep 2021 03:52:58 -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=n0Y9nH5x; 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 S1351273AbhIDKwk (ORCPT + 99 others); Sat, 4 Sep 2021 06:52:40 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:41860 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351118AbhIDKvO (ORCPT ); Sat, 4 Sep 2021 06:51:14 -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-out2.suse.de (Postfix) with ESMTPS id 6735120047; Sat, 4 Sep 2021 10:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1630752612; 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=tFMhySTaq6YX9S5AT4glg+2GS+e5+3dtX0MMjEGbNOM=; b=n0Y9nH5xLlkxKZ00bWqf712wPmz8x6ZxBjC/kHB3BcLOcaiTY+xxU0JdlI6b4xCDc2p6qj XOo+AOpDqvEj5KwqtFdOO2LShOxjBrB8dbqnRhxC5mMn7UoT8ecgmyDiYDYx51DI0f5wQc b0AdbPqVhkKbd0nPW+8jQkSgRN9p244= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1630752612; 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=tFMhySTaq6YX9S5AT4glg+2GS+e5+3dtX0MMjEGbNOM=; b=ae2g3hL7b+RjqspV0GH3negCxho2reP8CJ+JgxKm+cw2zoefwjaMHQG2gx1YAgitHWNQ/t GWIrO1xMy+ZLfQAQ== 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 40C3213A2C; Sat, 4 Sep 2021 10:50:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kIgyD2RPM2HoUQAAMHmgww (envelope-from ); Sat, 04 Sep 2021 10:50:12 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Andrew Morton , linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Vlastimil Babka Subject: [PATCH v6 17/33] mm, slub: stop disabling irqs around get_partial() Date: Sat, 4 Sep 2021 12:49:47 +0200 Message-Id: <20210904105003.11688-18-vbabka@suse.cz> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210904105003.11688-1-vbabka@suse.cz> References: <20210904105003.11688-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2602; h=from:subject; bh=52j8sujcm4of7FmRbqiBJPbkJ2aBJYGWEd6QWSsF+6M=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhM08xYuBbSPdDE/wxVSZTpEmavIss5mEc8JObjR3R M7rXrymJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYTNPMQAKCRDgIcpz8YmpEFTBCA CsSfzb6YngNCvKefgnDZLDHJpecUw7rQNdmr1HYt+eSgrcaJuN2lSFUyHb8A9W2fhGmhlQNiLAKoT6 v/TkHgbfK1wAIvIw0nnVcMkVDrGR7FUUjXA9QkSKtrK2XZ0PeVaogK40lgsnNe5Gdvgq1GrfkzAoQl cYSRjqUbLuyVIFxHK745kJOHGH8sr0fOezWsmavQ89FGR7eYFuG+PdRy0zNb0f6EkrZwZ9cxNSG3Tr p9IrCrZ+BFi6L+SG5ivQ6xC71xf/Pt7P9EzFueSzwAGRI4zfDIo4+ziGwI/tL2CS6yHHOZHyJ7BbGx UTNOfHXnX4naeuVB5YOJ5Y+HdCmqVE X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 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 b5788040d92e..8433e50d2c8e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2010,11 +2010,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; /* @@ -2026,11 +2027,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); @@ -2051,7 +2052,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; } @@ -2779,8 +2780,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); @@ -2789,18 +2792,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.33.0