Received: by 10.223.185.116 with SMTP id b49csp579471wrg; Tue, 20 Feb 2018 04:32:21 -0800 (PST) X-Google-Smtp-Source: AH8x227UtW6+1GW7bJe7DfHzlXJsfjbP468j3/dKhoEGq0CaPvYptfbu1azNzTN/xbk4lZX1f7Bk X-Received: by 2002:a17:902:9a01:: with SMTP id v1-v6mr7788160plp.76.1519129941819; Tue, 20 Feb 2018 04:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519129941; cv=none; d=google.com; s=arc-20160816; b=cnYxVHRlODywqjwubCLwytvNHBn9feud8aADapFLWD2rDaK+9B7Bp0erMjxKvfb+M7 t5qV2PKqIwhhXL9qpEF1Rp+DwTil3vfUOykIWEgTFHMq4qtaQsGzBeftzxNa+7zyQ5Hp 0ZC+z0vrlSy/4VPSyiLywNwJ5ZAiOeiDaXDX1cCVbFXbMVegHwX01H47gRbCJv6fEpdu 7T4HzmXuvPxvuAgunCgq4wb7koons5j5Qd7Kj2J7RuFJJxpLeAY8rDDRSY00R3DhCJI2 zUr3eMwGCtbaQZ396EYtG7YLRVH0l26YACX6mF9ZkhbfFdZzODLVUkPzUK/SDyPfpbkz t+hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=VeEr9H5mW9S11DWejVRnqSpJmgt1rB8p43AsktUmWfw=; b=kjnHRiKQFCv6InoSwKqXBOTiOOAXuJ+vpN9vGg4svijvpTjxNT0F57jYialtF5rvNz vl2Xdn+vX9oUZ/FC6/S2/b6EXOryEVGkeE5Uer7YpaDBHr+n84z/Orni1cn2+70q44X0 3M4uTKmRkCpxfvgsfEVI9SPOrvG0tuosyhPqNJtc3wencTrwtOwYUvuFMTJzIERRVIdF dagMc6lDA+vYOi6gyyx+enBpqE/xrYsiMEfbwdj8i9BVKB3vJhf5zKAtjzGoEgbEdNnY 5KLnyPxxQTPIy2bnaYGlBgcoD1PhLPa4cNwIiPScL9BRBcrPWRn1q3EGgJpf/H7djRc1 tITw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZX3w8EYg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16-v6si10088147pll.360.2018.02.20.04.32.07; Tue, 20 Feb 2018 04:32:21 -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=pass header.i=@gmail.com header.s=20161025 header.b=ZX3w8EYg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751820AbeBTMbU (ORCPT + 99 others); Tue, 20 Feb 2018 07:31:20 -0500 Received: from mail-wr0-f182.google.com ([209.85.128.182]:36352 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751630AbeBTMbR (ORCPT ); Tue, 20 Feb 2018 07:31:17 -0500 Received: by mail-wr0-f182.google.com with SMTP id u15so13890018wrg.3 for ; Tue, 20 Feb 2018 04:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=VeEr9H5mW9S11DWejVRnqSpJmgt1rB8p43AsktUmWfw=; b=ZX3w8EYgbra07TvqmpmZAiJ7l9s7XPd8c+iU42fwWMa+NilFLegD/j5ybdLfqxJxc8 oWWYnsnRGNwKYJEMXiRAYHdmQZhJpoS0nSdpf7V1LajmwMG+WHVIgT1ysoYlm8vbRbGV DCcLrFk6OSQef6NSdZPmp4dj0edxKnuz6ZZsdex18qLeRoCcqjjrdQs/zdFNtLFZtK0h +7lf+N+lAPgQeb2Whqi/jVvsLJ2VPLliQ9sM2en6gDAJA2jq07e4bta12izTMjwEYNmA +1n4yfhGNuatpEBHNryLXW4hm0cfqCk7KPdanCJ/xCXjzStDn+r9Ry+douyD/cT389U3 gvzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=VeEr9H5mW9S11DWejVRnqSpJmgt1rB8p43AsktUmWfw=; b=I1JU6SEBlfeOPMh5kXValL2VK1NBJWe0iPW8/JOVfKQTSt6KtfQJr8ir5VAAvqTF1i 1swxQ2AregRelyW6fLRVvywUBOrdl6Nb8LyT3Nm0w9TNkMWhCBHRKVR8QncD/If1HAkY cBIh2KqrqUDRuBenOBNGsZ045fSzDS5I/tw9G+kOS8j7kNK5P84REFm96ykd9t0FurCs 9cDgzHvO+S3CR1ICOTFdFvz6Pgknlt0KLXzv/9WOYRWjuB1VoJyCpRWaGeh9Vnj201xr PwLJ6/F3BW3t5XRyxP/tfWfQBmmpcxrgSy115mGPhGE+dMaN0ckzGrvNxKxIs1DBOvsU MrFg== X-Gm-Message-State: APf1xPBY02CeduKHB2EprMpFucD5OYI7Ns3s0CVZrlBzvdrws1o8Vc6G hC4bnYZED5PQDlsQcx9TmJhz/nN7 X-Received: by 10.223.201.11 with SMTP id m11mr17350285wrh.146.1519129875858; Tue, 20 Feb 2018 04:31:15 -0800 (PST) Received: from ?IPv6:2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88? ([2a02:908:1251:8fc0:4c6d:7233:b7e1:3b88]) by smtp.gmail.com with ESMTPSA id c37sm10544902wrg.66.2018.02.20.04.31.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 04:31:15 -0800 (PST) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH 1/3] locking/ww_mutex: cleanup lock->ctx usage in amdgpu To: christian.koenig@amd.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20180215141944.4332-1-christian.koenig@amd.com> <20180219152421.GQ22199@phenom.ffwll.local> <20180219161544.GY22199@phenom.ffwll.local> <2e696981-6b4a-e292-c16a-0f3477dbf8ce@gmail.com> <20180219164354.GB22199@phenom.ffwll.local> <20180220113318.GN22199@phenom.ffwll.local> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <9c0175bd-cd5e-e643-de9b-5b2f6b2449a1@gmail.com> Date: Tue, 20 Feb 2018 13:31:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180220113318.GN22199@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 20.02.2018 um 12:33 schrieb Daniel Vetter: > [SNIP] > Ah, so the ttm_ctx I've spotted was something entirely different and > doesn't contain the ww_acquire_ctx (I didn't check)? I'd assume you have > the same ctx passed around to everything in ttm, but if that doesn't exist > then we can indeed not annotate ww_mutex_trylock_ctx with the right ctx. Yes, exactly. I actually tried this approach, e.g. put the ww_acquire_context into the ttm_operation_context and then use that with ww_mutex_trylock_ctx. But a) that turned out to be to much hassle, e.g. at least amdgpu doesn't use a ww_acquire context in most cases. And b) it actually wasn't what I was looking for, e.g. I couldn't distinct between the trylocked BOs an everything else any more. >> [SNIP] >> But to me it actually looks more like that makes it unnecessary complicated. >> The use case in amdgpu which could only check the context isn't performance >> critical. > Oh I'm not worried about the runtime overhead at all, I'm worried about > conceptual clarity of this stuff. If you have a ctx there's no need to > also look at ->owner. > > Another idea: We drop the task argument from functions and go with the > following logic: > > ww_mutex_is_owner(lock, ctx) > { > if (ctx) > return lock->ctx == ctx; > else > return lock->owner == current; > } > > I think that would solve your use case, and gives us the neat interface > I'm aiming for. Kerneldoc can then explain what's happening for a NULL > ctx. Good point, going to adjust the patches this way and resend. Christian.