Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp791310rwb; Wed, 9 Nov 2022 08:39:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7FitQN3ZFkMkSnvBUarfybGI01RdI8DTcaCOX0jkK2go1WmhE+J6L9sAQFYK7HkWUcTQim X-Received: by 2002:a17:907:971e:b0:78d:e7ed:7585 with SMTP id jg30-20020a170907971e00b0078de7ed7585mr9235567ejc.258.1668011943046; Wed, 09 Nov 2022 08:39:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668011943; cv=none; d=google.com; s=arc-20160816; b=hyrOjcmqsgKLuIVKJcEGtfyiHecTG2VNgOp8PTSLr1VWzny0tEg1EJ7GnbTUZnOlEN tusgQYpiKbZRU286lpdd6dj/j6IstkONOTohjl0Jq56QjBTxBNm783VcKsIKeA1cVW1W O3odwRReDyvIhMlT8elcBhsoLAC7q6CIOfIL2ZvAn+oBEHzmaZzDWMbKgf8T9gEzlZRc 8Lc1jzTd7aUaW/YKSXJdaQpimfJcPqRi9NTbfngmogGLyzoKqZ38Aa8NZYVx6FBirBWb ETwgXaE8qg1kNuU+GX7NSiNCD+57tBhwS63SFZpTAtBG9YSTH8fa3vJRz6Ex2u8px8La UsKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qRk4p2HbEZZ1OcHa4nFMXHCL9FPdAHTsrM1YRCQsiCY=; b=AiplfXaKp/of2rFQ9diS/r+lZQdfqAuy2VvfxGy+ePLyHcIhkaiQAAn+jECOayDJpw eggP9eV0UoWb3JOj9cwGUgYUmNqr3FBpNImTccUsd4ZJCY2zsncEL5hhnezJITMY/nK0 7KDSNSKv6ZvEItdkGUTHYub4iqeiwZFQbrszz5M8QVCjIejc8nqt8bRDVlfG165NaNe+ Mv6DsZj8B3fSiZoYEVQLUdSd0OquOVhGdK1ri9ZPxaMECI34RR8AF4L0fZzBW6FSPMvA Qm1C3YCKMH99VNcUhV2midOyY7fQLWp01rWk76dMQe7tqB5r+/gQmP91yveAeXU/cvFU 8iGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J0P364hW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020aa7d34d000000b00465f6a9fbb3si13928306edr.155.2022.11.09.08.38.41; Wed, 09 Nov 2022 08:39:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J0P364hW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbiKIQMV (ORCPT + 92 others); Wed, 9 Nov 2022 11:12:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbiKIQMP (ORCPT ); Wed, 9 Nov 2022 11:12:15 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD8322B0C; Wed, 9 Nov 2022 08:12:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668010330; x=1699546330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=65danGbq1zwJ9FB6InBTjiB49NsQltjw5lK60A9yBPk=; b=J0P364hWb86592KL1CS8EsMGK0mATqUa0Xg1FlNDgV9fbX1VhgB66VSE fnhK/6AWOg04EwCs5EtxDaghrImv7kfDOgTZQgdySJTdNGjuunbsrLqyv 36voFnS1RciyLsVcd20T4QgYnsmagpt+MSO/H864g92pgeOpsvzyljg8a f/wdeyeRxHtRWwxMoIywppisajGhlgSKOOd9BgsAUQio/THgQ0M81kvbW 6R1od1gXmr5+U/QvhuHB+DA2AVPj5sxsEr9AKg4hOk/0/hlVb/3mRor+l kmHLd8kSBQI4LMwfknGipNcCfabaiRogOx3jl/ev/MK6/2aR7H4hNdoUB A==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="290735959" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="290735959" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:12:09 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="811684393" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="811684393" Received: from smurnane-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.196.238]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:12:02 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Tejun Heo , Johannes Weiner , Zefan Li , Dave Airlie , Daniel Vetter , Rob Clark , =?UTF-8?q?St=C3=A9phane=20Marchesin?= , "T . J . Mercier" , Kenny.Ho@amd.com, =?UTF-8?q?Christian=20K=C3=B6nig?= , Brian Welty , Tvrtko Ursulin , Zack Rusin , linux-graphics-maintainer@vmware.com, Alex Deucher Subject: [RFC 02/13] drm: Track clients by tgid and not tid Date: Wed, 9 Nov 2022 16:11:30 +0000 Message-Id: <20221109161141.2987173-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109161141.2987173-1-tvrtko.ursulin@linux.intel.com> References: <20221109161141.2987173-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tvrtko Ursulin Thread group id (aka pid from userspace point of view) is a more interesting thing to show as an owner of a DRM fd, so track and show that instead of the thread id. In the next patch we will make the owner updated post file descriptor handover, which will also be tgid based to avoid ping-pong when multiple threads access the fd. Signed-off-by: Tvrtko Ursulin Cc: Zack Rusin Cc: linux-graphics-maintainer@vmware.com Cc: Alex Deucher Cc: "Christian König" --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/drm_debugfs.c | 4 ++-- drivers/gpu/drm/drm_file.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 8ef31d687ef3..4b940f8bd72b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -967,7 +967,7 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) * Therefore, we need to protect this ->comm access using RCU. */ rcu_read_lock(); - task = pid_task(file->pid, PIDTYPE_PID); + task = pid_task(file->pid, PIDTYPE_TGID); seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), task ? task->comm : ""); rcu_read_unlock(); diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index ee445f4605ba..42f657772025 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -80,7 +80,7 @@ static int drm_clients_info(struct seq_file *m, void *data) seq_printf(m, "%20s %5s %3s master a %5s %10s\n", "command", - "pid", + "tgid", "dev", "uid", "magic"); @@ -94,7 +94,7 @@ static int drm_clients_info(struct seq_file *m, void *data) bool is_current_master = drm_is_current_master(priv); rcu_read_lock(); /* locks pid_task()->comm */ - task = pid_task(priv->pid, PIDTYPE_PID); + task = pid_task(priv->pid, PIDTYPE_TGID); uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", task ? task->comm : "", diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index ba5041137b29..5cde5014cea1 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -156,7 +156,7 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor) if (!file) return ERR_PTR(-ENOMEM); - file->pid = get_pid(task_pid(current)); + file->pid = get_pid(task_tgid(current)); file->minor = minor; /* for compatibility root is always authenticated */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c index ce609e7d758f..f2985337aa53 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c @@ -260,7 +260,7 @@ static int vmw_debugfs_gem_info_show(struct seq_file *m, void *unused) * Therefore, we need to protect this ->comm access using RCU. */ rcu_read_lock(); - task = pid_task(file->pid, PIDTYPE_PID); + task = pid_task(file->pid, PIDTYPE_TGID); seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), task ? task->comm : ""); rcu_read_unlock(); -- 2.34.1