Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp372853pxa; Thu, 27 Aug 2020 04:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMbqNELIcenY45/cYzTfAP/LF822mzsUGoaubnf6ZOlZNnp0G5qiPWWJRKEFElBlOlPZF6 X-Received: by 2002:a17:906:87c8:: with SMTP id zb8mr20059412ejb.552.1598529444651; Thu, 27 Aug 2020 04:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598529444; cv=none; d=google.com; s=arc-20160816; b=ygfGO45fnhrb6CtpCTz/GwZQLzT4r6ZL7DFErgzAVClJE/80dVbnxkd16OaD1h3txk ctMMvYwe/uC2UpZsfSGZEFlcknnZZ6kj7gGGsgRcR436Wew6qcY4u5AGAXb3W0MAaTaj eSB4a+qaOpTpDuNjWcI90K2vS0OhTsukIBAiIufKthk3c6iFVzC47/g0KvUrAybxjYJ5 PEiQo9yQicGxbHfibxMEgjGacPdQfCEfU7i36NJcBUIfnAEqQMJOilvGwD8JrcC1bfit hTrhn1Uv7ozmYl+CPbnFRMmIbKL8hZNlih+sz4lmsobk1ZbMn0IvSQ78xkD/eT+n9Vo5 UeIA== 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=VrRM45vL6L0gNPdfds/GsuaBAjPLpyd+E3qz8ezBnpQ=; b=h5/3De9e8eHkvOxu9H5OF9+X7Ycn8dvq+frx2CGTfER1mM/5ohiAryuEnAl6TddjOM 7AGigx1Cye16Ubz6ETWy1G8FB7DUHryh49lMCM2EG+eAuuMWRpYaqKFi2w+mU9PvvmMX aRep93stp3CSO2neNnfOQo7TaUYE6T/AaLnVxFj4HFMJrndJit+yn+GyuF2X225RRT/d bLCU1Akg3u1xdInmo+gSUh3E/2QB9LHCj40AaHzASWj3RrMF2oFdieXEcHTWOgMYht/w ldk7x+SeSVN1pMzXn1fxyk5Pl6YoXPwf2hTKADt6Gw12zdtl7RCn4852HxCbUUmzRbW/ HMPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G8jjpap+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 w5si1107528eja.645.2020.08.27.04.57.02; Thu, 27 Aug 2020 04:57:24 -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=G8jjpap+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S1728512AbgH0Lxp (ORCPT + 99 others); Thu, 27 Aug 2020 07:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728785AbgH0Lk0 (ORCPT ); Thu, 27 Aug 2020 07:40:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 405EFC06121B for ; Thu, 27 Aug 2020 04:40:26 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1598528424; h=from:from: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=VrRM45vL6L0gNPdfds/GsuaBAjPLpyd+E3qz8ezBnpQ=; b=G8jjpap+o80AIiLZN5+/94QkGZCqPg6Ug0Mh3EgjITFTgbe0DNcSmLxFlmtmicosbFbAPd mVDlYUn8MW/7I3HdTn3gzKioN35HOt0QA5ItQofzbTHnVBuROjPvzUlkKxBmlf1nAaSnc9 ZDbgk8PqR9dUmr5mgOrmjB0ty8KBkpnhUA6VbBvJZ9cDP0p12C1VrfBbk33f/nwaLStyrf 4FDkj/23K7LVgqXkvBN+9miin5ZNnStFd165PSDu14QLPVEWWEj15bvDRg5mw38f6Elklr LhRcvTYI95p+uxLSB+AGyk2VdY8ksFexCeL9yxzVyumY5JwZqEVBWMCtqVaU1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1598528424; h=from:from: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=VrRM45vL6L0gNPdfds/GsuaBAjPLpyd+E3qz8ezBnpQ=; b=EGu7Yilw784/dRq6Y+vuP9+tv6uvOyMqetIBeGAR10BcKGwYNPr0z3OxL2Ecbr8rZTd4/r /ukwrjBSh0UHNLBw== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Sebastian A. Siewior" , LKML , "Ahmed S. Darwish" , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Subject: [PATCH v1 0/8] seqlock: Introduce seqcount_latch_t Date: Thu, 27 Aug 2020 13:40:36 +0200 Message-Id: <20200827114044.11173-1-a.darwish@linutronix.de> In-Reply-To: <20200519214547.352050-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> 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 Latch sequence counters are a multiversion concurrency control mechanism where the embedded seqcount_t counter even/odd value is used to switch between two copies of protected data. This allows the sequence counter read side to be invoked from NMIs and safely interrupt its own write side critical section. Initially, latch sequence counters were implemented as a single write function above plain seqcount_t, raw_write_seqcount_latch(). The read path was expected to use plain seqcount_t raw_read_seqcount(). A specialized latch read function, raw_read_seqcount_latch(), was later added. It became the standardized way for latch read paths. Due to the dependent load, it has one read memory barrier less than the more generic raw_read_seqcount() API. Only raw_write_seqcount_latch() and raw_read_seqcount_latch() should be used with latch sequence counters. Having unique read and write path APIs means that latch sequence counters are actually a data type of their own -- just inappropriately overloading plain seqcount_t. Introduce seqcount_latch_t. This adds type-safety and ensures that only the correct latch-safe APIs are to be used. Not to break bisection, let the latch APIs also accept plain seqcount_t or seqcount_raw_spinlock_t. After converting all call sites to seqcount_latch_t, (patches #4 => #7), only allow seqcount_latch_t. Thanks, 8<-------------- Ahmed S. Darwish (8): time/sched_clock: Use raw_read_seqcount_latch() during suspend mm/swap: Do not abuse the seqcount_t latching API seqlock: Introduce seqcount_latch_t time/sched_clock: Use seqcount_latch_t timekeeping: Use seqcount_latch_t x86/tsc: Use seqcount_latch_t rbtree_latch: Use seqcount_latch_t seqlock: seqcount latch APIs: Only allow seqcount_latch_t Documentation/locking/seqlock.rst | 18 ++++++ arch/x86/kernel/tsc.c | 12 ++-- include/linux/rbtree_latch.h | 6 +- include/linux/seqlock.h | 96 +++++++++++++++++++++---------- kernel/time/sched_clock.c | 6 +- kernel/time/timekeeping.c | 10 ++-- mm/swap.c | 65 +++++++++++++++++---- 7 files changed, 156 insertions(+), 57 deletions(-) base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd -- 2.28.0