From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84ED7C369C2 for ; Wed, 16 Apr 2025 14:25:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2722610E94F; Wed, 16 Apr 2025 14:25:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="WHy2i4VQ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id B631510E94C; Wed, 16 Apr 2025 14:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744813513; x=1776349513; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=RUUhMRaXCYfn5fwgQqSFNGmUVfLFJHpfpDzjR3hSwRQ=; b=WHy2i4VQsURUrmcaa0H+z3eRCgRljscfmrixtr6Fy4UWzSUwFhDx6MZ6 1qrh9AxNzkP3HNmpDl+TnHMO+p4jQVDCBnrgqdNfLoCkK6ELZC8j2HDF8 12mbFSIO/9uZcW1+ft/wVlujMM22iOQAQ/N7H24n86W5uqpyxoP6mjIXf wME7OnBCsfOBOuzLtbrJ8nPZ4RgejyRqk3Qxnw8/iUOdSSsZHL+kL9gjH RlIePqC7H+GR2aoxwAqBMhvWoHZyWNEIfBvEr1sEAVgOvr/+H05CHGATV XV7PKu3dfTTf0KLJus4Pch1pReEG/sCsD+V03XmykmZJGapVjIeYomLoi Q==; X-CSE-ConnectionGUID: ICGory94QsWlwk4J33BA+Q== X-CSE-MsgGUID: Xe8dqN9SRWKJ5PHCth0Gfw== X-IronPort-AV: E=McAfee;i="6700,10204,11405"; a="57000748" X-IronPort-AV: E=Sophos;i="6.15,216,1739865600"; d="scan'208";a="57000748" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2025 07:25:13 -0700 X-CSE-ConnectionGUID: LlBinjo4QGKYxHU6lkykPA== X-CSE-MsgGUID: yVO+/8vQQlKQ2OvfD9ZBKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,216,1739865600"; d="scan'208";a="130258233" Received: from unknown (HELO localhost) ([10.237.66.160]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2025 07:25:10 -0700 From: Jani Nikula To: Sunil Khatri , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Cc: Alex Deucher , Christian =?utf-8?Q?K=C3=B6n?= =?utf-8?Q?ig?= , Tvrtko Ursulin , Pierre-Eric Pelloux-Prayer , Sunil Khatri Subject: Re: [PATCH v4 1/5] drm: add macro drm_file_err to print process info In-Reply-To: <20250416133144.862023-1-sunil.khatri@amd.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20250416133144.862023-1-sunil.khatri@amd.com> Date: Wed, 16 Apr 2025 17:25:06 +0300 Message-ID: <87lds0p4jh.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Wed, 16 Apr 2025, Sunil Khatri wrote: > Add a drm helper macro which append the process information for > the drm_file over drm_err. > > Signed-off-by: Sunil Khatri > --- > include/drm/drm_file.h | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h > index 94d365b22505..5ae5ad1048fb 100644 > --- a/include/drm/drm_file.h > +++ b/include/drm/drm_file.h > @@ -37,6 +37,7 @@ > #include > > #include > +#include Not a fan of including drm_print.h everywhere that drm_file.h is included. We've been trying to get rid of this, and go the other way. It's really hard to manage dependencies when everything ends up including everything. > > struct dma_fence; > struct drm_file; > @@ -446,6 +447,46 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv) > return file_priv->minor->type == DRM_MINOR_ACCEL; > } > > +static struct task_struct *drm_task_lock(struct drm_file *file_priv) > + __attribute__((__maybe_unused)); inline is the keyword you're missing here, and that's why you've had to add maybe unused... > +static struct task_struct *drm_task_lock(struct drm_file *file_priv) > +{ > + struct task_struct *task; > + struct pid *pid; > + > + mutex_lock(&file_priv->client_name_lock); > + rcu_read_lock(); > + pid = rcu_dereference(file_priv->pid); > + task = pid_task(pid, PIDTYPE_TGID); > + return task; > +} > + > +static void drm_task_unlock(struct drm_file *file_priv) __attribute__((__maybe_unused)); > +static void drm_task_unlock(struct drm_file *file_priv) > +{ > + rcu_read_unlock(); > + mutex_unlock(&file_priv->client_name_lock); > +} ...but *why* are you inlining these? To make this header self-contained, I think you'd need to add maybe sched.h, pid.h, rcupdate.h, mutex.h, or something. I consider static inlines actively harmful if they force you to pull in a lot of other headers. > +/** > + * drm_file_err - Fill info string with process name and pid > + * @file_priv: context of interest for process name and pid > + * @fmt: prinf() like format string > + * > + * This update the user provided buffer with process > + * name and pid information for @file_priv > + */ > +#define drm_file_err(file_priv, fmt, ...) \ > + do { \ > + struct task_struct *task; \ > + struct drm_device *dev = file_priv->minor->dev; \ > + \ > + task = drm_task_lock(file_priv); \ > + drm_err(dev, "comm: %s pid: %d client: %s " fmt, \ > + task ? task->comm : "", task ? task->pid : 0, \ > + file_priv->client_name ?: "Unset", ##__VA_ARGS__); \ > + drm_task_unlock(file_priv); \ > + } while (0) > + For that matter, why is *this* inline? For debugs it makes a little more sense when it adds the function, but drm_err() doesn't. Make all of these real functions, no need to include drm_print.h, and everything is better. BR, Jani. > void drm_file_update_pid(struct drm_file *); > > struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id); -- Jani Nikula, Intel