Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6093962pxv; Thu, 29 Jul 2021 06:24:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZRcP3F+Y1fq7bvDQ4WbPD4ff5PfgbMgVJJ9omg5XhTwfJlz/tKVaCwWj9aoZOlMdPOvz8 X-Received: by 2002:a05:6602:24d8:: with SMTP id h24mr4177580ioe.27.1627565047468; Thu, 29 Jul 2021 06:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565047; cv=none; d=google.com; s=arc-20160816; b=NwhpKUH/xr1S1NE2LgT4AWUo7qZ3wo+kMiC/AwMQD98vFkCaooRR3F2U0Ov+t/vhfl T1XFNcEjeuh9XcDGhhB+kjNRRdmHzSDOLcYXmmnSiFzQcVU0r2w6viO2UcOwxamtIK6P JEk1GJw9EPEEL52uji4jZ72+FVzvXWyIRgwuXh0tK5Ez3NBCIRJN+hR+H+VgNsBH2zJJ ToL9YuBOOGb+9Kv28IuHB054WpXoeE1F3A6GmtFb2YMonyKBB2YaxS0rFeYjCDsIoL7B txl7izkg/gc9QKIGSnNEQ8J/WxtrblJxrKnFlBe8pQ4719oj163Gzs5e/iI/Z3xwpfuj DP2A== 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=4QfpjXG+5kFLZ2p6kNsROLyftr92plvhJpGSjqBIahw=; b=NSDivaRgtCWUL33jCxscN6fvDZKuuGml2CCahM+CWepB+loT5QrgL/thfnJmU7GfbO DEQAwEG8QGTxsJE4NhEFJG5rlqmH6fZiVFuOpNSKu2P3BMUIiP/dpOKqz6Rl00DTC1Xk 3WN2LCxTcGB8kt/hV3nDmp5/KJt1LNP0qXMuEPeZailJpyr9r7mctRdA+eJRMmiX/09y XNNhL6xX5nwShxzjh36w54SRBxnJoUuIcv1sDR5+7NJweSynm4A5R1aausGD3X4BGMAR WmxaQI/vuZ8xASve9NG2zbPm7h3R+w/qsw8FR9TCxeqogkU83fov1nchxamFgXNiVO+R r1pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=XSZtilpC; dkim=neutral (no key) header.i=@suse.cz header.b="ZSA/SiP2"; 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 r23si3520827iot.18.2021.07.29.06.23.56; Thu, 29 Jul 2021 06:24:07 -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=XSZtilpC; dkim=neutral (no key) header.i=@suse.cz header.b="ZSA/SiP2"; 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 S237682AbhG2NWz (ORCPT + 99 others); Thu, 29 Jul 2021 09:22:55 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:56758 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237503AbhG2NVr (ORCPT ); Thu, 29 Jul 2021 09:21:47 -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 2EBF42003F; Thu, 29 Jul 2021 13:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627564904; 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=4QfpjXG+5kFLZ2p6kNsROLyftr92plvhJpGSjqBIahw=; b=XSZtilpC4VaZN+IeIUQJh1QGvvSvPq/5GIxm+f9jYkeaqjyKicPKfjiHkd4EhKYBLE5fKn 9HwTlTytEItWNNWuLzerjhwHSSiEHLwcySf8GKOAVzpqDrgElo9D3AGPjqSMJ0voI8SUyz 0pERUyqNFvtJcKGgasNPm2/oRJjF8rQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627564904; 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=4QfpjXG+5kFLZ2p6kNsROLyftr92plvhJpGSjqBIahw=; b=ZSA/SiP23nyeGMh+2tCaTdazY4fYuvChT1xWR9hhMSbIMpx4Hv3TTsAFksW6K2nuPKQcCu 9/BiplNJ2+M25XAg== 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 F367B13AE9; Thu, 29 Jul 2021 13:21:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ELWqOmerAmF9AwAAMHmgww (envelope-from ); Thu, 29 Jul 2021 13:21:43 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Mike Galbraith , Sebastian Andrzej Siewior , Thomas Gleixner , Mel Gorman , Jesper Dangaard Brouer , Jann Horn , Vlastimil Babka Subject: [PATCH v3 20/35] mm, slub: make locking in deactivate_slab() irq-safe Date: Thu, 29 Jul 2021 15:21:17 +0200 Message-Id: <20210729132132.19691-21-vbabka@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729132132.19691-1-vbabka@suse.cz> References: <20210729132132.19691-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 7a8554eb3d96..3d5a2f9371f8 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