Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6094812pxv; Thu, 29 Jul 2021 06:25:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwtpi9T87alLOATAyH5dh8gplW4Fti7UlKtm8fCg4Q+mHDgIchiyEr45L4gq6ymy8FVyPA X-Received: by 2002:a6b:c9d3:: with SMTP id z202mr4099061iof.44.1627565108795; Thu, 29 Jul 2021 06:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565108; cv=none; d=google.com; s=arc-20160816; b=0OlNlLUcsOzqM6ooZTUNpOg/FFaISOWBs86rwxev9ir1f3DDV8TJiO9mQMpgu6O2Lg /Mjt8nIbj+Ej8jzhYzJRmKe+9JoxJ8JBi8Zidb7IZZNCAZdbWWzx1NKGfyfuwOLrDWtx Ee+H2Z5z9/jBLYj/jsTE8UkAId9WJqJ+f5AB28i0hAhZORTE6UZoarj8Kv/10VyhlA2U 8lf/ZbHHF/F1rC/3f1MTlxYeygMylhVD1ev4gXKqyddU8wNbV8Q3nc1RXbJyEygwFpxa Xm9k7i4hJawC7/QkvoUPAK92ZEm1je2aZy6X4WkbElKHdyZ7Cvx+rxZ0h4yMtPvfBp6E Jw2w== 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=olVj8TzJyA+2dnvSaGBci9jPLrnTCwoE5VuT2aCUAwQ=; b=J5An/8i66E7vp+8+euxA/qNuaEfnlc1guvvsBU5qXD7/W7lfi6Z/q1UgZWKaDFfvVK Cn/RsxZfAGyGXy8xTSuEvZbW+35XYGEEBVsvzn9qXNFHLTU+K+uDh5JOXmXS5lw99es5 kMju1EP4w7wuUsqAA+pIRQJlZSvlhsbRWRV8O/QuTcODpZ6aOg+Rnb2iZzAS0dQRCN3b 7hAxCP9utRqrHGx+PDJj0t1BINRGnf6sK+hX3H/LiPXh9B68GKdO1tBnBduwIy12b9nP KqT+IbdsZ8k8ne4/EhiCZNLfOQicMj+Ppbv1sEkTJjSEBAyL+pcrgGkplNIR7Gzvf9X/ shOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Iu3K2jwf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 y7si3378709jae.125.2021.07.29.06.24.57; Thu, 29 Jul 2021 06:25:08 -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=Iu3K2jwf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S237795AbhG2NXG (ORCPT + 99 others); Thu, 29 Jul 2021 09:23:06 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:56744 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237517AbhG2NVs (ORCPT ); Thu, 29 Jul 2021 09:21:48 -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 8DB2D20043; Thu, 29 Jul 2021 13:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627564904; 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=olVj8TzJyA+2dnvSaGBci9jPLrnTCwoE5VuT2aCUAwQ=; b=Iu3K2jwfkQ71ATLXmt0CSwoXbkEfSyIb2IhKaNEnkUxuBgFg6Qpcj50x4ZqQJd3mQLxrC3 /UM8YpLPg+tvLQefW6/AaQUrB2AMsdfTm+Rda1DVJk/j6cmLJXPw7yWGy3i5Bh000sdtMV CAisFHFeSbRFHJlRmzVHJnzmPnPyA64= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627564904; 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=olVj8TzJyA+2dnvSaGBci9jPLrnTCwoE5VuT2aCUAwQ=; b=LcY4UGnfulfSWszuVgT7O1KJu9ucGRpUbRrSuW7QkFQat5ZFQrT6LsMTvmfocjl58/056h HHpTtMhxevZtctDg== 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 5DD7E13AE9; Thu, 29 Jul 2021 13:21:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0Ow7FmirAmF9AwAAMHmgww (envelope-from ); Thu, 29 Jul 2021 13:21:44 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v3 22/35] mm, slub: move irq control into unfreeze_partials() Date: Thu, 29 Jul 2021 15:21:19 +0200 Message-Id: <20210729132132.19691-23-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729132132.19691-1-vbabka@suse.cz> References: <20210729132132.19691-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 1fdbc2ea8f67..0ff103ea73d2 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