Received: by 10.223.185.116 with SMTP id b49csp632354wrg; Tue, 20 Feb 2018 05:24:00 -0800 (PST) X-Google-Smtp-Source: AH8x224SrThWc2onpaSQSlrb//TCoC1+J9ili7UG9vbkU9foFVO2UjchqqYi9nqpYg3XUCf+l51l X-Received: by 2002:a17:902:8b88:: with SMTP id ay8-v6mr17627976plb.197.1519133040390; Tue, 20 Feb 2018 05:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519133040; cv=none; d=google.com; s=arc-20160816; b=cRqlV9EDGp0va4+B7/xTJQgqRrU7GQQph+bY5qMxi9AGNN+xajmOKX+oC8KTHBqoBg 7UmdIp8uxB+r4e6DRiEqGO5nzj2vhE/wzCRkm48IHnA8sopcoOsxgs3KnzCO9r9QtDhG g1ZguzS/BBr8TpqthsPzu1qwFU3hNnlb+OItOq06zthl4T65kgq5/eM2rH+T5XgoRKih vqu+CpKQ7yc9ezgkzg/JrfwB/4GkuIKxM0zkP7xF9bWtfuicQhcKsqmB8hP5y5BxJYkP G0kYQ27EAc5eqk4LOm6E3e1s8q+ylOKxToIIuC9JT7GQMXP9xoQCL3L0DB+zBV3KOXDG mYZw== 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=QNu0pZpiSZymi4s0VifXShAJGsv86fsVG0Hk4QP1m7E=; b=eMCVU6WYiQEWeV8KxyaXgJ40bDNxatiZMWD0vkRZ4PcNcNoDoNq9QWX0aJEeja/ojQ eM39suIFlmdNpNkiLcF5lkI24fNHsi0Bf8fDYga/K2FU7aBab+tEoiaghrRxv0uA60Ae GMNe+7fex8eAZ1MX+HiJRUHELnUj9TlO8TEgagCbf03XEQe+QO/wxGtQ8+YOq7IUY2HI qx4or746bwRQTKaPhII/NTiXTiRDHqI/6hHOGCK6pxZsW8W2SnvMHJ+2XX2Fof1VY9Fm 6aorcfSoKs6gtyTzldsG1C4q0vbKOGEWYfcph7oRQJMyc3Z+Pkq4+6okMZzJknuvFlvI 53GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=DHuOjwEW; 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 u10-v6si7178755plu.362.2018.02.20.05.23.46; Tue, 20 Feb 2018 05:24:00 -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=merlin.20170209 header.b=DHuOjwEW; 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 S1751891AbeBTNXC (ORCPT + 99 others); Tue, 20 Feb 2018 08:23:02 -0500 Received: from merlin.infradead.org ([205.233.59.134]:55774 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbeBTNXA (ORCPT ); Tue, 20 Feb 2018 08:23:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=QNu0pZpiSZymi4s0VifXShAJGsv86fsVG0Hk4QP1m7E=; b=DHuOjwEW9oVgAeykSmuuNCzZ0S gMHyYt8bn/rrB0dYVbGrGagkCyIZYCyfSxYdQvgX8zKX1XZ6a9Z6n5I5lNlIHAykxRJrjBs+3Jjkc QpPZyul1TqYzWu7L8wYPxFovUMsX3QHYTbMJl9wI7h6zvQaJQbCQsow9CDdYpbWSmkPsvYSvN1PU4 0tcVgkPbmuDO2QLm4JHq707ihTeywXd6vhMnQvAri/SiJGzoUo7eylfJQd2PU+Cbfm2PPxFGiMNEs itbHBt6fjLoSImA+lYnIybLGELYUf7Jx/DpKbpSYoxUX/PJJH8P9WvJSJ2kKw7SjXTrKcnjVwukPR eVXqvayg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eo7sm-0008CE-2m; Tue, 20 Feb 2018 13:22:56 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5BC99203895CA; Tue, 20 Feb 2018 14:22:54 +0100 (CET) Date: Tue, 20 Feb 2018 14:22:54 +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: <20180220132254.GB25201@hirez.programming.kicks-ass.net> References: <20180215141944.4332-1-christian.koenig@amd.com> <20180220123532.GD25314@hirez.programming.kicks-ass.net> 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.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 20, 2018 at 02:08:26PM +0100, Christian K?nig wrote: > Am 20.02.2018 um 13:35 schrieb Peter Zijlstra: > > > +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. > > Why? If task != current you can race with a concurrent mutex_unlock().