Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp416714ybh; Wed, 15 Jul 2020 05:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9TZSOlmFUClA//yZ+zvejEWVXl67hm+g7z3u6nWQxAJ3n27W2A/FNqz7cg+NiIlbrns9M X-Received: by 2002:a17:906:6558:: with SMTP id u24mr8522960ejn.364.1594816498358; Wed, 15 Jul 2020 05:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594816498; cv=none; d=google.com; s=arc-20160816; b=eVrEr0YTuEr3x8YEHKxicZoFtDumlk+8TG7I40qI93J5GCDsebqm3Z+KdV/MIrxC7g XT3m6lVU3VMJSTfbkmkga9shePcMzwI+XE5My0NxRzT4D+W9NJ3Xc4Y8fAQnFuMPql8/ QgsCm8G0UYdCg41qG0NoQ3OpIkChaprDRhgs9lejPAq9pep+/G5g2JhUF5APSBzc1GE7 H56bYSQQ0PPzVadl5Z8qXKZWY1dl3FHjZf4eI5elXQSx594xwKS26FkEc5IoXra4lzKS XNE29+kwWkWC0qF8ox2x+u72bHD1vfiKTmaoeOO/9Yxy1ea8gJOHVbzn8i/J12I/SOip p+1Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=E/Hw+7u7aBxeaVg0fnGygmITDj3v4tIkOl2+fAUxPTA=; b=SF79p1HL4mOzwa5m8YD8f3sYbWPEBn1BugtlCJyikxaOAreNpspGVFRHCYc65yqmYC vydPUSoBI3NFnBkU/8IrIzA2h4jFTxffR4cLV2Ep1ENdW2u6iPYtm/pN8tlzf3OQYLhf /Rq5Tzj7a9nJ42Xh4ct/QcOjANwBVPiu1fexr9PQl0H4AT31jrqG8UItNDSaP6Uecg8f wXiz/NCcEYnazbFWWgpboT/urxUD7usibOvdp2Y0wzk0rJHTVJz2vsGpbTotbju3KBYT v4i9v4+AZlnwufY1eHao2KEgLbYBMLTowdUJilmz/ai6Mrl8O3oGD06KNIsHGbSbTUk9 3Yzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yPvm7CWt; dkim=neutral (no key) header.i=@linutronix.de header.b=oNrpRIq8; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si1131268edq.493.2020.07.15.05.34.34; Wed, 15 Jul 2020 05:34:58 -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=@linutronix.de header.s=2020 header.b=yPvm7CWt; dkim=neutral (no key) header.i=@linutronix.de header.b=oNrpRIq8; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729348AbgGOL7G (ORCPT + 99 others); Wed, 15 Jul 2020 07:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgGOL7G (ORCPT ); Wed, 15 Jul 2020 07:59:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F35C061755 for ; Wed, 15 Jul 2020 04:59:06 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1594814341; h=from:from:reply-to:subject:subject: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=E/Hw+7u7aBxeaVg0fnGygmITDj3v4tIkOl2+fAUxPTA=; b=yPvm7CWthkRwlgkbg7g+faKOFs7NJk5qxg8qwKA5nL8eKSbGvhGte1Wk7qi7IQL0FSRFYk hIzoPza7nioo4DDk51dvAslE9Jzr2bo8V56WpkGviOaJvGH7tyUF9RPAnkuLcq+BN8W/51 juhHRRzevdx88N+vmlySdiTMSN2TuCIXZNOwezf74nu6T7mVA7Goxa2S8cyQmOD0lvRbqZ czhk3/wxsFBgedPVCwHQgVqVlr/VKNiOitSIAX4Yw7eA7Q7De9CkqtTSq2dhAawVEDYrz8 QJLZWcObt5Y2xkzhtCkEEYq2TitT+AYe+Ra3dZnwQx2AgcJjwtt8pzqz2uQOIA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1594814341; h=from:from:reply-to:subject:subject: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=E/Hw+7u7aBxeaVg0fnGygmITDj3v4tIkOl2+fAUxPTA=; b=oNrpRIq83+0jvmZcDwfQAsaE9OgkuYiwLJQw1Jtukv/q1VpPzrB9AVnPYwXiiCSZdsisJq oyeq+HTEY0CQieCQ== To: Thomas Gleixner , Peter Zijlstra , Leo Yan Cc: Will Deacon , John Ogness , "Sebastian A. Siewior" , LKML , "Ahmed S. Darwish" Subject: [PATCH] time/sched_clock: Use raw_read_seqcount_latch() Date: Wed, 15 Jul 2020 13:59:01 +0200 Message-Id: <20200715115901.515956-1-a.darwish@linutronix.de> In-Reply-To: <20200715095220.GH10769@hirez.programming.kicks-ass.net> References: <20200715095220.GH10769@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sched_clock uses seqcount_t latching to switch between two storage places protected by the sequence counter. This allows it to have interruptible, NMI-safe, seqcount_t write side critical sections. Since 7fc26327b756 ("seqlock: Introduce raw_read_seqcount_latch()"), raw_read_seqcount_latch() became the standardized way for seqcount_t latch read paths. Due to the dependent load, it also has one read memory barrier less than the currently used raw_read_seqcount() API. Use raw_read_seqcount_latch() for the seqcount_t latch read path. Link: https://lkml.kernel.org/r/20200625085745.GD117543@hirez.programming.kicks-ass.net Link: https://lkml.kernel.org/r/20200715092345.GA231464@debian-buster-darwi.lab.linutronix.de References: 1809bfa44e10 ("timers, sched/clock: Avoid deadlock during read from NMI") Signed-off-by: Ahmed S. Darwish --- kernel/time/sched_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index fa3f800d7d76..ea007928d681 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -100,7 +100,7 @@ unsigned long long notrace sched_clock(void) struct clock_read_data *rd; do { - seq = raw_read_seqcount(&cd.seq); + seq = raw_read_seqcount_latch(&cd.seq); rd = cd.read_data + (seq & 1); cyc = (rd->read_sched_clock() - rd->epoch_cyc) & -- 2.20.1