Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5153895pxj; Wed, 9 Jun 2021 10:19:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3trzS/W2dHl+k2OOD5b1mHWJuFXj3UMJHeQdrkJfCzpRHgVXncsqc4Hi0xJeQFoqEDCZx X-Received: by 2002:a05:6402:1153:: with SMTP id g19mr480210edw.179.1623259195819; Wed, 09 Jun 2021 10:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623259195; cv=none; d=google.com; s=arc-20160816; b=0Qi0nWaJ+bZ3dyg2gvSrWDB332uO6b/r6xDZDd4vm3oLszwwptEpyKJ55v8M5kPxjm JJzFX1LvPai57zHJSnA3nALnnJCay/bZWG5VMcpBFIycmaSbOBihOBbxPma4MXkGlD/H QWvaN4IHrLFH0vv2ZXWLqM3FCQhW337ylgd2qhP19TbN3RGA14P3aGP6jnD1+ey0JKDn ltAN34ER8F3hmBTKRw3X2FnM6QoVQlYyNuXrzGRiUagqJAtMDeUeLPGxhLO6yPmBfvMZ YCHQA4bsh37oN9dOKXJL1sQP4PP82ia9lwNz5/T5jfVhdUt55qnzkfG7YRkCMlvhhtwj dCgA== 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=epQKKcaNSs6oc8v4JtInuf1QdvJlAwnRMC1xTjWgeXI=; b=hhqaZ5QGt9swMiVuutYmgRLzcl3ySaIoLsW5kiq1BTexH6XEl683M+mp4j2kC97rwo Wr/7ni+D5l2cTfEhVXCNTrAKIJEFSfXneX75QagMN48w1YVvzmqUzseNHF7spteO3xd3 I4FPcD2qB/rz3+h+J/8Afk/3mqTaKw97TvpucAvSdnheoOQQy2R0ULDIss/7KWZzjwC9 IqHqsXrn+ixPrLbgAr6KDgJllw3zap91IPtZfPGBA2K4TRQuT6ECM43t9LiXKuA6YRh0 O52BW+uTVN+nNKMuSk5dzFiqYSgI38SCUtIhY3peff7esW170f/uusnxM7E+VMNPDSqK 9cww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=WO97LCf9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=yg5PRqXC; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=WO97LCf9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=yg5PRqXC; 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 v7si251928edj.328.2021.06.09.10.19.30; Wed, 09 Jun 2021 10:19:55 -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=WO97LCf9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=yg5PRqXC; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=WO97LCf9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=yg5PRqXC; 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 S239322AbhFILmW (ORCPT + 99 others); Wed, 9 Jun 2021 07:42:22 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:54686 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239158AbhFILla (ORCPT ); Wed, 9 Jun 2021 07:41:30 -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 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.31.1