Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933397AbcK3Mxb (ORCPT ); Wed, 30 Nov 2016 07:53:31 -0500 Received: from mail.fireflyinternet.com ([109.228.58.192]:64353 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932233AbcK3MxX (ORCPT ); Wed, 30 Nov 2016 07:53:23 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Date: Wed, 30 Nov 2016 12:52:29 +0000 From: Chris Wilson To: Maarten Lankhorst Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Nicolai =?iso-8859-1?Q?H=E4hnle?= Subject: Re: [PATCH 4/4] locking: Add kselftests for ww_mutex stress Message-ID: <20161130125229.GQ23336@nuc-i3427.alporthouse.com> References: <1480335612-12069-1-git-send-email-nhaehnle@gmail.com> <20161130003548.22266-1-chris@chris-wilson.co.uk> <20161130003548.22266-4-chris@chris-wilson.co.uk> <67628c55-e8a1-cc33-f99a-ec458c83657c@mblankhorst.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67628c55-e8a1-cc33-f99a-ec458c83657c@mblankhorst.nl> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1302 Lines: 42 On Wed, Nov 30, 2016 at 01:29:39PM +0100, Maarten Lankhorst wrote: > > +static void stress_work(struct work_struct *work) > > +{ > > + struct stress *stress = container_of(work, typeof(*stress), work); > > + const int nlocks = stress->nlocks; > > + struct ww_mutex *locks = stress->locks; > > + struct ww_acquire_ctx ctx; > > + int contended = -1; > > + int *order; > > + int n, ret; > > + > > + order = get_random_order(nlocks); > > + if (!order) > > + return; > > + > > + ww_acquire_init(&ctx, &ww_class); > > + > > +retry: > > + ret = 0; > > + for (n = 0; n < nlocks; n++) { > > + if (n == contended) > > + continue; > > + > > + ret = ww_mutex_lock(&locks[order[n]], &ctx); > > + if (ret < 0) > > + break; > > + } > What's wrong with attempting to lock the contended lock here? > Who knows, this might find some more bugs than the functional tests already do. I was trying to follow the guide, which was lock, backoff by unlocking everything, slowlock the contended lock, then lock everything else. I have now a second worker that follows the reordering method as well. (As well as a test that slowlock after the ABBA deadlock detection resolves the locking order.) If you have a sketch of something else to try, I'll add it. -Chris -- Chris Wilson, Intel Open Source Technology Centre