Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4803327ima; Tue, 5 Feb 2019 01:23:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IZvbDdtpp6qa5TcAxqWNn/O94LTnD1KE6L4qguMcTAKuqU8Umc5S3K9C36E6gEN7aTjwkBU X-Received: by 2002:a62:d448:: with SMTP id u8mr3961396pfl.105.1549358616312; Tue, 05 Feb 2019 01:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549358616; cv=none; d=google.com; s=arc-20160816; b=K0T+DYA1lMAX6EnbqlWD2Axu4CieQa91pgc4DeqLlsvuM7WNZPl+8Zsu/dwcNPPYdW FMtb8RVtw2hM0asHIJIXu3zZ9BZvdmrmEVTaYyDJiEjX3aJYsub+mMYbA9NQFf3Z5ri3 ECRnFIFrJV77xRDzL76XIIHsNijaYavqSbZcSPNOliiGJubK7jvlglRxWpk1kGlr+Q4i ysi1fDBvx4yGnbgexAwEpDW9TXxJW2ct5LzVpP5GStxTLbTuNrgsK89TN/ureU7WjkAF 57VczfYU1KHg3yiC9UXP1Pfo3JmHuzYv2t1n5CuZhh+QmFJwza4sMxPIB8wwavJzwuyh RL0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ibwc9w+bPMoLLGGAf8748K/x4LzwNL3moCb9zIc0th8=; b=cpbduzqUD+6MyAthh0+PGWFefSDRViUCPTz2rFA09rwUaPGHg4peqv8uLHIhqBYzvX XjqXkbNxcRZ7PG5gi7SAaUnP1k55xu3j1/rGSLbacNadieANyUaV+TCOYzsAV33KcGKA yvp9BRjmWZwMquPULGzOgSL6hw8mrs3ErG0IJm+MAlFz6VfBMBQa5MG9wetaF0hGOxn3 z2XMKfLaUG9vkXaSgSVLDsBEd3IteOShgThRmV2wsnTJrI3kmuRULRLBx5A17IzOqL7T oskSG1bM/hV+Dkwjon9slCyLXEOL4qYSWXbkRedzAQFaHNOTaD1JfZzh9XBD9wwS6iU4 3tIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="Q2m/B2UA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si2737731pfc.49.2019.02.05.01.23.19; Tue, 05 Feb 2019 01:23:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="Q2m/B2UA"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728252AbfBEJXP (ORCPT + 99 others); Tue, 5 Feb 2019 04:23:15 -0500 Received: from merlin.infradead.org ([205.233.59.134]:44446 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfBEJXP (ORCPT ); Tue, 5 Feb 2019 04:23:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ibwc9w+bPMoLLGGAf8748K/x4LzwNL3moCb9zIc0th8=; b=Q2m/B2UAuj4t6AcCQHXNX5wHR anYsqzl+OJyEO+PvAxNbTyYu7ROVEcW+2bA6WXksmwffZyo/hI9Fn4rkutOzPYrrk3zNo/tI6Lmq6 HGIeS/Qudr+6ura0se7OTePh6p7Y0cAB5q9MtTSDu6GUkoXHMkhxvRX3ihBKNXOkD/TiG/tplINGn oKta3x0SMyt/IXLn/opX3ia/HPvphmR9e+NJbPf3UmuYybTQ7VqIHMloKddKomQcqHoDgzTItsnGT QflkjbJtZqZye85BH+qH/8tZHY+zou/K443aY18TmJphTGnfY/4jUEq46jwB1IzJzSiIDTK3wJpZX /OwvKSNYg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqwwT-0002Rr-Ng; Tue, 05 Feb 2019 09:22:58 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3382E2029FA06; Tue, 5 Feb 2019 10:22:56 +0100 (CET) Date: Tue, 5 Feb 2019 10:22:56 +0100 From: Peter Zijlstra To: Alex Kogan Cc: linux@armlinux.org.uk, mingo@redhat.com, will.deacon@arm.com, arnd@arndb.de, longman@redhat.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, steven.sistare@oracle.com, daniel.m.jordan@oracle.com, dave.dice@oracle.com, rahul.x.yadav@oracle.com, Thomas Gleixner Subject: Re: [PATCH 3/3] locking/qspinlock: Introduce starvation avoidance into CNA Message-ID: <20190205092256.GN17528@hirez.programming.kicks-ass.net> References: <20190131030136.56999-1-alex.kogan@oracle.com> <20190131030136.56999-4-alex.kogan@oracle.com> <20190131100009.GB31534@hirez.programming.kicks-ass.net> <10672939-5C35-4DEF-AFDE-99E85E0F9C46@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10672939-5C35-4DEF-AFDE-99E85E0F9C46@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 04, 2019 at 10:35:09PM -0500, Alex Kogan wrote: > > > On Jan 31, 2019, at 5:00 AM, Peter Zijlstra wrote: > > > > On Wed, Jan 30, 2019 at 10:01:35PM -0500, Alex Kogan wrote: > >> Choose the next lock holder among spinning threads running on the same > >> socket with high probability rather than always. With small probability, > >> hand the lock to the first thread in the secondary queue or, if that > >> queue is empty, to the immediate successor of the current lock holder > >> in the main queue. Thus, assuming no failures while threads hold the > >> lock, every thread would be able to acquire the lock after a bounded > >> number of lock transitions, with high probability. > >> > >> Note that we could make the inter-socket transition deterministic, > >> by sticking a counter of intra-socket transitions in the head node > >> of the secondary queue. At the handoff time, we could increment > >> the counter and check if it is below a threshold. This adds another > >> field to queue nodes and nearly-certain local cache miss to read and > >> update this counter during the handoff. While still beating stock, > >> this variant adds certain overhead over the probabilistic variant. > > > > (also heavily suffers from the socket == node confusion) > > > > How would you suggest RT 'tunes' this? > > > > RT relies on FIFO fairness of the basic spinlock primitives; you just > > completely wrecked that. > > This is true that CNA trades some fairness for shorter lock handover > latency, much like any other NUMA-aware lock. > > Can you explain, however, what exactly breaks here? Timeliness guarantees. FIFO-fair has well defined time behaviour; you know exactly how long you get to wait before you acquire the lock, namely however many waiters are in front of you multiplied by the worst case wait time. Doing time analysis on a randomized algorithm isn't my idea of fun. > It seems that even today, qspinlock does not support RT_PREEMPT, given > that it uses per-CPU queue nodes. It does work with RT, commit: 7aa54be29765 ("locking/qspinlock, x86: Provide liveness guarantee") it a direct result of RT observing funnies with it. I've no idea why you think it would not work.