Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3846632pxj; Mon, 24 May 2021 16:44:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCgPCz+LbGp/5Xuj8W2jr5LALDXFE9FwAcoZcaCkWTAgGnSZ6EbtVol40gKwMPLhdWGRka X-Received: by 2002:a17:906:b74f:: with SMTP id fx15mr25928448ejb.85.1621899849022; Mon, 24 May 2021 16:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899849; cv=none; d=google.com; s=arc-20160816; b=aFNR5MjzgL6GIrke+NE1PCWzqdgKACo6ivm127bec48f4sDw1bCNNJNGYPByWt6kWr sMg9A4cz3Tz4u8LYjfjmhA+GtQ+Ox7qWndo6cU9x0sWIMIqSJXre7ZROQ81ryFupRnUh w+ilntzvTn9txYJm/PwhyMasBEBgxYmetoGNQ6/iw+oS+XFpr6enbp5zj6Zg2vmgkWtG Y6mUZzvj7G9AK1OP7iHHtUIkPEDVHxG5oULw7lERS4UaELOPEoI5qDetOUT7KrrcYd1K JGWj8YR/l6tuZNiiKilvFUkDBAVgeCf3buqo5QrPH42hf01qMjBsNWlXJImV0YRVb8Nm 66Rg== 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=x5p0PizEV3N3GiwLue+53YpFP9i8rF0CXirWwfnsCP4=; b=ESmFaVBGcET3OoO9IWT4MNgkMVKuh+AUXvcD7dB/ukQuvCq5Ro727jKhZGYEI83rSD Zs/T6UfZ9mcZcjYIMOZerb68SLMIt18tBF1Sf4bGX6YwqpznqItwDqa9B/JvR0y8ym1b IznFHUy4TjLMHD7B8Dm3s2RnPknl3d0y8caSa6viAehtbxTpYHbHLIfRJeQCNmrHTen4 u5ZqqTgwsYWq37ARBpmw88UldYbaIua+GI0Hk5HL12WzfSCO+i5SAqDMPjoH/IDraNMB GorDUtQno96Uu2FNRrSgX4i0nXEg/9RRKCIpAmHd3eEv4VWLovNfl7Dgqac68JeYIvHV kCpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="DXFOK/s7"; 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 m1si13990031eji.731.2021.05.24.16.43.46; Mon, 24 May 2021 16:44:09 -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="DXFOK/s7"; 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 S230378AbhEXXne (ORCPT + 99 others); Mon, 24 May 2021 19:43:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:50688 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbhEXXmW (ORCPT ); Mon, 24 May 2021 19:42:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1621899648; 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=x5p0PizEV3N3GiwLue+53YpFP9i8rF0CXirWwfnsCP4=; b=DXFOK/s7RsNQOHek7IKrH62rhnjIs5Q0JQVDdO9HiVjkSKvaNFf15g+kVOQ1TFiiCVW4r/ OMA7BorHY+9fpcwHQaI4V8YSsBFCgrmWtoKI86Sd9hRnK8aU5E5gV0Y6crsxNkIdVWW/t1 B56V2enMULhFxr7dGGbuB319smJpw64= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1621899648; 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=x5p0PizEV3N3GiwLue+53YpFP9i8rF0CXirWwfnsCP4=; b=eWIjO2wgep5ZYKjyLU6z8Cx8pWnq/Msaaw8quKQ4oUxAa0hByJjR4PtNC2/3jpcfx1G4oe gPzGGJVEnTqWo8Cw== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BE29FAF39; Mon, 24 May 2021 23:40:48 +0000 (UTC) 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 17/26] mm, slub: make locking in deactivate_slab() irq-safe Date: Tue, 25 May 2021 01:39:37 +0200 Message-Id: <20210524233946.20352-18-vbabka@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524233946.20352-1-vbabka@suse.cz> References: <20210524233946.20352-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. Additionally we now have to use cmpxchg_double_slab() for irq-safe slab_lock(). 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 cf855cd09802..0f58859165bf 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2177,6 +2177,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; @@ -2252,7 +2253,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; @@ -2263,7 +2264,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); } } @@ -2280,14 +2281,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