From patchwork Wed Jun 9 11:38:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12309867 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 9A510C48BCD for ; Wed, 9 Jun 2021 11:40:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C4CC60FD8 for ; Wed, 9 Jun 2021 11:40:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C4CC60FD8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 04DE96B0095; Wed, 9 Jun 2021 07:39:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E519D6B008A; Wed, 9 Jun 2021 07:39:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1E246B0098; Wed, 9 Jun 2021 07:39:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 62DB86B0092 for ; Wed, 9 Jun 2021 07:39:37 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D7D78BA10 for ; Wed, 9 Jun 2021 11:39:36 +0000 (UTC) X-FDA: 78233990352.20.6DA9D97 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf11.hostedemail.com (Postfix) with ESMTP id 09F3C20010A9 for ; Wed, 9 Jun 2021 11:39:31 +0000 (UTC) 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 7B17E219E5; 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=epQKKcaNSs6oc8v4JtInuf1QdvJlAwnRMC1xTjWgeXI=; b=WO97LCf9vSIMTWJg/0ZzucZdzc/KUz0BS36mpkEr6IkncBpRRtXErcnJjbNRWwqvcSoK4a YRPFd1XsAFa46zoD6I2jXpss1OADAEXhNgqpZn3dqego9LkLzkcAexp6GkyMgMZRpCkb4g jJWjhtBNnoO6kXeDbX2Ldl+z4XFJTls= 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=epQKKcaNSs6oc8v4JtInuf1QdvJlAwnRMC1xTjWgeXI=; b=yg5PRqXC80SpIoAHlB81o2BuIzmk+uejuwQLDb2xD9TU/xKj7uCw3rpzFLHbFm67QcSHAq 93Be0I1JgmWfW8Aw== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 4DCB3118DD; 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=epQKKcaNSs6oc8v4JtInuf1QdvJlAwnRMC1xTjWgeXI=; b=WO97LCf9vSIMTWJg/0ZzucZdzc/KUz0BS36mpkEr6IkncBpRRtXErcnJjbNRWwqvcSoK4a YRPFd1XsAFa46zoD6I2jXpss1OADAEXhNgqpZn3dqego9LkLzkcAexp6GkyMgMZRpCkb4g jJWjhtBNnoO6kXeDbX2Ldl+z4XFJTls= 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=epQKKcaNSs6oc8v4JtInuf1QdvJlAwnRMC1xTjWgeXI=; b=yg5PRqXC80SpIoAHlB81o2BuIzmk+uejuwQLDb2xD9TU/xKj7uCw3rpzFLHbFm67QcSHAq 93Be0I1JgmWfW8Aw== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id YM1+EneowGD6XgAALh3uQQ (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 20/34] mm, slub: make locking in deactivate_slab() irq-safe Date: Wed, 9 Jun 2021 13:38:49 +0200 Message-Id: <20210609113903.1421-21-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 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=WO97LCf9; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=yg5PRqXC; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=WO97LCf9; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=yg5PRqXC; spf=pass (imf11.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: rspam03 X-Rspamd-Queue-Id: 09F3C20010A9 X-Stat-Signature: xmaya6uy6w6hey4fdad989fhhjgsfs3w X-HE-Tag: 1623238771-214948 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: dectivate_slab() now no longer touches the kmem_cache_cpu structure, so it will be possible to call it with irqs enabled. Just convert the spin_lock calls to their irq saving/restoring variants to make it irq-safe. Note we now have to use cmpxchg_double_slab() for irq-safe slab_lock(), because in some situations we don't take the list_lock, which would disable irqs. Signed-off-by: Vlastimil Babka --- mm/slub.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 8b0b975bfa36..bba18146def6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2163,6 +2163,7 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, enum slab_modes l = M_NONE, m = M_NONE; void *nextfree, *freelist_iter, *freelist_tail; int tail = DEACTIVATE_TO_HEAD; + unsigned long flags = 0; struct page new; struct page old; @@ -2238,7 +2239,7 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, * that acquire_slab() will see a slab page that * is frozen */ - spin_lock(&n->list_lock); + spin_lock_irqsave(&n->list_lock, flags); } } else { m = M_FULL; @@ -2249,7 +2250,7 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, * slabs from diagnostic functions will not see * any frozen slabs. */ - spin_lock(&n->list_lock); + spin_lock_irqsave(&n->list_lock, flags); } } @@ -2266,14 +2267,14 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, } l = m; - if (!__cmpxchg_double_slab(s, page, + if (!cmpxchg_double_slab(s, page, old.freelist, old.counters, new.freelist, new.counters, "unfreezing slab")) goto redo; if (lock) - spin_unlock(&n->list_lock); + spin_unlock_irqrestore(&n->list_lock, flags); if (m == M_PARTIAL) stat(s, tail);