Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2414155ybi; Sun, 9 Jun 2019 11:09:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6bjP4fzvukf682pcRxb/mBDY/WumuJWlTD6c4HqG2G5gGSVLDnOFs3ik2lncF1UgaHTLl X-Received: by 2002:a17:90a:a785:: with SMTP id f5mr17167974pjq.4.1560103793953; Sun, 09 Jun 2019 11:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560103793; cv=none; d=google.com; s=arc-20160816; b=G+T18te++TEEcyVIX06nRbST6SQbNZmH3FPYLyCFfw3KXwDDcA5WXwuIfqdzNdZN0Z WJyqFzhG7owo1EnL3QWbE8UunuRziflAfOQCV/hDUr1g7WlkyikJPwZaaEDLbOAb+GRE Z9E5cpHN8+QN6Otfwyx5C/hFbbIfxxWLUBgsqQx0hJQTep6uiRA6qcETjBvJ80Eg+Hvr UAITGqUlVVRjWrlPeqS9LNUqPC3NHfqg/lGKWy5nFfKgwCwKij8y0ygps1cODPVbHdRd gQaLWB4c4rYDDF0ATOQH2Zq5pz0oRxX+DgO5/UeHuWrPdAX2ZtffVLY6x7JRBRkZAFca /Bbg== 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=rHYGalA8R1GQHJrNFDFTHFQiOEz30Ucoh7ou8Gf5PX0=; b=J3NrZPGmxhrRvY8pE3o3AWNUPHqpSPEmLW27s7DLUFZj8J62QqQBl1c1iyaBOJilnD XDSFFHJGaOY+KBNS3Zt9WXMDtiEkD0j33Z3elGSgHrKXxHsFJXvxc0rQnLjjqnsq9cpL VOZCysFbsUIsV6uHXmBECETwtyiGst3SmIvfQXq9eoDSwhEOCqZh3l52V1td/IqPUejs lf2aNPh+pDm0YTjJSbsC/cdszEsaxuIi50J1fG4EMLPO4jzuR+uIffxDOe2zrMfZlR1o nV+/G7F2esqlTfu/EmOI8wTamS/hGj9GlsAOhgJSUiVcZ33O0vpRxuwdp+BHvn4CzCa+ hZ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TDvrbqcJ; 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 v4si7319774pgr.475.2019.06.09.11.09.38; Sun, 09 Jun 2019 11:09:53 -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=TDvrbqcJ; 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 S1731980AbfFIQye (ORCPT + 99 others); Sun, 9 Jun 2019 12:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:56208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732219AbfFIQyb (ORCPT ); Sun, 9 Jun 2019 12:54:31 -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 6FAB4204EC; Sun, 9 Jun 2019 16:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099270; bh=BlA6BIO6kERajv4RZYy7/31RqTOwWAKUBuSWOeKpDHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TDvrbqcJRe7FggNPftECYXRUGfgKpcQ+Zt/P+n71O4kAjn4xUNX+qb/5j/pJadosq LdnBZjGA1yim2o37Ev/Bh9pHcIlKMtophqN+CHxHWb4u8LEgh6DYWv+Agf/NnZjVYT lCS6f9DpBjNuGufX4JcXemLKrTDPyWVQg04TH5Lo= 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.9 71/83] rcu: locking and unlocking need to always be at least barriers Date: Sun, 9 Jun 2019 18:42:41 +0200 Message-Id: <20190609164133.888030297@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164127.843327870@linuxfoundation.org> References: <20190609164127.843327870@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 @@ -306,14 +306,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)