Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2383610ybi; Sun, 9 Jun 2019 10:22:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTCYzq41KiQ0p04iUT1TotXKCtuawgX+awqQtz5rbeAT+gU1T6bC0k4u1ir1DJVA+zhQ5Z X-Received: by 2002:a62:5e06:: with SMTP id s6mr72206231pfb.193.1560100925535; Sun, 09 Jun 2019 10:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560100925; cv=none; d=google.com; s=arc-20160816; b=XbgHTVR9UdM11oVAYi7ZXofqBniWsIS/Qa5/G37qij30L8uLNV2xE50XiF2ylHfCh2 KkDre8oCtMQ6bz8bJxGYd07brdrP8iKftkKv880xvjOHrpHqQSNlzEPVCG5WGPGkpe29 7VGz4/xHKiGGlBvOeJSnDwQ0tE8T+jHZHwjySlwJCtWDfag9JhHTEaQtV2Q0Hqw2sZhq h7ExlL1dANbls0RQ2GjzW2oYLgDBHYXoNMuhzthaF1Xs+dvJj0jKB5kENMnhwjzPzw0T r4vYH4OPogc6dmOgncb3xYukCvns01m4HnVWajzmawiWRsJa2g8Y+ZyuvRHB34FpBNxD TOew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9y7RHWlSx8bIjI6B71bq+9iaajlXJRq3Tf3VtrXbkwI=; b=gWur1QXeJTKuczsDMZ4cnXFR8evjj4tJlr6G2OjySQgPaEJLUjTPE3AR8CQtpB/JjT TahuyEXztsgxxxumJD0/JMY5hREeqK6qURb6yz3KpjLKLeQwjojhldHhG5EXbwbwYOiR djuZ9umOIu1pxCYBhYxvB4xB+kdAbh50p52LcaDG2TuyNd7nm2h8UKI/h7bzhJldVfv1 /bbfWzguNBy1Y//bvATpDwNxrdGrwzB+J8oybIyWj50UKy7R7nFRQiDoIM6Rv02Cfg4h tzzh7NFh/yI/sM+DH2T8Ghg4Zo7RkpdngT9xd0f+6yDqmtVA8M9u4i7U+4s37xtkFcuD GEhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Uu9K6O7K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si7888619pgk.423.2019.06.09.10.21.49; Sun, 09 Jun 2019 10:22:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Uu9K6O7K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731012AbfFIQrv (ORCPT + 99 others); Sun, 9 Jun 2019 12:47:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:46588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730968AbfFIQrr (ORCPT ); Sun, 9 Jun 2019 12:47:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B25EC206C3; Sun, 9 Jun 2019 16:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560098867; bh=fwsJwNFaon2R+lR5nFdFKSyG4R4Y2sVc0fxcUZG60+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uu9K6O7KArsoWMx/COkDeWFOEGmOfZma4SMP50njvvzSCZs98pSBJbF2KZgw+CJWw amOjrvrlLFlU7wvbHX9Y6XRfrz+vniH88xC5VlG8XCk7DY8oM4paqPTRy871tFmfjp Tcmdq0lzmGxQSTaVaW/qq5KUzKZq6XbhtN/kWYOE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , stable@kernel.org, Boqun Feng , "Paul E. McKenney" , Linus Torvalds Subject: [PATCH 4.19 18/51] rcu: locking and unlocking need to always be at least barriers Date: Sun, 9 Jun 2019 18:41:59 +0200 Message-Id: <20190609164128.133131668@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164127.123076536@linuxfoundation.org> References: <20190609164127.123076536@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Torvalds commit 66be4e66a7f422128748e3c3ef6ee72b20a6197b upstream. Herbert Xu pointed out that commit bb73c52bad36 ("rcu: Don't disable preemption for Tiny and Tree RCU readers") was incorrect in making the preempt_disable/enable() be conditional on CONFIG_PREEMPT_COUNT. If CONFIG_PREEMPT_COUNT isn't enabled, the preemption enable/disable is a no-op, but still is a compiler barrier. And RCU locking still _needs_ that compiler barrier. It is simply fundamentally not true that RCU locking would be a complete no-op: we still need to guarantee (for example) that things that can trap and cause preemption cannot migrate into the RCU locked region. The way we do that is by making it a barrier. See for example commit 386afc91144b ("spinlocks and preemption points need to be at least compiler barriers") from back in 2013 that had similar issues with spinlocks that become no-ops on UP: they must still constrain the compiler from moving other operations into the critical region. Now, it is true that a lot of RCU operations already use READ_ONCE() and WRITE_ONCE() (which in practice likely would never be re-ordered wrt anything remotely interesting), but it is also true that that is not globally the case, and that it's not even necessarily always possible (ie bitfields etc). Reported-by: Herbert Xu Fixes: bb73c52bad36 ("rcu: Don't disable preemption for Tiny and Tree RCU readers") Cc: stable@kernel.org Cc: Boqun Feng Cc: Paul E. McKenney Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- include/linux/rcupdate.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -78,14 +78,12 @@ void synchronize_rcu(void); static inline void __rcu_read_lock(void) { - if (IS_ENABLED(CONFIG_PREEMPT_COUNT)) - preempt_disable(); + preempt_disable(); } static inline void __rcu_read_unlock(void) { - if (IS_ENABLED(CONFIG_PREEMPT_COUNT)) - preempt_enable(); + preempt_enable(); } static inline void synchronize_rcu(void)