Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp313456pxx; Wed, 28 Oct 2020 05:42:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw0HO7YiSCb1gM/GSQstNCJl4My5N05Hq1LlkqLsWtHbUlZpxkAYM1BCcDeDe2vW+TV7+2 X-Received: by 2002:a05:6402:396:: with SMTP id o22mr7451298edv.361.1603888948633; Wed, 28 Oct 2020 05:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603888948; cv=none; d=google.com; s=arc-20160816; b=OB1Nhvm0TWANIIoNMAHDQxA4ArkdcLr7L1j4DiQcW2mXcGbzw/WI/jFL3stkcP/MuI UTLWSBR+q/B8LvV6xQEayUoHD8HnBSCoZEiOipxU8BNUUSq4XTBDHmKKzq/SYxVT7yVy kvefk2S2onDNtUp1OSr8H8t+U7Ufyg0HM9skgAXDlYFFcMbgtggKZhwEVWXu/1iQq/wK i0qU6Z3PpvbtldR3sIGQmd7dVw5eOyOjQUbzuH2fNuxHSBf96aGmcMZRbFzOt/sScqHH FH4AJ+1aASEvzKhhBwvfmQJ4lM8LeVrkWIK6Ihuiw1scwDRMa5gHPCxs+NvoXshUOr3f jMHA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F0Y4u2bdUU3kW+EelwssrOwUs9+AkPw9+ehhOGE+u8o=; b=c4wZgInNSvBtnRhn7ooU2NTpwjo+lQPiMnRMr/mgUtqmNdLAk/m9A7fghfyQp9aax0 Jz2wMi+olTaqL1obIfZJkP0zTT8Y1SqOuc6ydU1zJFZ33MXC5c6Z3MctjUAj86ovl/7F 0TgoF6PSA8BMace8cRVmNWv1pmgZ6cZ+tOA9JKSPPZHidiIHhNlacRt+zbGXas1kL3p0 uaMjLoxgW07CywGNEAjtmi6h8h9R6qeMCSWjTxuOd+GiH0PiSuE9IALER3fyiQqh+NQM DM4v49vr4E6ZUjd+rEGOflVI3cciEWhijj999ZsPRs446OsVx7rNECz/K8+LEgLn5/XS DFnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GvZwLhyE; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si3402013edu.343.2020.10.28.05.42.05; Wed, 28 Oct 2020 05:42: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=@kernel.org header.s=default header.b=GvZwLhyE; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759161AbgJ0PYZ (ORCPT + 99 others); Tue, 27 Oct 2020 11:24:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:37674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1797302AbgJ0PWr (ORCPT ); Tue, 27 Oct 2020 11:22:47 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2916C2076D; Tue, 27 Oct 2020 15:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812166; bh=fKvzga+9w0+RzEiih/miXAu8KUpWpFxvN+mox+OFqmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GvZwLhyEqwOuVrrZtPbJP0VzYUThfiFiXJsi3X4UJTDQFL2iSsMajdCUEcemRr+NO 3zTINzZWHL6idUGaRnN8lPQUYrQb8TDToJ6yIeMyZDrTESnhaPc1Zky3JQq34kq4RV 9H0ZEkRj66Z2tc/DDZFSTySxgxqg5W6bpMbWkHEY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Ingo Molnar , Sasha Levin Subject: [PATCH 5.9 116/757] lockdep: Revert "lockdep: Use raw_cpu_*() for per-cpu variables" Date: Tue, 27 Oct 2020 14:46:06 +0100 Message-Id: <20201027135456.010560721@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit baffd723e44dc3d7f84f0b8f1fe1ece00ddd2710 ] The thinking in commit: fddf9055a60d ("lockdep: Use raw_cpu_*() for per-cpu variables") is flawed. While it is true that when we're migratable both CPUs will have a 0 value, it doesn't hold that when we do get migrated in the middle of a raw_cpu_op(), the old CPU will still have 0 by the time we get around to reading it on the new CPU. Luckily, the reason for that commit (s390 using preempt_disable() instead of preempt_disable_notrace() in their percpu code), has since been fixed by commit: 1196f12a2c96 ("s390: don't trace preemption in percpu macros") An audit of arch/*/include/asm/percpu*.h shows there are no other architectures affected by this particular issue. Fixes: fddf9055a60d ("lockdep: Use raw_cpu_*() for per-cpu variables") Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lkml.kernel.org/r/20201005095958.GJ2651@hirez.programming.kicks-ass.net Signed-off-by: Sasha Levin --- include/linux/lockdep.h | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index b1227be47496c..1130f271de669 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -512,19 +512,19 @@ static inline void print_irqtrace_events(struct task_struct *curr) #define lock_map_release(l) lock_release(l, _THIS_IP_) #ifdef CONFIG_PROVE_LOCKING -# define might_lock(lock) \ +# define might_lock(lock) \ do { \ typecheck(struct lockdep_map *, &(lock)->dep_map); \ lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_); \ lock_release(&(lock)->dep_map, _THIS_IP_); \ } while (0) -# define might_lock_read(lock) \ +# define might_lock_read(lock) \ do { \ typecheck(struct lockdep_map *, &(lock)->dep_map); \ lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_); \ lock_release(&(lock)->dep_map, _THIS_IP_); \ } while (0) -# define might_lock_nested(lock, subclass) \ +# define might_lock_nested(lock, subclass) \ do { \ typecheck(struct lockdep_map *, &(lock)->dep_map); \ lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL, \ @@ -536,29 +536,21 @@ DECLARE_PER_CPU(int, hardirqs_enabled); DECLARE_PER_CPU(int, hardirq_context); DECLARE_PER_CPU(unsigned int, lockdep_recursion); -/* - * The below lockdep_assert_*() macros use raw_cpu_read() to access the above - * per-cpu variables. This is required because this_cpu_read() will potentially - * call into preempt/irq-disable and that obviously isn't right. This is also - * correct because when IRQs are enabled, it doesn't matter if we accidentally - * read the value from our previous CPU. - */ - -#define __lockdep_enabled (debug_locks && !raw_cpu_read(lockdep_recursion)) +#define __lockdep_enabled (debug_locks && !this_cpu_read(lockdep_recursion)) #define lockdep_assert_irqs_enabled() \ do { \ - WARN_ON_ONCE(__lockdep_enabled && !raw_cpu_read(hardirqs_enabled)); \ + WARN_ON_ONCE(__lockdep_enabled && !this_cpu_read(hardirqs_enabled)); \ } while (0) #define lockdep_assert_irqs_disabled() \ do { \ - WARN_ON_ONCE(__lockdep_enabled && raw_cpu_read(hardirqs_enabled)); \ + WARN_ON_ONCE(__lockdep_enabled && this_cpu_read(hardirqs_enabled)); \ } while (0) #define lockdep_assert_in_irq() \ do { \ - WARN_ON_ONCE(__lockdep_enabled && !raw_cpu_read(hardirq_context)); \ + WARN_ON_ONCE(__lockdep_enabled && !this_cpu_read(hardirq_context)); \ } while (0) #define lockdep_assert_preemption_enabled() \ @@ -566,7 +558,7 @@ do { \ WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT) && \ __lockdep_enabled && \ (preempt_count() != 0 || \ - !raw_cpu_read(hardirqs_enabled))); \ + !this_cpu_read(hardirqs_enabled))); \ } while (0) #define lockdep_assert_preemption_disabled() \ @@ -574,7 +566,7 @@ do { \ WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT) && \ __lockdep_enabled && \ (preempt_count() == 0 && \ - raw_cpu_read(hardirqs_enabled))); \ + this_cpu_read(hardirqs_enabled))); \ } while (0) #else -- 2.25.1