From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249AbbIEKfY (ORCPT ); Sat, 5 Sep 2015 06:35:24 -0400 Received: from www.linutronix.de ([62.245.132.108]:57541 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754294AbbIEKbi (ORCPT ); Sat, 5 Sep 2015 06:31:38 -0400 Date: Sat, 5 Sep 2015 12:30:59 +0200 (CEST) From: Thomas Gleixner To: Steven Rostedt cc: linux-kernel@vger.kernel.org, linux-rt-users , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , Peter Zijlstra , Clark Williams , Arnaldo Carvalho de Melo , Ingo Molnar Subject: Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack In-Reply-To: <20150904011900.730816481@goodmis.org> Message-ID: References: <20150904011900.730816481@goodmis.org> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 Sep 2015, Steven Rostedt wrote: > There are a lot of trylocks in the kernel, and I'm sure there's more around > that need to be convert to this method. The only ones we need to convert are those which do an actual trylock loop. The others, which simply bail if the trylock fails are completely irrelevant. > I think this is an elegant solution but others may feel > differently. As I think a msleep() hail mary is extremely non > deterministic, it's a blemish for a kernel that prides itself on > adding determinism. I agree that the msleep hack is horrible. Though I do not agree that this solution is elegant. It's clever. I was looking into that a few days ago and did not come up with something sensible, but your patch and reading up on your well done explanation made me look another time. So the problem we need to solve is: retry: lock(B); if (!try_lock(A)) { unlock(B); cpu_relax(); goto retry; } So instead of doing that proposed magic boost, we can do something more straight forward: retry: lock(B); if (!try_lock(A)) { lock_and_drop(A, B); unlock(A); goto retry; } lock_and_drop() queues the task as a waiter on A, drops B and then does the PI adjustment on A. Thoughts? Thanks, tglx