Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp651780pxt; Thu, 5 Aug 2021 08:26:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqwH+kAdKm2OiIMGDO/BIqHqiqMW9tS4o9Rr6kdKEX7eYSsnyA4JySNhUUUV8Vw/+yY0Ac X-Received: by 2002:a17:906:2dc5:: with SMTP id h5mr5567778eji.515.1628177214372; Thu, 05 Aug 2021 08:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628177214; cv=none; d=google.com; s=arc-20160816; b=zLvwB14vAo5ganKl1WCPG+MBrQ8dVKcxnXcQnt2Kh+Yx5sgzroGel8+S1vw2kzMLo8 uijhM8shV9ZwvIW+LUVE2kGrpl2y6xOKO8dWmBLYIlFvUCvK4BlMcTnQKJm1QcAJisSm 4IcjthXcRoWqqhCJ4vmUIJqhnVQJ5nQUfYSMMQG6hZ0ZE1+U1hds3ofMY2YsW3+6VMfS Wfmx9Kv9xqnHP4Y/+bSLSnzVCUHF0daHpOfc5MrMuVayRsa4j1QGDV85MpjwY/OUev7p wLfH07KJHz2Po3NdH5Fbj5dl/L1aiUHzr/ivrwYVHWKz6KuGualYNRo0w40DvRTQevJM z/Rw== 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=lMyiUcMeRm7iY2iUQEbPAU5I97AyoBy8iiWsBpoSEG4=; b=i/6ooK70y4ac6PCLaXnC7SN7ftZTgZpi/uHDVW1AVAtueSfgEujLUWGjbU1sDUKLV+ YvMt4NvgUUpYMfcA9q+x1/qHmrfE0xfaEXMzoQetopAmmpDvs0Ku+DpTPSwRdtPQMBL9 GksQ53wuJrJEnoE3gAZkLO0igDYUuWzIm21E2tWSNX3dXkptkglivDRm9EMrwd+1RD1Y Cvt7dtnfPHu2Ru79Wir+8WvoVAbr0ON1QGVqxXMTuP1ZMBPHDbuOHYzkfofUHftrT7HB PLjLPWQ4AOn85zbMYHfDJv5E/QiO26R7OnqlmPkP0FD6ST9Au+xRRbTfUbYBk3YI5j6V Y4MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=DrnvdR6l; 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 11si5660810ejv.229.2021.08.05.08.26.31; Thu, 05 Aug 2021 08:26:54 -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=DrnvdR6l; 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 S242131AbhHEPZG (ORCPT + 99 others); Thu, 5 Aug 2021 11:25:06 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:59360 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241974AbhHEPUX (ORCPT ); Thu, 5 Aug 2021 11:20:23 -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-out2.suse.de (Postfix) with ESMTPS id E4E4E20250; Thu, 5 Aug 2021 15:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628176807; 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=lMyiUcMeRm7iY2iUQEbPAU5I97AyoBy8iiWsBpoSEG4=; b=DrnvdR6lj3EYS8tg9TWnDCZv/PHO4pdqbW20pWPm43qivJ56KdbmujdsrB6JEJn77k/X7d q20SNKe6DFvUh3oKmON2Xek1Pr6hgBuAwHwX/aRh+ZmH3jHY1bB7zpdmcmyF14SqF6ZhED z6WSHbBorg7ibEvmwpORGj38lzjzEBc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628176807; 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=lMyiUcMeRm7iY2iUQEbPAU5I97AyoBy8iiWsBpoSEG4=; b=fuJ797Ro0zOfEInjMPAMN3/0vSEOLaOf1ELY6gxHHDvqoc7ORX8sFD/vYJBsnBuYdema6C mHyWqunuekO2ZOCQ== 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 B801413DA8; Thu, 5 Aug 2021 15:20:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SDFQLKcBDGFDdQAAMHmgww (envelope-from ); Thu, 05 Aug 2021 15:20:07 +0000 From: Vlastimil Babka To: Andrew Morton , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v4 20/35] mm, slub: make locking in deactivate_slab() irq-safe Date: Thu, 5 Aug 2021 17:19:45 +0200 Message-Id: <20210805152000.12817-21-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805152000.12817-1-vbabka@suse.cz> References: <20210805152000.12817-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 10fd2eaf8125..27c98f4fb3f5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2206,6 +2206,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; @@ -2281,7 +2282,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; @@ -2292,7 +2293,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); } } @@ -2309,14 +2310,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.32.0