Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp845466pxa; Thu, 27 Aug 2020 18:07:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRPXlxjkIv/WLvPF3K2nw57dD1vC3lc/GC2nC1fISIkT2U+j14XGTYkoW2TNjCvJSx5YJY X-Received: by 2002:a50:8e58:: with SMTP id 24mr23107563edx.199.1598576868527; Thu, 27 Aug 2020 18:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598576868; cv=none; d=google.com; s=arc-20160816; b=f7XpKC3F+hEhWT+O8pIbbiMK7rSA8GeLx2hjuwZVg/CdiRcZYZUsmVc9Pbz6MXa8EA u7pZUNx8EPoDlVAIjdwvKlnwTx0BM0KfQSPHrbgem2gBzzumkPL9hcBEGs5S6iUN6BmU t3VFKRr+ANTOSdkCYddl/XswErHfYLrQc6/FPdgk7paCn9KzRfCW5O+9R+Uzy20YXb3N AZK0Jh7BErfIDnE/gAJNAuBIe3nazn4ECyc2dE6N9lhqYFgTC62sDQ5wcV+Y2Jt7wgXj nFexiBU40q4trgbcTpPaMh9MUPdqPZmQlbvj+la5P3FYzJbDfBRyDl4AAC2zbp22LgjN A7qw== 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=krF9UCs2hhD6NhZsGv5yMaHJjvfUJRQrRXq3bXEz52Y=; b=bLlQLzQmKoXbzpq7GQzMHFgCm0wBj56Aw70y2ADI7qISzhoC/ZGx4+DsO/r2ewi4bn lUCZLXiIoo/Cmxp5GCKD1cgB265QYQ2DI3x0+0p5591AJnfM8aRX7f8AhjrHg2tMOmZh Jho9dX133m3Max7QVeeql5D5hIBRpS0WaWt+yXN+I8JXoYHvPiKmmaCKUnTEywmHG/KV FurPqIFm0xn2OdMvlA/L5f2SwUmA4bQCJcDQj6/plb5o2N5iUEXb/tnpCAaTXZnCxw5Z xhQQQfMZzzGtkFAucuA0EtGmmXA1QPZzNKf65+4+QtP+MQ3+XNtNO+WRoTOlamQhP4Oz psKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QuY3Zrzo; dkim=neutral (no key) header.i=@linutronix.de; 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 k2si1501524edx.169.2020.08.27.18.07.25; Thu, 27 Aug 2020 18:07:48 -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=QuY3Zrzo; dkim=neutral (no key) header.i=@linutronix.de; 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 S1727124AbgH1BGv (ORCPT + 99 others); Thu, 27 Aug 2020 21:06:51 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:41826 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbgH1BGv (ORCPT ); Thu, 27 Aug 2020 21:06:51 -0400 From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1598576809; 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=krF9UCs2hhD6NhZsGv5yMaHJjvfUJRQrRXq3bXEz52Y=; b=QuY3Zrzo14totflOYu8te2z0fy1UsAG/wVVrfWZnYC5/uVTPZEBmo7b19vH5JOLABQKYYH m5wX6WlBanxbQVXras84ZiJPHDUiFIpjWUIRhN2xnpfpOmOOqFghUZVkiWCt6sp1RN6Jaw dVFuUqCjTEExv7ud8IQvQpS0C0hu362WOdEDZ6Y7alk1jropK322PCkP2zfn+qmasSpxRd X5mTQ1UJSq4UaOBrUsrR2KxdF5kjdaFCfJghaQZLX5OcWeOdIUb7Q0Rtb4i3LzHcKzNXQ9 vX1q5cGtPG9MWs5WKgqmr+TLt52rZOjCUM9Hp27ouInAKojmZcnkZWT841TDzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1598576809; 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=krF9UCs2hhD6NhZsGv5yMaHJjvfUJRQrRXq3bXEz52Y=; b=VoChQdPr25dTxfVvHeFB03GgutMQyMj81tsEEmHQXo3nMBDhZcoxoZcH1GfzpXxTQ1x4ry 3yflVzYtCMzvohCw== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Sebastian A. Siewior" , "Paul E. McKenney" , Steven Rostedt , LKML , "Ahmed S. Darwish" Subject: [PATCH v1 0/5] seqlock: Introduce PREEMPT_RT support Date: Fri, 28 Aug 2020 03:07:05 +0200 Message-Id: <20200828010710.5407-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-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Preemption must be disabled before entering a sequence counter write side critical section. Failing to do so, 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. 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 solve this dilemma, do not disable preemption for seqcount_LOCKTYPE_t writers. Rather, detect if a seqcount_LOCKTYPE_t writer is in progress. If that is the case, acquire then release the associated LOCKTYPE writer serialization lock. This will allow any preempted writer to make progress until the end of its writer serialization lock critical section. Implement this technique for all of PREEMPT_RT sleeping locks. Thanks, 8<-------------- Ahmed S. Darwish (5): seqlock: seqcount_LOCKTYPE_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_LOCKTYPE_t: Introduce PREEMPT_RT support seqlock: PREEMPT_RT: Do not starve seqlock_t writers include/linux/seqlock.h | 277 ++++++++++++++++++++++++---------------- 1 file changed, 167 insertions(+), 110 deletions(-) base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd -- 2.28.0