Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1221384pxb; Sat, 4 Sep 2021 03:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTCbcDOSMlEMHnFLE5Cc60tYZrZaxC3+NIzGc0ovi5dpFm98YPD3FFDjGIgQDDuN2YObiE X-Received: by 2002:a05:6e02:1bc8:: with SMTP id x8mr2346922ilv.138.1630752779276; Sat, 04 Sep 2021 03:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630752779; cv=none; d=google.com; s=arc-20160816; b=m72V36CpJIMxtxPNd3tJ8olF4bDQzLSjT5RbboXaQmSikQbRQoVgpg5/k6nX8kWEtj cWm5g5fIV3mxrnS12/4PFlJ+N/eMpt/ozuqAlm1tcdIu7z1YzYyPm2WHAOgk6ykw7r7t pYTgE+DsRNBZp9NO0E7+gBpSWYexIlnLtQAbmitstgY6f6lZ2wj+eJqZSzgkqi4UZax6 NwToc4q7+pYedRzZk2obAswRsOcQNwYYExE3vrWDqYaNiu7pggcTGUf5NnGgcULYLRvC 3GuLvkcxFBgERU8QFioDghPzFTBF0v96dSHOW35fNb4Bzv0ceoVPxSk6MZO5Tnazs4G8 SMpQ== 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=G6OGrx6GIz3up+TR10DXhEX3qqgzgoncBND4dqx46JQ=; b=AF5QVGLpAgm9UQuKkEH3nOcdDCW5ve9hJJrI4NVKfua6nVdXlMIaRKsjsHELb0FrsM B0JTOlSePSKTRoCqsbAsw64SFISIwJMS85abLv6JBlyzMUzZ3Z9booHeIE/DbshiCRG4 CLpJPcNLYUNm2H2nY1ANAdGy20z5oHDjMAOJoGeO3N5QmZjB7n4FLFshLfEQowSVZsQR mLgNukKACRn6ySzfD7bKpNH1uJwoiKUvtrwJmGdwd8sVFKp3laDRwZ02kY6bnsTeujTI OncoGaH6gZz744lKeiWLinvQNkQQNBXTmqRPnAFrwn6USN5Rf9rEN6CI0DMmKHgnnjNA h5fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="R/1YG4px"; 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 r141si1822983jar.111.2021.09.04.03.52.47; Sat, 04 Sep 2021 03:52:59 -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="R/1YG4px"; 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 S1351268AbhIDKwi (ORCPT + 99 others); Sat, 4 Sep 2021 06:52:38 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:59716 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351119AbhIDKvO (ORCPT ); Sat, 4 Sep 2021 06:51:14 -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 BA7FF2269C; Sat, 4 Sep 2021 10:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1630752612; 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=G6OGrx6GIz3up+TR10DXhEX3qqgzgoncBND4dqx46JQ=; b=R/1YG4pxxmCF+V/yfa7WCiwFyBQo20Ny9YGDYZV8bneQn/MKwawoZwwVLwS3yHIpfvx72N 6vxrODBuyOVufeH/DcY9o9rN7s6QocULpCIdjOQ3/xWsmGNxsmfrdx0u2TmAvl8inWkzM3 t0HZZoAPL1zbIUH3BR9GySFgS2q9B4M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1630752612; 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=G6OGrx6GIz3up+TR10DXhEX3qqgzgoncBND4dqx46JQ=; b=/oDDZiF/f3RFroQeUBWyVfA2caJT7sYiXKxby/oVyDWYKFKKmWxbqaNRTD67QYNm340GCJ eEPmMS3xKcRpPfBw== 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 9346A13A2C; Sat, 4 Sep 2021 10:50:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kLZZI2RPM2HoUQAAMHmgww (envelope-from ); Sat, 04 Sep 2021 10:50:12 +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 19/33] mm, slub: make locking in deactivate_slab() irq-safe Date: Sat, 4 Sep 2021 12:49:49 +0200 Message-Id: <20210904105003.11688-20-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=1920; h=from:subject; bh=YzKb788v9/Uv70MA4Rhg3F13MEdyRR1sJKH4wo5Ptcg=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhM082Dw6UQkycba/shrCzbIHxh8w0nLMMX1KTqEQs ZLqhCvmJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYTNPNgAKCRDgIcpz8YmpEHtQB/ 9AilOZPBvAD9Ga6igYJHS3ePasiFqZE7IxQ5jt1aQ1KJZg/RLYIyAohaFk3aNzV5vAk5252TqW4FiP QDOUE0fspWrTpM2tdMkK6gpbCaMbHJnj4mgeSnguneIL/JUTk6cdMCdPSYp7Z3RvdD9Wu5waA8pdYs cjE7r9Ugyqe9XgVn8JdAVgOZtVnnu0QRSr1EEY9uX4dg7x+r6iwXX7ScU+8XTKbDU2+ieZbv2kp419 AzCGmTNLRh7Rqvkv+JQ74HhCfP80O+vID9xABa4MOfFz5RZCGRfWI7ZK98yHy9BWAwsbFXMnRg3dii 5YjPSB3PnLYDtEDLnlnfMPs3TXaLHq 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 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 cea7a2ad9e3e..6deb4080ef54 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2223,6 +2223,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; @@ -2298,7 +2299,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; @@ -2309,7 +2310,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); } } @@ -2326,14 +2327,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.33.0