Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1322464pxk; Thu, 10 Sep 2020 12:28:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1PLLpkHLW7F10vqlpQh4hOrHUrrsLbHPt7BEdU1z+WUXaLipj9qfxEaNZC+criuZHnlio X-Received: by 2002:a05:6402:10c6:: with SMTP id p6mr11061101edu.76.1599766096065; Thu, 10 Sep 2020 12:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599766096; cv=none; d=google.com; s=arc-20160816; b=gwvaWbRFYvhEdWNzroCxYns0rufiHMjZxLamL3TZFATeOlQCobKhKki5+ncSwAoQqK csZOCdlZloKI5Pg4NsaR16ytfwpe3KX4v26qsTC3D/HvZ6tkE9Kc+mZpl1zbaALgAUpl Nnzjadq1/hlUZmBaty8iOnkRt8U7ZooTm0M5oEAOjm7WFSyNa99WljICTDHykBaObWum pgUnhKl+ikWp8vSsMDVIWl3ki7WUZV3KybpKEpSGQIXIAQC7PkAg6YQkVUd9Gh3KyXn8 Zw4f6YoM4bNgGhtGtSuTTaG8z//CN8s+M/TqyO5JPaqIf6bmkrKM0jzRijbZRHZOZEpF Mv7g== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=L0m5hkB+ccYH+x0REmVy1EbpacF/uWU6RknxT4dz2eE=; b=lu/z/1kP0nF1Kjz9jU/BoQgRfo+U7BHYivSIMh/ukOvD8+Y+Sv+rhXSZZMyMzRrjMQ 8aUtL57Bu5hXhaOJYbNdkilnhHFE7Y3dIu4xOcmR8LGz1mJfJvqW0eG2aNtfXw43vhca ehj+zRvkqdSUNm705S+f+ahmhujmLw4tXadQ1ZwPOGj9nB49D4aAaJvKYITYb6N47P6/ AkR/sHUly48it0NpmM6/C83kEwFOD3XZSGW6TCKK1o59YZ0ZWs5SWOkF5AC3+QfpvWIz 8Gm7NRdcphJzLOs/lpj58vHzE0rJ7Zb5peZIgzDOCqn+6Q24iiu5LuuNeKw+z6zEPQaS yZmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=VMz6dL4y; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wwB99Isc; 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=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 f2si3305309ejq.262.2020.09.10.12.27.52; Thu, 10 Sep 2020 12:28:16 -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=fail header.i=@linutronix.de header.s=2020 header.b=VMz6dL4y; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wwB99Isc; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727861AbgIJTZy (ORCPT + 99 others); Thu, 10 Sep 2020 15:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730408AbgIJPs1 (ORCPT ); Thu, 10 Sep 2020 11:48:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772ECC061357; Thu, 10 Sep 2020 08:08:29 -0700 (PDT) Date: Thu, 10 Sep 2020 15:08:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1599750508; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0m5hkB+ccYH+x0REmVy1EbpacF/uWU6RknxT4dz2eE=; b=VMz6dL4yUiRiwUrxthpgSI5eAS1bzOnTA9DTFdL8ZV6ImIbQQh3RbFK9FhQM4FlOpqJfMK pZzcPO3U3Mjt1cGe9TREoX8fPdd9Zs21VMowg3EPtgRHCB5Tncf/yAAeA8DPJFtigrFo3R FELoOJxNQivl3UI5W0ly/oMY2bOriIfMRo5uVMkLXI1Ycb49XcsHeAuTZ8qPiLPHl6jQE4 v2BuPFw3ZUWyDeepVf3e9fog4eQf0BfZIbw88nDg9N+S8DEhlHdc+2w4Xff/Z+wmMGnUSr vFivSpI9NKo/R/8QFZaciclCSs4U9relzbCoVth+fArJ0JULxev3S6H/rVuqPw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1599750508; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0m5hkB+ccYH+x0REmVy1EbpacF/uWU6RknxT4dz2eE=; b=wwB99IscBcsPFeUbKjxInZFJd2XZmmWU+4G8MG+3lq181I1M5i2fZKWOzo1yhfa2eB5K7B wl+UVK1dOE6viOBA== From: "tip-bot2 for Ahmed S. Darwish" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] timekeeping: Use seqcount_latch_t Cc: "Ahmed S. Darwish" , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200827114044.11173-6-a.darwish@linutronix.de> References: <20200827114044.11173-6-a.darwish@linutronix.de> MIME-Version: 1.0 Message-ID: <159975050740.20229.1073373223572014594.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/core branch of tip: Commit-ID: 249d053835320cb3e7c00066cf085a6ba9b1f126 Gitweb: https://git.kernel.org/tip/249d053835320cb3e7c00066cf085a6ba9b= 1f126 Author: Ahmed S. Darwish AuthorDate: Thu, 27 Aug 2020 13:40:41 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 10 Sep 2020 11:19:29 +02:00 timekeeping: Use seqcount_latch_t Latch sequence counters are a multiversion concurrency control mechanism where the seqcount_t counter even/odd value is used to switch between two data storage copies. This allows the seqcount_t read path to safely interrupt its write side critical section (e.g. from NMIs). Initially, latch sequence counters were implemented as a single write function, raw_write_seqcount_latch(), above plain seqcount_t. The read path was expected to use plain seqcount_t raw_read_seqcount(). A specialized read function was later added, raw_read_seqcount_latch(), and became the standardized way for latch read paths. Having unique read and write APIs meant that latch sequence counters are basically a data type of their own -- just inappropriately overloading plain seqcount_t. The seqcount_latch_t data type was thus introduced at seqlock.h. Use that new data type instead of seqcount_raw_spinlock_t. This ensures that only latch-safe APIs are to be used with the sequence counter. Note that the use of seqcount_raw_spinlock_t was not very useful in the first place. Only the "raw_" subset of seqcount_t APIs were used at timekeeping.c. This subset was created for contexts where lockdep cannot be used. seqcount_LOCKTYPE_t's raison d'=C3=AAtre -- verifying that the seqcount_t writer serialization lock is held -- cannot thus be done. References: 0c3351d451ae ("seqlock: Use raw_ prefix instead of _no_lockdep") References: 55f3560df975 ("seqlock: Extend seqcount API with associated locks= ") Signed-off-by: Ahmed S. Darwish Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200827114044.11173-6-a.darwish@linutronix.de --- kernel/time/timekeeping.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4c47f38..999c981 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -64,7 +64,7 @@ static struct timekeeper shadow_timekeeper; * See @update_fast_timekeeper() below. */ struct tk_fast { - seqcount_raw_spinlock_t seq; + seqcount_latch_t seq; struct tk_read_base base[2]; }; =20 @@ -81,13 +81,13 @@ static struct clocksource dummy_clock =3D { }; =20 static struct tk_fast tk_fast_mono ____cacheline_aligned =3D { - .seq =3D SEQCNT_RAW_SPINLOCK_ZERO(tk_fast_mono.seq, &timekeeper_lock), + .seq =3D SEQCNT_LATCH_ZERO(tk_fast_mono.seq), .base[0] =3D { .clock =3D &dummy_clock, }, .base[1] =3D { .clock =3D &dummy_clock, }, }; =20 static struct tk_fast tk_fast_raw ____cacheline_aligned =3D { - .seq =3D SEQCNT_RAW_SPINLOCK_ZERO(tk_fast_raw.seq, &timekeeper_lock), + .seq =3D SEQCNT_LATCH_ZERO(tk_fast_raw.seq), .base[0] =3D { .clock =3D &dummy_clock, }, .base[1] =3D { .clock =3D &dummy_clock, }, }; @@ -467,7 +467,7 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_= fast *tkf) tk_clock_read(tkr), tkr->cycle_last, tkr->mask)); - } while (read_seqcount_retry(&tkf->seq, seq)); + } while (read_seqcount_latch_retry(&tkf->seq, seq)); =20 return now; } @@ -533,7 +533,7 @@ static __always_inline u64 __ktime_get_real_fast_ns(struc= t tk_fast *tkf) tk_clock_read(tkr), tkr->cycle_last, tkr->mask)); - } while (read_seqcount_retry(&tkf->seq, seq)); + } while (read_seqcount_latch_retry(&tkf->seq, seq)); =20 return now; }