From patchwork Wed Jun 9 11:38:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12309871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BB8AC48BCD for ; Wed, 9 Jun 2021 11:40:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C498E613B1 for ; Wed, 9 Jun 2021 11:40:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C498E613B1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 72AA16B0093; Wed, 9 Jun 2021 07:39:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30B336B0098; Wed, 9 Jun 2021 07:39:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 049E46B0093; Wed, 9 Jun 2021 07:39:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id AE07B6B0096 for ; Wed, 9 Jun 2021 07:39:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 591DE824999B for ; Wed, 9 Jun 2021 11:39:37 +0000 (UTC) X-FDA: 78233990394.14.277EC57 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf24.hostedemail.com (Postfix) with ESMTP id C643DA00025F for ; Wed, 9 Jun 2021 11:39:32 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DE7951FD6C; Wed, 9 Jun 2021 11:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238775; 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=q4H+O6ZFlXECn/j2lYWRNSXW+SmHmqvp1ZhSwxPI3Jw=; b=ZC9wIZSPPZ24y4U1q5vUZfHTz84l/8N5U2Ax2XOLWhjYGtaJQLC8erCQhKhO+QauwuWH5w dln/ljCmlVZERrlh3Pw8i2+UfrYvQzzzsCObf2uojkNZzWWAjsbFlK39FEVTjQ34JO7mXf bu7c3GDxUmrgXbc1O8QT+I4ocoJH/IM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238775; 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=q4H+O6ZFlXECn/j2lYWRNSXW+SmHmqvp1ZhSwxPI3Jw=; b=Ts2r0o78WKFso4GH8IJlkQM6/kQ01FT+XM3VFmg/VZ9SnbTug3DsK+Zog+T4ooO85T2DMh /SS6Ce2bcXUHYqCQ== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id AD014118DD; Wed, 9 Jun 2021 11:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238775; 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=q4H+O6ZFlXECn/j2lYWRNSXW+SmHmqvp1ZhSwxPI3Jw=; b=ZC9wIZSPPZ24y4U1q5vUZfHTz84l/8N5U2Ax2XOLWhjYGtaJQLC8erCQhKhO+QauwuWH5w dln/ljCmlVZERrlh3Pw8i2+UfrYvQzzzsCObf2uojkNZzWWAjsbFlK39FEVTjQ34JO7mXf bu7c3GDxUmrgXbc1O8QT+I4ocoJH/IM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238775; 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=q4H+O6ZFlXECn/j2lYWRNSXW+SmHmqvp1ZhSwxPI3Jw=; b=Ts2r0o78WKFso4GH8IJlkQM6/kQ01FT+XM3VFmg/VZ9SnbTug3DsK+Zog+T4ooO85T2DMh /SS6Ce2bcXUHYqCQ== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id yNy4KXeowGD6XgAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 11:39:35 +0000 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 v2 22/34] mm, slub: move irq control into unfreeze_partials() Date: Wed, 9 Jun 2021 13:38:51 +0200 Message-Id: <20210609113903.1421-23-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609113903.1421-1-vbabka@suse.cz> References: <20210609113903.1421-1-vbabka@suse.cz> MIME-Version: 1.0 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZC9wIZSP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Ts2r0o78; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZC9wIZSP; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Ts2r0o78; dmarc=none; spf=pass (imf24.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: 9gbenkz6uorobogzqy58qqjny6ope3fa X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C643DA00025F X-HE-Tag: 1623238772-640034 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 the put_cpu_partial() caller. Signed-off-by: Vlastimil Babka --- mm/slub.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a99a254f2410..4a3cd8174cd2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2290,9 +2290,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) @@ -2300,6 +2299,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; @@ -2352,6 +2354,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 */ } @@ -2379,14 +2383,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;