From nobody Mon Sep 15 11:53:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50F7C63797 for ; Thu, 12 Jan 2023 17:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232016AbjALRhw (ORCPT ); Thu, 12 Jan 2023 12:37:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232767AbjALRgz (ORCPT ); Thu, 12 Jan 2023 12:36:55 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB84CBBC1; Thu, 12 Jan 2023 08:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542685; x=1705078685; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q3zWAjP64jG9FhONvHni1RwGOKYO5eUnyqNVQmfnHLs=; b=FD69GaTrYEYWrjXwtI6aqOn0roYSHPDbD5zS/FAc3g8+h9Ez9ydftMqV bk6Qlu/efBtqYCuwEMUvDrrhHWrp2Bh4gZ5dGRIh4zztuzaxycTs1UM4E NUdDDSoXkBNqSziPp2V79M9leELWWl0BGdvkeK19Gw85FOTs9xFdDyOtV 7J58RjFP2sdgFATZfz+sOZS6N9iqXkIqe/6OAlNaHKTQZKNyKXr6FxC7t TN1HoFfzBlhCGYpEheBZfqUe3/1uRB+/JcUo2CySgl5jsa6N9zH39kUOd xiLlHQddmSxghiiIcGD3C94ybN9cTC1iMotYJyMfq06jEcPb6FuU7THJ9 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="325016498" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="325016498" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:56:54 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="651232836" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="651232836" Received: from jacton-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.195.171]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:56:50 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@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 Subject: [RFC 07/12] drm/cgroup: Add over budget signalling callback Date: Thu, 12 Jan 2023 16:56:04 +0000 Message-Id: <20230112165609.1083270-8-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112165609.1083270-1-tvrtko.ursulin@linux.intel.com> References: <20230112165609.1083270-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tvrtko Ursulin Add a new callback via which the drm cgroup controller is notifying the drm core that a certain process is above its allotted GPU time. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/drm_cgroup.c | 21 +++++++++++++++++++++ include/drm/drm_clients.h | 1 + include/drm/drm_drv.h | 8 ++++++++ 3 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/drm_cgroup.c b/drivers/gpu/drm/drm_cgroup.c index bc1e34f1a552..ef951421bba6 100644 --- a/drivers/gpu/drm/drm_cgroup.c +++ b/drivers/gpu/drm/drm_cgroup.c @@ -162,3 +162,24 @@ u64 drm_pid_get_active_time_us(struct pid *pid) return total; } EXPORT_SYMBOL_GPL(drm_pid_get_active_time_us); + +void drm_pid_signal_budget(struct pid *pid, u64 usage, u64 budget) +{ + struct drm_pid_clients *clients; + + rcu_read_lock(); + clients =3D xa_load(&drm_pid_clients, (unsigned long)pid); + if (clients) { + struct drm_file *fpriv; + + list_for_each_entry_rcu(fpriv, &clients->file_list, clink) { + const struct drm_cgroup_ops *cg_ops =3D + fpriv->minor->dev->driver->cg_ops; + + if (cg_ops && cg_ops->signal_budget) + cg_ops->signal_budget(fpriv, usage, budget); + } + } + rcu_read_unlock(); +} +EXPORT_SYMBOL_GPL(drm_pid_signal_budget); diff --git a/include/drm/drm_clients.h b/include/drm/drm_clients.h index 7e0c0cf14f25..f3571caa35f8 100644 --- a/include/drm/drm_clients.h +++ b/include/drm/drm_clients.h @@ -42,5 +42,6 @@ drm_clients_migrate(struct drm_file *file_priv, #endif =20 u64 drm_pid_get_active_time_us(struct pid *pid); +void drm_pid_signal_budget(struct pid *pid, u64 usage, u64 budget); =20 #endif diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index f5f0e088e1fe..0945e562821a 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -174,6 +174,14 @@ struct drm_cgroup_ops { * Used by the DRM core when queried by the DRM cgroup controller. */ u64 (*active_time_us) (struct drm_file *); + + /** + * @signal_budget: + * + * Optional callback used by the DRM core to forward over/under GPU time + * messages sent by the DRM cgroup controller. + */ + int (*signal_budget) (struct drm_file *, u64 used, u64 budget); }; =20 /** --=20 2.34.1