Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6095771pxv; Thu, 29 Jul 2021 06:26:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0WG9DycuGuUScNQWc3ZYZlkBEx1mFQV9TqDfDINYfwjfQhSnEUfj6NyywQ3ytBTsqiwSH X-Received: by 2002:a6b:8d0d:: with SMTP id p13mr4208968iod.8.1627565188607; Thu, 29 Jul 2021 06:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565188; cv=none; d=google.com; s=arc-20160816; b=TaF5qzwuwlfRGdtkTLwu1Vbuk63D2ydg1HuD4BLhJtgF5jjvSi7N0HOdu/IzkkRdZ1 Aenw2MbbMGlqjSmQGsea6d33o9cawvgzyFNlgFnwlNR6tBFvKVJ2YLK0hOB5YjaR9G6V Zr8Vn6ZQuvWKPLhm30qzIerQogUpQ14VZZvtiOvGwKA7YWEi3ARm1Kd6LuDaSqGJirhs CGM8YAPvGhuAwTLtMYBC9KUdq/2gNmqSLkY541Ld1FtvbVCYGWkGQZnBLUW1zGQZpwWv qU6NiDEz6UZBjo7T0/gV1YjROkHX5jaRWHd2gkgfizr2HysYj5Lkfx6PZ58CEiE3z17x URjg== 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=HSv63Kvkq+thDPLg/+1UDTLdchm7lgBN3x3SqO16PAI=; b=0LZejdyjsARInZCMmPsrikcns0HTA5fmF/VRqxQC7NPCy7imtHO/LvC9CiSNreEPmH uXLaKqoEY9GEnjcE2civeVamGlVK6gOnux/nGqVgpLFH74/9hewg5HKJgscOYdsUIyHG Z2aCCGF2aWyoiHHWZ0w8CcCNEsa09HIU9Jkka4KvTQvoA7T679/jRcwxZI7U6EDLs8c+ UlwAZRNtH15rBalAj4e3CRgI/wyegE4qt/4VKT3Pv5wYPMeLmDHdi6zhmxBYCUtsH13g CuX5EpJiJ0sEPssiiH7gR1IEL/oBxlFoEMkqhU1RgMrq8NlshNv1h7ipOb1McKK7zWYd IzxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=07f0XaHk; dkim=neutral (no key) header.i=@suse.cz header.b=+XxFY4lJ; 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 o19si3027319jav.61.2021.07.29.06.26.17; Thu, 29 Jul 2021 06:26:28 -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=07f0XaHk; dkim=neutral (no key) header.i=@suse.cz header.b=+XxFY4lJ; 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 S237849AbhG2NX5 (ORCPT + 99 others); Thu, 29 Jul 2021 09:23:57 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:38376 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237559AbhG2NVu (ORCPT ); Thu, 29 Jul 2021 09:21:50 -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 9415C223E5; Thu, 29 Jul 2021 13:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627564906; 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=HSv63Kvkq+thDPLg/+1UDTLdchm7lgBN3x3SqO16PAI=; b=07f0XaHks/yCLt+dQb1Tu5w39pt0w9QzHBf9hycwNRwHB9ZQAcrLlPsUx4e+sFSV81Rvrx kdEA95o6crHTI5gUQ9evAtWBjHz+gHs9fgMWMKn5VoN4bUiLoRzBVZQ41qn6KJIVqf6taK /Rmn1x0FKGwRCh40j7y3Ge+DT+TAObw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627564906; 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=HSv63Kvkq+thDPLg/+1UDTLdchm7lgBN3x3SqO16PAI=; b=+XxFY4lJFWkQXnQYo3Y8QXCrsltZRhEIfyOPyqEpvhTPXSacvVsNXJ1UvSp1kXc0eK2yEn rame/Ig7Z9RxCDCg== 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 6463413AF4; Thu, 29 Jul 2021 13:21:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8MDwF2qrAmF9AwAAMHmgww (envelope-from ); Thu, 29 Jul 2021 13:21:46 +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 32/35] mm, slub: make slab_lock() disable irqs with PREEMPT_RT Date: Thu, 29 Jul 2021 15:21:29 +0200 Message-Id: <20210729132132.19691-33-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 We need to disable irqs around slab_lock() (a bit spinlock) to make it irq-safe. The calls to slab_lock() are nested under spin_lock_irqsave() which doesn't disable irqs on PREEMPT_RT, so add explicit disabling with PREEMPT_RT. We also distinguish cmpxchg_double_slab() where we do the disabling explicitly and __cmpxchg_double_slab() for contexts with already disabled irqs. However these context are also typically spin_lock_irqsave() thus insufficient on PREEMPT_RT. Thus, change __cmpxchg_double_slab() to be same as cmpxchg_double_slab() on PREEMPT_RT. Signed-off-by: Vlastimil Babka --- mm/slub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 2496e0add6f2..4f7218797603 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -380,12 +380,12 @@ __slab_unlock(struct page *page, unsigned long *flags, bool disable_irqs) static __always_inline void slab_lock(struct page *page, unsigned long *flags) { - __slab_lock(page, flags, false); + __slab_lock(page, flags, IS_ENABLED(CONFIG_PREEMPT_RT)); } static __always_inline void slab_unlock(struct page *page, unsigned long *flags) { - __slab_unlock(page, flags, false); + __slab_unlock(page, flags, IS_ENABLED(CONFIG_PREEMPT_RT)); } static inline bool ___cmpxchg_double_slab(struct kmem_cache *s, struct page *page, @@ -428,14 +428,19 @@ static inline bool ___cmpxchg_double_slab(struct kmem_cache *s, struct page *pag return false; } -/* Interrupts must be disabled (for the fallback code to work right) */ +/* + * Interrupts must be disabled (for the fallback code to work right), typically + * by an _irqsave() lock variant. Except on PREEMPT_RT where locks are different + * so we disable interrupts explicitly here. + */ static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct page *page, void *freelist_old, unsigned long counters_old, void *freelist_new, unsigned long counters_new, const char *n) { return ___cmpxchg_double_slab(s, page, freelist_old, counters_old, - freelist_new, counters_new, n, false); + freelist_new, counters_new, n, + IS_ENABLED(CONFIG_PREEMPT_RT)); } static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct page *page, -- 2.32.0