Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3847150pxj; Mon, 24 May 2021 16:45:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmgKvZzErrPFv4aYN3Jgs76bn1NSj0l8MytwqA7dZMLCVl4JZeG74w3sFK41UlFn9Bcwzn X-Received: by 2002:a17:907:98e6:: with SMTP id ke6mr25471943ejc.107.1621899903780; Mon, 24 May 2021 16:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899903; cv=none; d=google.com; s=arc-20160816; b=p5UfIn4Ved2wD36+QZ247UQXclyl4e218wG1zG744X/OqrkTrNARpxlNwkaow9/LEP 80ctd1jtMwhYHFyWDmSCLLjyEM4ECs6ZER6P+LzxLwD/9dYeHYF56wg+J8V9wC7CG5PG yLkngc7mvv0uJZy8DUqEfR7etpqCuQ/ej3JJyL9hrkDRYyBxU96dW53cG5TTgTw4Nyqz yUR9RmMs24bYdjHPa74OcIe1WWzI/q+0cTluX0fTuVQBEsG62/iMUA0h2I81OJHabeEr 2vRL1D3PPViuXhg9u4CXDgR4Z0mrjRTjdoQVXTVJ7mpkBUcFkZ5b3s/mpwQPFCeZNQUK BHoA== 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=pujOlIhYWPeMTKEY13Ihu35BcGQbMGosNCP4JLGFGRc=; b=MHHhn44J4oshLWEF3twk+3fl8QDQHnE50wYcuGjd4JYEMBRSLPycuXwLD9u7ojHZAs aOu3UQdNNa+8bQxAzldaEv/Gge69OjAkoBoci9ElZ7XJXaAgMfoMludXjM2lZshAFXRD Tyq796GNyd3yD/WUD49QPdA5gUXsYAmKFe7RnOqdo5Dny/CM+UzBdFEQ3z/G9F0su+EF V4GyeqqTtDcU71xB6uV1mvH6krKlgzllvFaJt6IHgH4Rx44EpG275qf9ABoKl9iMAtk4 fCnudaRP0HgfBioYxrKXeNTpx+myeEZDTqWKlVld9qH/z8Im4dkmLjnzDU8/Mh0VSJpT LnqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=F97vcPNe; 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 g9si10098153ejt.82.2021.05.24.16.44.41; Mon, 24 May 2021 16:45:03 -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=F97vcPNe; 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 S230085AbhEXXnZ (ORCPT + 99 others); Mon, 24 May 2021 19:43:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:50686 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbhEXXmV (ORCPT ); Mon, 24 May 2021 19:42:21 -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=pujOlIhYWPeMTKEY13Ihu35BcGQbMGosNCP4JLGFGRc=; b=F97vcPNe0EcFqemti6Ay4RnyEq6vlmtCNoW7OtVhokSEGIzq90Bjw8Dbg44VqM94GlylWa rlcPX0L6qizYXu6xT7+pufXk/z0WMn7z6PTirGBRsrU1PpFOGwY5jUMJ67gMLH38z4qrzb BuiCRR+lVaFfbklTwaLPZ3nDoAvC1xU= 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=pujOlIhYWPeMTKEY13Ihu35BcGQbMGosNCP4JLGFGRc=; b=4gKyKM0f3X5lgv6ynP+Wq7V/h/yalpNL2pUTobVYUoDgbWATWd2TdbXubSxUSU7jJhNTpk 4pF3HNYbxQKwfQAg== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 83FDFAF37; Mon, 24 May 2021 23:40:48 +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 15/26] mm, slub: stop disabling irqs around get_partial() Date: Tue, 25 May 2021 01:39:35 +0200 Message-Id: <20210524233946.20352-16-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 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 | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index e092387b5932..bc7bee5d4bf2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1964,11 +1964,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; /* @@ -1980,11 +1981,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); @@ -2005,7 +2006,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; } @@ -2722,8 +2723,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))) /* stolen by IRQ? */ + if (unlikely(!slub_percpu_partial(c))) { /* stolen by IRQ? */ + local_irq_restore(flags); goto new_objects; + } page = c->page = slub_percpu_partial(c); slub_set_percpu_partial(c, page); @@ -2732,16 +2735,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: freelist = get_partial(s, gfpflags, node, &page); - local_irq_restore(flags); if (freelist) goto check_new_page; -- 2.31.1