Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1221510pxb; Sat, 4 Sep 2021 03:53:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkfizsV1VSHmrakOpf6J8RNuP+b0Mp2/l14AAiQfKJalCPiYyZRQ/tpidF2+XtZYLhMLBf X-Received: by 2002:a02:330f:: with SMTP id c15mr835307jae.41.1630752797519; Sat, 04 Sep 2021 03:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630752797; cv=none; d=google.com; s=arc-20160816; b=gI1ZaHidLVR6ojfDiGGjTTpN3+p+DXK5SqNeeI5n+O2HrK4xj0U2Oc2oauCm909LBr 2Qv6ceQGiXB1t7OE4dn+YpT77qKKl36KXCqghB1IODncYgV/EMrKYJulYD+swFR5jPVz S5Z+4uEZyVEDILpc02jTkzarQSevsFdfvEtg12nDw2qI3efIXKQANx1hYhs5QvIg/HHO zWBNyqVj5sazxd3x/RKSs8OWMNrqhFhjuOTTsWLlq7ZmHgx7YA7Fuu/nhL+96UIfaTqr UnqyNiIM1LAo6tBOUO40oqw8bp6mOHGYjiqpwn4JZZR3h7XXDiAINzX7dxjgETlpz+nN 5/gg== 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=iSpQG1+PfwLKiMgJfknaJqeXj7cXw4vf/kl9y706Bhg=; b=vviZOyQFH3+yepBOKO+YyAJze5z9aUv2IUSfMjGi/jmBLD9Re9U3hRO2kuydHJuVNQ unLy8UpXfFiiWJg1a5yFtlIkU8A+JcMYJtm5qS4B06azlVkwP6HuyJHJx8o8Vl3Ibyxs e3DeimXo2644mjTw3lMNUTHzjDfo3de4+2p/Vva8KRh1TrV23VJaGbHmOiUkaoryZIG3 wUL1rXS47B8nhM4+G39hpESjIPLMMKLIUob8xlJJSE9sTvWQz9KLzPdUAdFCRXYKAgax 8WnQMryfkRd7PSfa/ULZFs+nI7y0F6SWN5sxtyIXcc4A1r3krcYQ1gH+cBpKUIQbO01z qhgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=kBFNjaGe; 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 c4si1671565iok.10.2021.09.04.03.53.06; Sat, 04 Sep 2021 03:53:17 -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=kBFNjaGe; 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 S1351361AbhIDKww (ORCPT + 99 others); Sat, 4 Sep 2021 06:52:52 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:59794 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351149AbhIDKvQ (ORCPT ); Sat, 4 Sep 2021 06:51:16 -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 21060226A2; Sat, 4 Sep 2021 10:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1630752614; 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=iSpQG1+PfwLKiMgJfknaJqeXj7cXw4vf/kl9y706Bhg=; b=kBFNjaGembaer+vkNpQ/n87tA3rdoNkMNLE1J/0B6bIw66J3h0r0/Onr+QqiMKbcm/X1dH rO+bTpVNuM8ogAVyyJbnZTLfk4QPfh5iLYR/Opz6ujvH+udhAlkaD8CrgtfHJSxDTJ1ZT5 bmcZzZGSzSF8FNFFisx+LEUM9vLk8vs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1630752614; 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=iSpQG1+PfwLKiMgJfknaJqeXj7cXw4vf/kl9y706Bhg=; b=kCW/C6ClzXP0qrkeELjN6iiL66wL7lhmykDM9yB4ZvwdcA1yIhZw9CYqLkngG7HyPz2/QE LUVHmGDCWQAnRADg== 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 EA7F913A2C; Sat, 4 Sep 2021 10:50:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0AEoOGVPM2HoUQAAMHmgww (envelope-from ); Sat, 04 Sep 2021 10:50:13 +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 27/33] mm, slab: split out the cpu offline variant of flush_slab() Date: Sat, 4 Sep 2021 12:49:57 +0200 Message-Id: <20210904105003.11688-28-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=1480; h=from:subject; bh=Me93t/ujdmp4NIcicG7SIS7AaN3bj9p7Xn+WAdX4uvg=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhM09KUSTBRuzrR5kT1PPvCxtCuMM0lzUc2IGoF+87 gDGdpiOJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYTNPSgAKCRDgIcpz8YmpEERJCA CYMPna+TQkf7B2RM7MZCyWwsuRm/ZDyUTUAQ3tECgppZ38qu0PbOfjaT4h0ANkIzTFNL3umsHelShB UlDEBmqSkN7X/b2UKKPjFg5gVeqMpxqBV1tC42TGfK2KEKcMy/tC610mSG0GsEw42Z/zwqJwet/3fC 6NEUHqdQ77phe1YpuXnqmHhFHRlmSuabHgX1JQvB9XdTOtIyw64bENDVG0qZuMNTrX31nuKFg25why 3/X1Wm/gl9V1EqNoHDqYns9TFGvTXVVKefwIGC3vXSoJOW6iYSJpAQ7TqppNai+qGkQd4SvRhIenaY zBFf20EjtZpd0bsbZPyTM9dhgWeI/T X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org flush_slab() is called either as part IPI handler on given live cpu, or as a cleanup on behalf of another cpu that went offline. The first case needs to protect updating the kmem_cache_cpu fields with disabled irqs. Currently the whole call happens with irqs disabled by the IPI handler, but the following patch will change from IPI to workqueue, and flush_slab() will have to disable irqs (to be replaced with a local lock later) in the critical part. To prepare for this change, replace the call to flush_slab() for the dead cpu handling with an opencoded variant that will not disable irqs nor take a local lock. Suggested-by: Mike Galbraith Signed-off-by: Vlastimil Babka --- mm/slub.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index c4a9b8901576..fa9a366d2d9c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2511,9 +2511,17 @@ static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu) { struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu); + void *freelist = c->freelist; + struct page *page = c->page; - if (c->page) - flush_slab(s, c); + c->page = NULL; + c->freelist = NULL; + c->tid = next_tid(c->tid); + + if (page) { + deactivate_slab(s, page, freelist); + stat(s, CPUSLAB_FLUSH); + } unfreeze_partials_cpu(s, c); } -- 2.33.0