Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965502AbcKXLkf (ORCPT ); Thu, 24 Nov 2016 06:40:35 -0500 Received: from merlin.infradead.org ([205.233.59.134]:50486 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965352AbcKXLkc (ORCPT ); Thu, 24 Nov 2016 06:40:32 -0500 Date: Thu, 24 Nov 2016 12:40:07 +0100 From: Peter Zijlstra To: Nicolai =?iso-8859-1?Q?H=E4hnle?= Cc: Nicolai =?iso-8859-1?Q?H=E4hnle?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Ingo Molnar , stable@vger.kernel.org, Maarten Lankhorst Subject: Re: [PATCH 1/4] locking/ww_mutex: Fix a deadlock affecting ww_mutexes Message-ID: <20161124114007.GE3092@twins.programming.kicks-ass.net> References: <1479900325-28358-1-git-send-email-nhaehnle@gmail.com> <20161123140336.GU3092@twins.programming.kicks-ass.net> <20161123142525.ns2pkyp4bo2sa5z2@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1094 Lines: 25 On Thu, Nov 24, 2016 at 12:26:57PM +0100, Nicolai H?hnle wrote: > I do believe we can win a bit by keeping the wait list sorted, if we also > make sure that waiters don't add themselves in the first place if they see > that a deadlock situation cannot be avoided. > > I will probably want to extend struct mutex_waiter with ww_mutex-specific > fields to facilitate this (i.e. ctx pointer, perhaps stamp as well to reduce > pointer-chasing). That should be fine since it lives on the stack. Right, shouldn't be a problem I think. The only 'problem' I can see with using that is that its possible to mix ww and !ww waiters through ww_mutex_lock(.ctx = NULL). This makes the list order somewhat tricky. Ideally we'd remove that feature, although I see its actually used quite a bit :/ > In the meantime, I'd appreciate it if patch #1 could be accepted as-is for > stable updates to <= 4.8. It fixes a real (if rare) bug, and the stampede > inefficiency isn't a problem in practice at least for GPU applications. Sorry can't do. We don't do stable patches that don't have anything upstream.