Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6094939pxv; Thu, 29 Jul 2021 06:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI+XHJ8Vxfoh6pAF2mBHUneGvisqW6nc5eK0HKLT/c8yib8hLkFf/hQ5tZeIPzzZ1jQYiT X-Received: by 2002:a17:906:d20b:: with SMTP id w11mr4716967ejz.242.1627565119244; Thu, 29 Jul 2021 06:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565119; cv=none; d=google.com; s=arc-20160816; b=nbNSh86HSy8HH1DsqdbFxAzLfIxxr+pOD1u+NlKyH3U/+8mKovHVdab7cKsdziKkvy KauoxuXcOgsPbRWzF7nbzLqTMGRwRyu0oPfI7vlM5biOqDRGeec+y6xXcNlCoVQR3uKG 5/WDKmoxz7PTv40nDrgzxeMssGVownoaRb+m4MsJ2/bloqN/H35Q+hdShi5PPaz7Jjnp TrJAFe+fKwNrb5dFKaZ/KXarPY40VdkTcarkUyaYPnDCOfHzl8Gl/nIhoUNU+ZHx3oNx FctUY9lHltcDJc0YlOYCy5xu0cS8sSF42iUc+H9FZ513uEAy1rSSQ05AZsceDKfEY68g OylQ== 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=P61v5SrVVVwb0JE0HPIFaGZVNsseWHcamks9oxC0x+w=; b=K0oi0OGDcn3o2xecJn0Gk/rTTD8OXXTN9RbyA81iT3uoUaiwc1LG6WEWNhL3hf3EqA AeCReRPjXwTXYUgiQU+gh25UmtpOuAjyuklYkcD//0uxhFqASbKq49VbFtcsPzXdWavE +NeVzAWf07SIMaA36Da0Do50CF0i+u++Jv/v5KGdxpfVmUb3lcNd4A1F+lz+PT5qkcTl mPpjl/luuAq0PvsE5B4PDLKpA1/s/nJwqNgRGsFpZ9ppUtgAeg634LacsBSfP8wbHd26 nlR4elO40AoBjgv3HQOqaxl5G0RU/b6/FAHXsULMGh3QH/14PXLSpFpGd8oYk4u+k7Hc oEEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Gim9fgEI; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=LiPcwygh; 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 l8si2542835edc.520.2021.07.29.06.24.55; Thu, 29 Jul 2021 06:25: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=Gim9fgEI; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=LiPcwygh; 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 S237569AbhG2NXd (ORCPT + 99 others); Thu, 29 Jul 2021 09:23:33 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:38710 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237554AbhG2NVt (ORCPT ); Thu, 29 Jul 2021 09:21:49 -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 AB660223DD; Thu, 29 Jul 2021 13:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627564905; 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=P61v5SrVVVwb0JE0HPIFaGZVNsseWHcamks9oxC0x+w=; b=Gim9fgEIjDIbS501ysXYxL7HZMVvw8fAp0xnQVZijzX7DTM0AnCr+c+cRjM6HkfKBX8L6W lgIjtSQDtzf7KpMpnJ6+xI0qkBgvoeg+oO5nVTLzMqQoI1ITrlgBkp5/GIN87s6IGwPZ6Z edLtrhkcanxALx5bvvx0GkACoKH2mJA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627564905; 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=P61v5SrVVVwb0JE0HPIFaGZVNsseWHcamks9oxC0x+w=; b=LiPcwyghr2zNTdWY6flaO57GpVTv4mfeXvIMVCW0QJQrURzdT4ulHqqJofRygPR4BSIYh7 1WcImkoXiJnqXeDw== 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 805B813AE9; Thu, 29 Jul 2021 13:21:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kFnFHmmrAmF9AwAAMHmgww (envelope-from ); Thu, 29 Jul 2021 13:21:45 +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 28/35] mm, slab: make flush_slab() possible to call with irqs enabled Date: Thu, 29 Jul 2021 15:21:25 +0200 Message-Id: <20210729132132.19691-29-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 Currently flush_slab() is always called with disabled IRQs if it's needed, but the following patches will change that, so add a parameter to control IRQ disabling within the function, which only protects the kmem_cache_cpu manipulation and not the call to deactivate_slab() which doesn't need it. Signed-off-by: Vlastimil Babka --- mm/slub.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index edda419ec260..9fbc5396f3e1 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2477,16 +2477,28 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) #endif /* CONFIG_SLUB_CPU_PARTIAL */ } -static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) +static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c, + bool lock) { - void *freelist = c->freelist; - struct page *page = c->page; + unsigned long flags; + void *freelist; + struct page *page; + + if (lock) + local_irq_save(flags); + + freelist = c->freelist; + page = c->page; c->page = NULL; c->freelist = NULL; c->tid = next_tid(c->tid); - deactivate_slab(s, page, freelist); + if (lock) + local_irq_restore(flags); + + if (page) + deactivate_slab(s, page, freelist); stat(s, CPUSLAB_FLUSH); } @@ -2496,7 +2508,7 @@ static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu) struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu); if (c->page) - flush_slab(s, c); + flush_slab(s, c, false); unfreeze_partials_cpu(s, c); } @@ -2512,7 +2524,7 @@ static void flush_cpu_slab(void *d) struct kmem_cache_cpu *c = this_cpu_ptr(s->cpu_slab); if (c->page) - flush_slab(s, c); + flush_slab(s, c, false); unfreeze_partials(s); } -- 2.32.0