Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp655309rwb; Thu, 12 Jan 2023 10:30:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyk3mkOYCLa/zue4XkyTRq5Y1bPLrtEZQfNleuL3wwY9tMPuA3sAGp3YbZMWQA6f4QBNGx X-Received: by 2002:a17:902:968d:b0:192:8d74:99e0 with SMTP id n13-20020a170902968d00b001928d7499e0mr51936288plp.4.1673548256394; Thu, 12 Jan 2023 10:30:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673548256; cv=none; d=google.com; s=arc-20160816; b=RvU+2o5tEUUfK+yFo49kD446HtzlCO1BaUlVr9z5+v5tD/lM4QmbcoGxh4qkf7stX4 gtU0aF1q0xsLUkRgD6ek9xSy1S72zSe6Yz97HwBZvBwxeJdG6tp+9bvMQ1WpPFniwKkR 81SrXe7WDRBE4J7Ozp9mXyjmMpWZQZczu88AnNt5BRVDdf56TpSaao0NeyHxigLkf9F2 ZxLfyMqCHflG/50QhvmrmHtqHzkJf5Wcb5dRuOeLWGP8qmrtoWk/r5nxyn1EIkpiY0T4 OrJKf3YCrN/4CTPcOOlv7FYFM1JSUkDBmr9ZwClRPzEt5xoWgXEl8dlPyUkid+R6t1mi 8JWg== 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=nQk05ytoRr3Ax9fHXv5q5hTnGBbqKwfszHoS1t6H1SA=; b=GXTnmg1l2Hw/Sm41OhgB29Kq2ob8Gr5Ih+rOfZZ6u2A2FK0fjT3ersvlOuHNIUeSyf xUPS6o+EsAdLM4NlTOhH9lE8zAMksgrbiGFsxlF4w9rXAz1WN4bR6cHmLzb5qP6GuLhr CY+HQ5GqfTrmL0VIxxqUQpVeBmRIZKL6AJM12G8ztXFoOr1WJ5k99YC0/y3aFMbkdb0q JtMk7i6E5A0CsR3ZdjL4VQoYYXW2XAp6ZZaBsn2m0WP1+o9kMJGp19YjJ+k9JhHbuw+N KtQNewY47PVLXFFbwlzkyQlPurcM/8CK45tMCidn4BtYVSmwcT1dzRd9HI8EktLs/UzC jH2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FD69GaTr; 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 t13-20020a170902e84d00b001944c51f9d6si5449314plg.123.2023.01.12.10.30.49; Thu, 12 Jan 2023 10:30:56 -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=FD69GaTr; 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 S234782AbjALRht (ORCPT + 50 others); Thu, 12 Jan 2023 12:37:49 -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: 8bit X-Spam-Status: No, score=-3.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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, 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 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 = 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 = + 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 u64 drm_pid_get_active_time_us(struct pid *pid); +void drm_pid_signal_budget(struct pid *pid, u64 usage, u64 budget); #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); }; /** -- 2.34.1