Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5155184pxj; Wed, 9 Jun 2021 10:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOO0SLJDPA3FqEvyYuj7xdFAgIeQIYoRyV+mcVkkaakNQCES2Uz3L8O8L8Bc6VBXaWqkcR X-Received: by 2002:aa7:db49:: with SMTP id n9mr465355edt.361.1623259304915; Wed, 09 Jun 2021 10:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623259304; cv=none; d=google.com; s=arc-20160816; b=l0dw+h2uFMowzHMuLmV5ZkRjsqkC5RTdVO3D1AONnYK5L6Rh0Wedtqfgu3e7cDOpHb bIn72uedOC4jH1oYOp8ucQco36gXIOhF+kSuXmyPW8zrL7CttlCJ7rD4qdBROaC6Fcy+ xof3bJQTP8d1T306S0HNr6iAEkZ76xBiY4GyJOapTnt3e+1vwY93q8zRS9WQvLrPjgyw 3+R7eL0q1wZkL8AkVPx05Eaw8UiqiNR9UbfKDxRIida2JlXT2yKOeT43jeeq9DHSsQkW vokix8znjBBfrFo8mWqf0R6+w40uC77g0lsOY24jhHHNT6U0p5Ghzrmw16XK4CrctYH1 CPxA== 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=i+kXFJUxiAt8nF/gFOeGLQ15QjX96rJgGO1xp0O5Hkw=; b=Trum2BtOiZjclrTZ162sGwiVcA1tXOx3PPCBN4kIuMi0I3uQXrFLT+wxgrVnS4M7F0 w1ao04NKfO8c8Cedqtm2KhJeLjLZV+SUUcSm4FSQTMOQ7iW7t0fEVuDqCTVPClVswaiF te5Lv9YKgaElKGAGQ4iLVQC2//XMxZ7psTMKpfe/rGc/plx3swyRcZME1zeC0dXwdlMh jWAxOZ6JqRSqiOI9ig3yKQ2FZ7zN2MLRHkV0Thi8k8QpqAonRR4xcuRFbHzqZ8U/1X98 +emnFoR0riV9cI1xiFmw8qo2IFj2ph9u3I1VWgbxLq0E0pW9WPyLgRoCj3OY/0RE9luz o6Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=EZ1sKebs; dkim=neutral (no key) header.i=@suse.cz header.b=43aWP7Er; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=EZ1sKebs; 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 26si288101ejk.419.2021.06.09.10.21.20; Wed, 09 Jun 2021 10:21:44 -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=EZ1sKebs; dkim=neutral (no key) header.i=@suse.cz header.b=43aWP7Er; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=EZ1sKebs; 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 S239381AbhFILmy (ORCPT + 99 others); Wed, 9 Jun 2021 07:42:54 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:54644 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239173AbhFILlc (ORCPT ); Wed, 9 Jun 2021 07:41:32 -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-out1.suse.de (Postfix) with ESMTPS id 269E3219EB; Wed, 9 Jun 2021 11:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238777; 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=i+kXFJUxiAt8nF/gFOeGLQ15QjX96rJgGO1xp0O5Hkw=; b=EZ1sKebsm1bY5kIaC7UF9DQ1G7UTyLUSr9XMyF5zYN+EANnQpxhQm1tfdWkXRzv30znYUQ e2SXselrS/jgk97AcPczw3+LhCZJhHsIaF93qGh7JBJZJviOst6a3gCaRPF+ca4dF6YusJ Uuo9uoa4l0+l44z3JCV12cZIzfG1Rbk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238777; 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=i+kXFJUxiAt8nF/gFOeGLQ15QjX96rJgGO1xp0O5Hkw=; b=43aWP7ErEcQ8m4WYdN2jnhMk19VRL9YgzR8Ujy/uFvzbExDd59EeIRYYvZPn/LjgCnkLnc htaDRTjM5wTNlBDA== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id E6952118DD; Wed, 9 Jun 2021 11:39:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623238777; 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=i+kXFJUxiAt8nF/gFOeGLQ15QjX96rJgGO1xp0O5Hkw=; b=EZ1sKebsm1bY5kIaC7UF9DQ1G7UTyLUSr9XMyF5zYN+EANnQpxhQm1tfdWkXRzv30znYUQ e2SXselrS/jgk97AcPczw3+LhCZJhHsIaF93qGh7JBJZJviOst6a3gCaRPF+ca4dF6YusJ Uuo9uoa4l0+l44z3JCV12cZIzfG1Rbk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623238777; 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=i+kXFJUxiAt8nF/gFOeGLQ15QjX96rJgGO1xp0O5Hkw=; b=43aWP7ErEcQ8m4WYdN2jnhMk19VRL9YgzR8Ujy/uFvzbExDd59EeIRYYvZPn/LjgCnkLnc htaDRTjM5wTNlBDA== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id 4CbVN3iowGD6XgAALh3uQQ (envelope-from ); Wed, 09 Jun 2021 11:39:36 +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 28/34] mm, slab: make flush_slab() possible to call with irqs enabled Date: Wed, 9 Jun 2021 13:38:57 +0200 Message-Id: <20210609113903.1421-29-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 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 12d35d6a6eaa..5c70fc17e9be 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2438,16 +2438,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); } @@ -2457,7 +2469,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); } @@ -2473,7 +2485,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.31.1