Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp667064qtb; Wed, 19 Oct 2022 11:37:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hcJ1HXYKzTzv1eKvXIzs8EF1oc0KTr4dEphe02VZr9PhJKVp+DPCX7i5XwAIUXr+shkhs X-Received: by 2002:a17:907:7d8e:b0:78d:ed30:643b with SMTP id oz14-20020a1709077d8e00b0078ded30643bmr7791796ejc.253.1666204661626; Wed, 19 Oct 2022 11:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666204661; cv=none; d=google.com; s=arc-20160816; b=IujcJr1xAOctkE+Nb7p3o6DrJ8wFMuczdpf6M7gYKx8qLro4297sihOfoKHG0UQNox QQxu4WbQ9/c6ulLYOnjBi6Tro+KT8LLyJWO6cIoxpmjxrhRAg18DQetJewwA0OqhgEcO c9QJjjoEoKh1z/NY0nmR9E7h4VLRyz23xEmX3R1Q+SdPzp6DP18PxtlZoGb3E4nIeLXy T2LE0VWodi087CiBQYO0ZTWAefA96rA49BieqNrelPVfV5YWe8xOomqN7v1xw1Eax7eB CIxetBcgW6adx4y4TxtZ8+UuoNPYzMnWXs9hiJ0LrUEm5W5lJfnFRJZ1u++RNUvNnZBV dSig== 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=tuHN3b8i9JjwlZv9qe3ZfNCpHXqhn1shZAywGh4qoXY=; b=ced2vgjU2X1NgvumfXiMwa0y8x2CofgKM6Ucjf4J3oOKfpBRT8piRpVnkMKTbtj2ma rGfw5Vj7vM8aTJhxrmu86jOXQvDC0s9kqL13Mij6XsDcrIgQkrXONM9QPIp8Hzgbttnj aams5y6Q94TKWkSfrmPRGNIxHIf4hRecTpylM7bcvMAAqa5k15X+8PLW0bKUGf/yuQBD 6JiH7fvhsnPre4DL3DDIA7bHEohKlpAvJYUJGjJtEkCv9WucR7Th7gZrH/nUcsEM8OmQ ZIcjWGQ/67emmVswdpaZNEBNfYsxdWExmCIxpkQu5T8xRjRkafm+OzDSRonrw3j8cn9m MA8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YT2wlRma; 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 z11-20020a170906714b00b0077f2c582561si11946847ejj.156.2022.10.19.11.37.13; Wed, 19 Oct 2022 11:37:41 -0700 (PDT) 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=YT2wlRma; 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 S231382AbiJSRe6 (ORCPT + 99 others); Wed, 19 Oct 2022 13:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbiJSReQ (ORCPT ); Wed, 19 Oct 2022 13:34:16 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E50AB1D345D; Wed, 19 Oct 2022 10:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666200850; x=1697736850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SCLxQXssqCGWpksvQ3lmggIlRVu0wTOV5RqTAwzpGxU=; b=YT2wlRmaNRcXW/JlKsOJWoWSF2xWdU1Gv+Qgjo6yjhwKvjZlBlPz/H1d FcIr8njPSKs6MoEnhsZKZmIw9sXoPM4vDcnWWwQzH7aJE2bagZyYes5d4 cpXpZl9z8GRTo3vUZfvr4uizNPe3iv7HwoMVTvTIkaKhlB+agwSMPdHT3 yyS5LfToopSOcYzFOTA1oJ85AGW0I3IZD+drSdzSSGIW1Lm2XH1+14hDQ PnLg+x3P+0fCo1qNBq9hPEK59+n04wgL3UVXw+5VsHVFf7kX1UiSARnHJ nedAlE7xk3G1WTptIunaKd+nBmfdIXhHVEhCWFp5CbUMVhtWaTHfvOVNR g==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="306474529" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="306474529" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 10:33:56 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="607204816" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="607204816" Received: from mjmcener-mobl1.amr.corp.intel.com (HELO localhost.localdomain) ([10.213.233.40]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 10:33:53 -0700 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 Subject: [RFC 11/17] drm: Add over budget signalling callback Date: Wed, 19 Oct 2022 18:32:48 +0100 Message-Id: <20221019173254.3361334-12-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019173254.3361334-1-tvrtko.ursulin@linux.intel.com> References: <20221019173254.3361334-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.5 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_HI,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 e0cadb5e5659..e36bc4333924 100644 --- a/drivers/gpu/drm/drm_cgroup.c +++ b/drivers/gpu/drm/drm_cgroup.c @@ -230,3 +230,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 f25e09ed5feb..7ad09fd0a404 100644 --- a/include/drm/drm_clients.h +++ b/include/drm/drm_clients.h @@ -38,5 +38,6 @@ static inline void drm_clients_migrate(struct drm_file *file_priv) unsigned int drm_pid_priority_levels(struct pid *pid, bool *non_uniform); void drm_pid_update_priority(struct pid *pid, int priority); 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 0f1802df01fe..07dec956ebfb 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -192,6 +192,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. + */ + void (*signal_budget) (struct drm_file *, u64 used, u64 budget); }; /** -- 2.34.1