Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3847794pxj; Mon, 24 May 2021 16:46:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7zNznyCMYbv4Cqfn02l/u96Ez5fychvAr6XMo08S/QmfMAeI1BXsNzikoP7J4vB2NEcrf X-Received: by 2002:a50:a404:: with SMTP id u4mr28640559edb.112.1621899973067; Mon, 24 May 2021 16:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899973; cv=none; d=google.com; s=arc-20160816; b=AcAzICYta/lsY1cPn8GhwQu21UqRfxd36rM9uBqxrhNZxqwqdYchGOrLfBw0yOHJXg DPbiN90UJpdRy3ajeVFeGFu2HESlUQOAv8D4gJ2eDSMlWPI2fKt2Ts20INmALMBzFo8Q bBhsVNaB4v/TMXJrAH5VwzsDYx29RrB+wbpa4mDNsPFWzGz8qLEbogL/rYS4D10JEA3C +ySZHAX6nLUnLRZqyiBzKqFfDgNVOEAQsXyX6sW+rf0VS0uis9cAmCBv83WWAuz95BU5 l3GPTZNbXqCCnGmzh+lGq1t5qWRWhm7XImss1sfwn50wgGKZoBMXaK5xkl5iaQFfoxxn ZkTQ== 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=8aiQwK4df8tDnzTlsaSf3SJq73hoGcFgjjePzs7fO+U=; b=uld7sqbb5KmgHz4OcJvgQza9JRDUF/VADZCV05b+wjbcuV0btIp1zU74bOM2JWSpuL VZJI5x20QOKi51KuYXvs4Wjeiylr03k2BgKRhXgFs+4f8GU2xBun28wTX+E9dPZJcs8i R0SPIj4K84My54ew+g2oo4GvRFFu+4qR+IQ1r/v6YR8ULswp5dsCT6qT29GIIWBYFDO1 y2ItdKQillbI/7bkoCDyrfSH2GsRg6U6RQo/B/+AQZjLCbeK59bz9sODv7rYiDHhGvvZ Xerow+MelLhsl6G01mA4WrLdA9oewLRlVHXxnAXlcP0vfiPRBHLeBFg+4wjsXIPJX7Uc lVfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ey83G9BN; 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 m22si13972939ejc.115.2021.05.24.16.45.50; Mon, 24 May 2021 16:46:13 -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=ey83G9BN; 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 S230229AbhEXXnv (ORCPT + 99 others); Mon, 24 May 2021 19:43:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:50690 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbhEXXmW (ORCPT ); Mon, 24 May 2021 19:42:22 -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=1621899649; 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=8aiQwK4df8tDnzTlsaSf3SJq73hoGcFgjjePzs7fO+U=; b=ey83G9BNV6qKtgSw0R0jNkLvTroUNyE3N7E1bKKIvmocpOJNRbQ+3dqZIX4xJAxj9p55wP 1HlK4Y1EekunZyqm+A5faUE9WrbQ0jQb7Vd/WdBNoGp8qVmTe9UVmIDD4E8qkkQhPNF3zH 2Um327Z92MR4aHvP7+ESzpaCA/dhkGQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1621899649; 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=8aiQwK4df8tDnzTlsaSf3SJq73hoGcFgjjePzs7fO+U=; b=2jCoI7PPUmnPfzFHXtsYZhnP1YxE/pHHkdSBx2T/vLmC3QbJykdjwDG1FaFgAhu31yT2Q4 ylL8iqaRR+c+4dDQ== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0F103AF3E; Mon, 24 May 2021 23:40:49 +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 19/26] mm, slub: move irq control into unfreeze_partials() Date: Tue, 25 May 2021 01:39:39 +0200 Message-Id: <20210524233946.20352-20-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 unfreeze_partials() can be optimized so that it doesn't need irqs disabled for the whole time. As the first step, move irq control into the function and remove it from callers. Signed-off-by: Vlastimil Babka --- mm/slub.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 01422c757f9b..446d2d5344c9 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2304,9 +2304,8 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, /* * Unfreeze all the cpu partial slabs. * - * This function must be called with interrupts disabled - * for the cpu using c (or some other guarantee must be there - * to guarantee no concurrent accesses). + * This function must be called with preemption or migration + * disabled with c local to the cpu. */ static void unfreeze_partials(struct kmem_cache *s, struct kmem_cache_cpu *c) @@ -2314,6 +2313,9 @@ static void unfreeze_partials(struct kmem_cache *s, #ifdef CONFIG_SLUB_CPU_PARTIAL struct kmem_cache_node *n = NULL, *n2 = NULL; struct page *page, *discard_page = NULL; + unsigned long flags; + + local_irq_save(flags); while ((page = slub_percpu_partial(c))) { struct page new; @@ -2366,6 +2368,8 @@ static void unfreeze_partials(struct kmem_cache *s, discard_slab(s, page); stat(s, FREE_SLAB); } + + local_irq_restore(flags); #endif /* CONFIG_SLUB_CPU_PARTIAL */ } @@ -2393,14 +2397,11 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) pobjects = oldpage->pobjects; pages = oldpage->pages; if (drain && pobjects > slub_cpu_partial(s)) { - unsigned long flags; /* * partial array is full. Move the existing * set to the per node partial list. */ - local_irq_save(flags); unfreeze_partials(s, this_cpu_ptr(s->cpu_slab)); - local_irq_restore(flags); oldpage = NULL; pobjects = 0; pages = 0; @@ -2417,13 +2418,9 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) } while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage); - if (unlikely(!slub_cpu_partial(s))) { - unsigned long flags; - - local_irq_save(flags); + if (unlikely(!slub_cpu_partial(s))) unfreeze_partials(s, this_cpu_ptr(s->cpu_slab)); - local_irq_restore(flags); - } + preempt_enable(); #endif /* CONFIG_SLUB_CPU_PARTIAL */ } -- 2.31.1