Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5040356pxj; Wed, 9 Jun 2021 07:52:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZJoYbyZ41+ZXxxvTnSCfy1JBTjF+Y39oKKf/7rxEkgJRJ5qTgJ6Mx3lywL4/Vn9tQXROp X-Received: by 2002:a17:906:f88b:: with SMTP id lg11mr240752ejb.99.1623250339767; Wed, 09 Jun 2021 07:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623250339; cv=none; d=google.com; s=arc-20160816; b=0EcBBVerPYT7KN+9onRuhVP3az6c7PGPwzL/0mbsVN86AbtNW2jyos0rN59ohMdm4o whgVky67IZ0MFhn4PDXd31s2O1hRnqCQR4wM9LHY49XMv0syUDP5jxgDxxFHc6c80ddW KLmV0wafHkZN1teM2o/fgQOFSCKnrfvt2zBGEmTXhxp3rI6LzR/5n2fvspsI8dPQcNEQ 3cR4UE90ilhXV2bkt++G/dgfWAFh0Dk2Uh/xh4ivf6MX1wmuHGPGrrkQfWyTFL4nMAZI M2oDvPzwpshZXyX5BFZ5zMTk0uYv6lbWprfjtRlU/Ul6ZqZBRxEL1H+9tAfzO/MP/fES 8n/Q== 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:dkim-signature:dkim-signature; bh=q4H+O6ZFlXECn/j2lYWRNSXW+SmHmqvp1ZhSwxPI3Jw=; b=DjK7YwJIzd5P74W4Sn1RMepd7sDWufqa/hy4/XmvpZeOwvOvsBVmiGlTfiL1T2cxgt mndtRRguh4EmQzJqEuMJBaecg1ytYU1rASlLWL1p3b6JnH+JQHx88m2E4UbX0GEFv9zy IiB0+BIh7jouYNqNGLK7E3d0uH4LIal84xy10agDAqx4gb3gul4xj10Ln51QwSBqmSiP ggzCbI1fVW80VaR8bnE7DHNDbTBkPEPamDdAznQUvs7KJaCzj7C3dbFVRQrbSZLVmZUB vo4C0Qa1t9BIOAqzh9xMqN68Lh4kVZ61CY99Iike+mF2UL2yyVia+DtpOqJuQFG9/TQ1 PdlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZC9wIZSP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=Ts2r0o78; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZC9wIZSP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=Ts2r0o78; 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 p21si48534ejn.31.2021.06.09.07.51.55; Wed, 09 Jun 2021 07:52:19 -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=ZC9wIZSP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=Ts2r0o78; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZC9wIZSP; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=Ts2r0o78; 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 S239345AbhFILmn (ORCPT + 99 others); Wed, 9 Jun 2021 07:42:43 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47098 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239164AbhFILlb (ORCPT ); Wed, 9 Jun 2021 07:41:31 -0400 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 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 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; -- 2.31.1