Received: by 10.223.185.116 with SMTP id b49csp615760wrg; Tue, 20 Feb 2018 05:07:54 -0800 (PST) X-Google-Smtp-Source: AH8x22755d21qMPqStg2RpY9TR+c5i5tU0C7hte+26i+5PfUDUIjRtQB1NLPd72LC/2maZohP474 X-Received: by 2002:a17:902:9683:: with SMTP id n3-v6mr17160763plp.177.1519132074271; Tue, 20 Feb 2018 05:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519132074; cv=none; d=google.com; s=arc-20160816; b=ahk5TGq6xpSG2ah2ddA+KuDsc97YUri3zfs22k+qTaqpD2+BxDsxJ9RClwLGmjq78l 5hMJtqK/AmZJ6yPvYIHE2xn7hEoqkldMRhcuV/EY3dnvivG5XULUm8URSd3kk0A6H/ZE k8Yi/eS2LiLlh/92mLhOx6Fkx9amtKshsjX/GK48TNhjbymC/8h60C/f0V7HPQrouwL9 9p7Up8xGXzOhnsS/JODapebkSkMoHS8JVQe2yhjHTj11fdpRFjP4mhKrZQYFy64B5UbO 4FmIdBVHHHX05bbiWk6DFPt1hYFq1f+Czn7yuss1mG7BoOLlgS1gKybYD2kOPWGWboAx lu3g== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=5m5W9gMGb1O2yMDirgwsBS6sC4M82KHEX+LeAxitTE4=; b=j00rORwMi3gMYjnSXeme1qDeJzVSZT314KB6AEoTIk4fSjZ2NNp6jBZkyatWkwpZ/u s87i/rTQOGoFKLIkpdS6PFWIC0IfBjvOWjZLbQSmRPasjmlqSxvevzlhgJTBfm7gonm1 wb8yRmO3enRXPGAQU/UKb4a8RWiOU0a0lUzWgDfVev1t6LXjVUchx35tX6n2F0a3MuRM JkOUN17NFWj6Rw7vEzWW5PyVwBZqVeesnLpPxaEGbELznAxrOoRji3CGxmE5hxd53X1C +UR4FRn6YUaV/Qw40c6u+4HGcOTlASe3opSECKjYV5RkUSGrUvH8upJRU7TGUq/sfDrb wyqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZUswnEJz; 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 o2si3337704pgq.565.2018.02.20.05.07.40; Tue, 20 Feb 2018 05:07:54 -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=bombadil.20170209 header.b=ZUswnEJz; 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 S1752387AbeBTNEN (ORCPT + 99 others); Tue, 20 Feb 2018 08:04:13 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:46534 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097AbeBTNCI (ORCPT ); Tue, 20 Feb 2018 08:02:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=5m5W9gMGb1O2yMDirgwsBS6sC4M82KHEX+LeAxitTE4=; b=ZUswnEJzshXFGlDyM1oFyKkt0F HVAXfrqEzs/NOd3PswQE0YmnG36mrSKO3x7LqjByoG5m6xRjlFIGM/veqJ9cbAL1mXf+QNBNiRUPd ntmUPOungR2sSN8jK3pj1Nmp9b8vD5+FK8sA9aBhQw4cohRcw+UvaKxZqEtZ2ktQ/xAcCFchYyyqI Tg+p26824MAFuMN3IVdNfHuCGMZ1Vr4JoI4xDEc4axR7hm+grrYqWgQcDN0T9+/xAzCYABeXnkZgx S50n/aiBpyG5lps7l9pC9VDq0JFu03BtXla0rZypWwM8Ynk5snCUiVR44euG/hrQtMTCl7DGsYmxe vWUcfu/g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eo7YU-0005x0-Sg; Tue, 20 Feb 2018 13:01:59 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 169152038D7AB; Tue, 20 Feb 2018 14:01:54 +0100 (CET) Date: Tue, 20 Feb 2018 13:35:32 +0100 From: Peter Zijlstra To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] locking/ww_mutex: cleanup lock->ctx usage in amdgpu Message-ID: <20180220123532.GD25314@hirez.programming.kicks-ass.net> References: <20180215141944.4332-1-christian.koenig@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180215141944.4332-1-christian.koenig@amd.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This really should've been Cc'ed to me. On Thu, Feb 15, 2018 at 03:19:42PM +0100, Christian K?nig wrote: > diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h > index 39fda195bf78..dd580db289e8 100644 > --- a/include/linux/ww_mutex.h > +++ b/include/linux/ww_mutex.h > @@ -358,4 +358,21 @@ static inline bool ww_mutex_is_locked(struct ww_mutex *lock) > return mutex_is_locked(&lock->base); > } > > +/** > + * ww_mutex_is_owned_by - is the w/w mutex locked by this task in that context > + * @lock: the mutex to be queried > + * @task: the task structure to check > + * @ctx: the w/w acquire context to test > + * > + * Returns true if the mutex is locked in the context by the given task, false > + * otherwise. > + */ > +static inline bool ww_mutex_is_owned_by(struct ww_mutex *lock, > + struct task_struct *task, > + struct ww_acquire_ctx *ctx) > +{ > + return likely(__mutex_owner(&lock->base) == task) && > + READ_ONCE(lock->ctx) == ctx; > +} Nak on that interface, that's racy and broken by design.