From patchwork Sat Sep 4 10:49: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: 12475523 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 51949C433FE for ; Sat, 4 Sep 2021 10:50:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0B3B060FDC for ; Sat, 4 Sep 2021 10:50:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0B3B060FDC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0A3246B0087; Sat, 4 Sep 2021 06:50:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F938940014; Sat, 4 Sep 2021 06:50:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07589940011; Sat, 4 Sep 2021 06:50:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id CA67894000C for ; Sat, 4 Sep 2021 06:50:14 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8A4338248076 for ; Sat, 4 Sep 2021 10:50:14 +0000 (UTC) X-FDA: 78549571548.16.F56C7B4 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf27.hostedemail.com (Postfix) with ESMTP id 3AF1D700009B for ; Sat, 4 Sep 2021 10:50:14 +0000 (UTC) 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 176812269F; Sat, 4 Sep 2021 10:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1630752613; 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=QXXtQUpt+s21y+aXf3Lfke9xhArxmbVP1MBx9NrA+G4=; b=EJWqLj8c0M0IC2tME6FdUCWusxOL4ynR7llUMhYbugE9zdlNzdt9l5LvNx8X7zkgdPiVRs ouLoLvpZsiVWbhvrkZYnY4IKoyI5CnV6CMF/VvYW2PV7DkKHHTND7yGv+2CF2RLYWPiT7X kNlnYaPEKVeLQh8atpD8PxiFFBenAOI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1630752613; 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=QXXtQUpt+s21y+aXf3Lfke9xhArxmbVP1MBx9NrA+G4=; b=DC3qiUe3uRkEwh4Mb6bdlX+FrTAlhpqZ5GYNBFGZMg2qQQqVS9N9rkE/OtMjFZAS816nRy tEGHp7nfZw3bmACg== 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 E3BAD13A2C; Sat, 4 Sep 2021 10:50:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +IzzNmRPM2HoUQAAMHmgww (envelope-from ); Sat, 04 Sep 2021 10:50:12 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Andrew Morton , linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Vlastimil Babka Subject: [PATCH v6 21/33] mm, slub: move irq control into unfreeze_partials() Date: Sat, 4 Sep 2021 12:49:51 +0200 Message-Id: <20210904105003.11688-22-vbabka@suse.cz> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210904105003.11688-1-vbabka@suse.cz> References: <20210904105003.11688-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2032; h=from:subject; bh=KkFM/bBAlZPKKs90R9QA+BXAm0w82nhYdh6z2WNGHns=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhM08790U8BrvrgoyAYQSbpj8zCYtLbEiWDjoZ/Uif r2IaOp2JATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYTNPOwAKCRDgIcpz8YmpEK18B/ 9PlC/xFu4tBBEX4KV/RM/FO7ZsUoXJe4tEJkDBWs2Du9N8kTgVCBeodPqqUZ1Q9wKPobVDUdoS/kQl /yxJqUKFHx+g7buJKuyBrki0dh8WtI9hfMXKlyPgJn8w4zqJiFr0pv1oNgYV7tn/XQxiTr1LNMYUh1 ZLKxedf6EgtgtG+nt9J8+VF9nORfyCgs4nP6wBHFe/uSHgQttuWFnSMYAgKf/60TpZZtcmUawPkyvK klouB+7v8rtcRwHFubNyNoLISHq3ojwOG7L2J7ZFYB+YSNm+BUUZN+ylcIWZDm09G7ti0Pg2gTcJ65 9azNw7915a2SEZnuoJ8aUkEFcooqSY X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=EJWqLj8c; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=DC3qiUe3; spf=pass (imf27.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3AF1D700009B X-Stat-Signature: 4rxz77ffk8hjcn6umposng6nb5cno3hz X-HE-Tag: 1630752614-95711 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 cb12a077c61c..1c4bd45d66a1 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2350,9 +2350,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) @@ -2360,6 +2359,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; @@ -2412,6 +2414,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 */ } @@ -2439,14 +2443,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;