From mboxrd@z Thu Jan 1 00:00:00 1970 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,URIBL_BLOCKED,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 8C843C4338F for ; Thu, 29 Jul 2021 13:22:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3FCD360EBC for ; Thu, 29 Jul 2021 13:22:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3FCD360EBC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E90ED90000C; Thu, 29 Jul 2021 09:21:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1F84900009; Thu, 29 Jul 2021 09:21:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1ACC790000A; Thu, 29 Jul 2021 09:21:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id C95F6900009 for ; Thu, 29 Jul 2021 09:21:45 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7BBE318432CD7 for ; Thu, 29 Jul 2021 13:21:45 +0000 (UTC) X-FDA: 78415687770.10.E062FAD Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf03.hostedemail.com (Postfix) with ESMTP id 26130300009B for ; Thu, 29 Jul 2021 13:21:45 +0000 (UTC) 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 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 26130300009B Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=XSZtilpC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="ZSA/SiP2"; dmarc=none; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: h8djfpn4e1icn43qyh9wba6hwdbqjjcm X-HE-Tag: 1627564905-644504 Content-Transfer-Encoding: quoted-printable 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 i= t will be possible to call it with irqs enabled. Just convert the spin_lock call= s 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(), b= ecause 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, s= truct page *page, enum slab_modes l =3D M_NONE, m =3D M_NONE; void *nextfree, *freelist_iter, *freelist_tail; int tail =3D DEACTIVATE_TO_HEAD; + unsigned long flags =3D 0; struct page new; struct page old; =20 @@ -2281,7 +2282,7 @@ static void deactivate_slab(struct kmem_cache *s, s= truct 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 =3D M_FULL; @@ -2292,7 +2293,7 @@ static void deactivate_slab(struct kmem_cache *s, s= truct page *page, * slabs from diagnostic functions will not see * any frozen slabs. */ - spin_lock(&n->list_lock); + spin_lock_irqsave(&n->list_lock, flags); } } =20 @@ -2309,14 +2310,14 @@ static void deactivate_slab(struct kmem_cache *s,= struct page *page, } =20 l =3D 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; =20 if (lock) - spin_unlock(&n->list_lock); + spin_unlock_irqrestore(&n->list_lock, flags); =20 if (m =3D=3D M_PARTIAL) stat(s, tail); --=20 2.32.0