Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1403583pxk; Fri, 4 Sep 2020 08:33:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkq2vMihGoXxeueRTZcrIks/c/btj+nz1M8v/QlLvTtxj9+nDQPkbd/ru8w8y7qT/sdXnP X-Received: by 2002:a05:6402:176e:: with SMTP id da14mr9315585edb.349.1599233601650; Fri, 04 Sep 2020 08:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599233601; cv=none; d=google.com; s=arc-20160816; b=YAqYN9OVwHgs2GV/X2ah15tkqIOgfU/scggpJ0ZJ+8NLjZhZ7/xWmSXu34keMTiHn+ sE6z7fI4G44EEVzl0StVp+to5/6e3FP0c9DZerAwEcWVutIbbZgJqGb+EaHvASFSWZ/K PZfd6K6wT7yDPLprpBeu3IV39G2N8+SmS3qG1vO2jsvMdYCXyeHTEa+DLRPH/bvWO/sW lH6W0zWroMmqRKl9HvbsFm8uXbRRaGGckt+gShcJekYA7l8RaUICBgF+x5wNaNJFvOmX e7pBOIvcYRhpoJYfwGxYcVPs3mhauVIh6HB7kxQ6sHK5VDnDbrviOeflQwQU5iMwSFjn +XkQ== 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 :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=rSCW3ByRFMYvEoYwmcb4lzYw4fsM0+Zw7CquB9xGWrw=; b=0fr6npceFANGYyRbFwCkugoy6tJBEfApOsJ+WF9nEM7Kbva0h7S2OJ9TuR4PcmIHG7 E0e5OtND1peKQbAEXkCHfu5CQET9V0pxDCYlTg16NyMD2bb0r8gA4m3N1zSQzobfeq3P ojd0A7MAxe0tUDbFEKQuCNkzpj27xuaL7x0B1en8IcDyRIW9C4F8gboMOUCV3L28Al81 dBJG+XfHM3FWBTC/GLwbL5h3Vnxh9qRAWAdPPqHFtHyzGpKC4tIqSzCZS9tAh/iIfyDO dT9X+kuTnMtiKR1E3FCWBYkPOHxIkm0/NmLK4DnBol3hiAW3MtZHKCB0en2jQBGpQ9VS 7RHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EKQptKe5; dkim=neutral (no key) header.i=@vger.kernel.org; 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 p8si3915437edw.437.2020.09.04.08.32.57; Fri, 04 Sep 2020 08:33:21 -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=EKQptKe5; dkim=neutral (no key) header.i=@vger.kernel.org; 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 S1726314AbgIDPcI (ORCPT + 99 others); Fri, 4 Sep 2020 11:32:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbgIDPcH (ORCPT ); Fri, 4 Sep 2020 11:32:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DDA9C061244 for ; Fri, 4 Sep 2020 08:32:05 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1599233523; 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; bh=rSCW3ByRFMYvEoYwmcb4lzYw4fsM0+Zw7CquB9xGWrw=; b=EKQptKe5F9xnHP/B7LudRVUuQC0e/5xfdyXJAzXj/q8trSFdgoPCKQh02Ep5xAaDenV5YE cs8peUClqLUOs0K+TDdvXyNBV+EdtY/W4DoeTTXoFaKLg8hMIb1+UQCTEpxwcr/h5pvFSy Tt5OioK82Unm5PsZNVcJJWp3twKd3PASI70iXxRhAyqhP8wkhOtDWEuaEbAFDTZfzigesb ZSYmbTUIihSB3FgrWNRr+h1Opo6JHPHwhhWuVDlP4A40IuLLtdirKuUC0idbIhgGlfK4AE eTp0Hxjpl39mxT/5fTfPVrO3JWB1m2SbiGNvNK6bZB6QGFHuJRUSlQy7MrMJ4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1599233523; 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; bh=rSCW3ByRFMYvEoYwmcb4lzYw4fsM0+Zw7CquB9xGWrw=; b=NrMT2JMySmccXfRhuW+2AUBT8f5WaSleSzC4NlM6RBtnGD9asZ+hMz+6h5XX/vNn0mzsgc EVOFHk4zZoalfOBA== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Sebastian A. Siewior" , "Paul E. McKenney" , Steven Rostedt , LKML , "Ahmed S. Darwish" Subject: [PATCH v2 0/5] seqlock: Introduce PREEMPT_RT support Date: Fri, 4 Sep 2020 17:32:26 +0200 Message-Id: <20200904153231.11994-1-a.darwish@linutronix.de> 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 Hi, Changelog-v2 ============ - Standardize on seqcount_LOCKNAME_t as the canonical reference for sequence counters with associated locks, instead of v1 seqcount_LOCKTYPE_t. - Use unique prefix "seqprop_*" for all seqcount_t/seqcount_LOCKNAME_t property accessors. - Touch-up the lock-unlock rationale for more clarity. Enforce writer non-preemitiblity using "__seq_enforce_writer_non_preemptibility()". Cover letter (v1) ================= https://lkml.kernel.org/r/20200828010710.5407-1-a.darwish@linutronix.de Preemption must be disabled before entering a sequence counter write side critical section. Otherwise the read side section can preempt the write side section and spin for the entire scheduler tick. If that reader belongs to a real-time scheduling class, it can spin forever and the kernel will livelock. Disabling preemption cannot be done for PREEMPT_RT though: it can lead to higher latencies, and the write side sections will not be able to acquire locks which become sleeping locks (e.g. spinlock_t). To remain preemptible, while avoiding a possible livelock caused by the reader preempting the writer, use a different technique: let the reader detect if a seqcount_LOCKNAME_t writer is in progress. If that's the case, acquire then release the associated LOCKNAME writer serialization lock. This will allow any possibly-preempted writer to make progress until the end of its writer serialization lock critical section. Implement this lock-unlock technique for all seqcount_LOCKNAME_t with an associated (PREEMPT_RT) sleeping lock, and for seqlock_t. 8<-------------- Ahmed S. Darwish (5): seqlock: seqcount_LOCKNAME_t: Standardize naming convention seqlock: Use unique prefix for seqcount_t property accessors seqlock: seqcount_t: Implement all read APIs as statement expressions seqlock: seqcount_LOCKNAME_t: Introduce PREEMPT_RT support seqlock: PREEMPT_RT: Do not starve seqlock_t writers include/linux/seqlock.h | 281 ++++++++++++++++++++++++---------------- 1 file changed, 167 insertions(+), 114 deletions(-) base-commit: f75aef392f869018f78cfedf3c320a6b3fcfda6b -- 2.28.0