Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp651954pxt; Thu, 5 Aug 2021 08:27:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhKmGWMlX3ftHNOBQc8UuiTG5l3DeyxfI2rT+niqhBm6kQcEVpPiOh4aqdHnDwd+zbFhMv X-Received: by 2002:a17:907:9875:: with SMTP id ko21mr5452989ejc.83.1628177230740; Thu, 05 Aug 2021 08:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628177230; cv=none; d=google.com; s=arc-20160816; b=I1dAxkCawQaAsAtHTjkYFy/FZ8+mXO9Amm93BKbPPFc5JMO/+WrJZdkD0rZB80MEOY Mgtl0WukQetksSWg4D0xbcSGgrzyqzHgHmRCst4m3kw0lx1WZOfcI4m5/MDxsbGhxDwh tHlpWddpJDYvFOMAVi+ZdtIvrif3v/7mVP7yPxiEnoDC5W7/6udYlXMn8YBcPnwoxxD6 Z1DYbsm6dZOHJVsMaP7zoD0H9ubeThhFvGCsskVKNElXx9+yIxLHJ6auCSH+2OGotF7Z PLj/DEKYAuJyspZZWQ1+elRWSvqDDmTIrq30QF88GWx7tiR/8rTACSZL1PnFlfWR39hD 3b1w== 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=IlQnS0KMVe89QhFjv1FK06xzb00jNMRlRCiWXsCz02c=; b=aCQHtEhxWkUOnD2eWo7LpnHnS6jp5LxxV8USdlh2TkXR+gOaH/XF6VB+6P8vdq3R8T Bl62NL7kVKQdQlAlJX/iJl34tlljjzAPQ0Y1LvVZ7tVzzDklCvFLfAIQtyxrKQ7q49bO dPw4T63Tzn77Ar4IJWgydDGBimaKzaG80n/5LQ2L4+F/mL0jSr4utdVzrO9E0UPE2kV8 40oHmVN74HMeaT3814be0Gtsv7ittABMpRuod2lvWwOHWwB2sizUjwotzjmxkQXU2NyD rn8S78Cz+THRhLYkXOmv8YBU8eFTARRdg91wV4B8ZxdHxXAwW+lwOxlp9txoUPzHFz/z hTfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="04pc/Vnd"; 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 d16si5742660edy.450.2021.08.05.08.26.46; Thu, 05 Aug 2021 08:27:10 -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="04pc/Vnd"; 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 S242122AbhHEPZN (ORCPT + 99 others); Thu, 5 Aug 2021 11:25:13 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:33984 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241984AbhHEPUY (ORCPT ); Thu, 5 Aug 2021 11:20:24 -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 454AB223E4; Thu, 5 Aug 2021 15:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176808; 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=IlQnS0KMVe89QhFjv1FK06xzb00jNMRlRCiWXsCz02c=; b=04pc/Vnd5KuV/y8Xl4FFuxRtTZ/DeAYz1+h0Mg6imSH+zO4a4SaWDvkAkzJfo1ZmR3GySA SY6Yx+WlEBkr2ks0yUZnGWuWcXeboL7pzh0zY2irIZJPeQKeKNzUBmICLtZKZsK/bc7XID Jj879GhvKObRygiIbfXaxqS/VBbPmTM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176808; 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=IlQnS0KMVe89QhFjv1FK06xzb00jNMRlRCiWXsCz02c=; b=FUhpoqS+8g/S0XTpWS5mCfQZBbhITH0HS83EgASFh5hlK0TdYBgNxroKJQeRbXqfTKy6dy hZMWvSRcL77WtUCQ== 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 1B62813DA8; Thu, 5 Aug 2021 15:20:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SH8tBqgBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:08 +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 22/35] mm, slub: move irq control into unfreeze_partials() Date: Thu, 5 Aug 2021 17:19:47 +0200 Message-Id: <20210805152000.12817-23-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 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 8de4ead2dbf3..51f8d83d3ea8 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2333,9 +2333,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) @@ -2343,6 +2342,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; @@ -2395,6 +2397,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 */ } @@ -2422,14 +2426,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; -- 2.32.0