Received: by 10.192.165.148 with SMTP id m20csp1930030imm; Sat, 21 Apr 2018 19:57:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx49dG2S+V0C0oCPtUxhIhxOKNVDh7wZX0a9FohX8OQgNTlO9NqSqS7kcN1dk2g8PaaMM5llc X-Received: by 10.101.66.6 with SMTP id c6mr12782784pgq.133.1524365864356; Sat, 21 Apr 2018 19:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524365864; cv=none; d=google.com; s=arc-20160816; b=a5MgklMihJTtC3ovvANdg9oBHHQJl5jItO1cpLuUy9JuGCnHaCUMX3mBIdnhBe/F0h 60fYaYMXSkRW1Ngb2zJAuznaOFfBjRt5Kg75e+FgDlkOlA2CHtpUEIS/gcACMfwKTTqW IkJHnXdJWj2WuEFN8EQxkMEwcXM/M6MRGfuweyjfmm0zGSn/yI6KtnOk1Zht1ixt8wQc 9eHTQGpbxws/fTa8piELFCmRzUQ9sh58r2L/0QWeCxsRrI6rh48G7i6692qLz7O348c6 puJT3Ogy5dc/vvV5vXuXyRd4jL/46SyuNm96THJG9Fgc1IscGYrTgIxGyn/DdySJ043Y 7tNQ== 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:arc-authentication-results; bh=5qg2SCLTb4pcaaHvhXGvX5FixPbtCeG/fvZLB75zLV8=; b=VZc78eRC4IDekLyO/Ig3h9wT/td6wOp2vYMNF/gYIhYF71F8hQoGnVr7bAnz076pGL /4X6I4XVjGNBOu1GYZpYtLzG1UGZuq73LdS/AxJguBQw+V5y5ViqLwbyk6zQUrU1p22c NhEumMjtcYEKUrzBJqny7scBRZriG/ywyZqXPAj86DZw98ZdYk6gQ2PGWadgtsRJzZt4 vO2B0vBlst+xanCC1Dx3vhBJfKgcoZWlZmVxRnfrLE6RMlSvZTjN/fuJGujMb6pEuRF9 wSH3SglibvvanWFlOpcE4LvMxsrcz4T8ltQrJ4s1OpBS+aRMFZX9ar49S0jPxSCD9KmX 6FSw== ARC-Authentication-Results: i=1; mx.google.com; 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 m6-v6si5654127pln.382.2018.04.21.19.56.55; Sat, 21 Apr 2018 19:57:44 -0700 (PDT) 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; 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 S1753385AbeDVCxx (ORCPT + 99 others); Sat, 21 Apr 2018 22:53:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:55809 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753025AbeDVCxw (ORCPT ); Sat, 21 Apr 2018 22:53:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D2646ACBF; Sun, 22 Apr 2018 02:53:50 +0000 (UTC) Date: Sat, 21 Apr 2018 19:39:35 -0700 From: Davidlohr Bueso To: Mike Galbraith Cc: Peter Zijlstra , tglx@linutronix.de, mingo@kernel.org, longman@redhat.com, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 2/2] rtmutex: Reduce top-waiter blocking on a lock Message-ID: <20180422023935.twybmkfj3kdtwfuo@linux-n805> References: <20180410162750.8290-1-dave@stgolabs.net> <20180410162750.8290-2-dave@stgolabs.net> <20180420155028.GO4064@hirez.programming.kicks-ass.net> <1524242934.5239.1.camel@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1524242934.5239.1.camel@gmx.de> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Apr 2018, Mike Galbraith wrote: >On Fri, 2018-04-20 at 17:50 +0200, Peter Zijlstra wrote: >> Is this similar to what we have in RT (which, IIRC, has an optimistic >> spinning implementation as well)? > >For the RT spinlock replacement, the top waiter can spin. Yeah and the difference with the rt-spinlock and this patch are points (1) and (3). Probably worth mentioning and, at least at first thought, the rt version might benefit from these breaking out of the spin loop; lateral or normal, I doubt the rt-spinlock wants to adaptive_wait() if the top_waiter changed. > >> ISTR there being some contention over the exact semantics of (3) many >> years ago. IIRC the question was if an equal priority task was allowed >> to steal; because lock stealing can lead to fairness issues. One would >> expect two FIFO-50 tasks to be 'fair' wrt lock acquisition and not >> starve one another. Indeed. >> >> Therefore I think we only allowed higher prio tasks to steal and kept >> FIFO order for equal prioty tasks. Right. In fact this patch is a very limited version of optimistic spinning because we have little room too break fairness and rt constraints (ie no osq, etc). So say waiter task A is spinning for the rtmutex when task B (with equal prio) comes in and tries to take it as well. Because when B is being enqueued we don't comply with rt_mutex_waiter_less(A, B), so we go rb_right. As such the top-waiter pointer is not updated and therefore B blocks while A keeps spinning and take the lock hopefully without blocking. And if we do block we're still top-waiter so fifo wrt waiter B all the way. > >Yup, lateral steal is expressly forbidden for RT classes. Only rt-spinlocks allow lateral stealing, this patch uses the same normal stealing semantics as what rtmutex already provide. And either way I don't see how rt_mutex_spin_on_owner() will influence on current rtmutex semantics as all that changes is not calling schedule(), and we are already accounted for and queued in the waiter tree. Thanks, Davidlohr