Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp599557rwb; Thu, 12 Jan 2023 09:49:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAyZhRjNk8rKyGmCpsBQoGN0VVKPmzwiPCOhOCe2Zbk9YMZmMk/m8LKNzryM2J4S5JRHJl X-Received: by 2002:a17:906:2c48:b0:862:1709:a06f with SMTP id f8-20020a1709062c4800b008621709a06fmr271395ejh.37.1673545747056; Thu, 12 Jan 2023 09:49:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673545747; cv=none; d=google.com; s=arc-20160816; b=KmY+O0KKvCS1wbA6681SITbwnFgEVMaQ4U4mQOIRTBJBBleBC8XPKgeBf5LE4B1Tvf 88SlrWMHk+YFkhLGT7tYDJdzt92JV0JyDaOrjtwSAwFmzuylJO+35AeQJ0Y98NhvcxTJ lliA5cQjOEN2/aa5BmAeAD6u5oZKm9Z4j9/GRUGGfGlWkYsWPRa5PvbnyOV8v+iEtxFR /P4mn7mMxy/6Vx4Q0+Z/GyiQ+czBtR4ZgSYjoRZMpl0fkFsFKzkFhZAftmHqettAbToO Zvwfdks/rvqqh5L3zO/jXsAzPHSjtotXScXMw7uwGhnPxR6oWF5Ud0eA8efhJJ1qTKmd UJ7g== 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=1jz1M7xOjkWvKh7JC8SglbFcNBMG+/84syQFCczswJQ=; b=SbJ71LYr4bcolwXu9ug1DMrxdcJGT9AlK9esZlxZF8ZTdkmhIfLtqgHdYzVWyOjJoM lymSXoSAyiJj2eDPV1OHO6Iz89HxjUlwalq7LV1HZ1RGXmkxOPJJhM3WST6b3/2uVZ6L n41Hx/VV5xlxXwLaAnwQXpW6mk7HJdIL5ZrL7QGm7vc60YjXKpVwI19oZyMYiqZd0Rau BYyD14TfsVFe5OqCAmQJwv1ioI8X/w5V357szzyLFRDEFh+LVGvxn5StiTJRed1nZ7IM 5TTbyDectI35CHQXDanZRyRpv3dje7cQemUtt6LT5OkcBMHxyg6STgLbkdvqKAZWG9T7 FCRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gr5YodDu; 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 hw20-20020a170907a0d400b0084cbf5552b3si14094272ejc.970.2023.01.12.09.48.54; Thu, 12 Jan 2023 09:49:07 -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=gr5YodDu; 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 S231246AbjALRg6 (ORCPT + 50 others); Thu, 12 Jan 2023 12:36:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbjALRgN (ORCPT ); Thu, 12 Jan 2023 12:36:13 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5E466B58B; Thu, 12 Jan 2023 08:57:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542675; x=1705078675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5tUTxI03m+NTLtcglmz0tTkp8uvuUcMX2wFEFmhnCZQ=; b=gr5YodDuerwBQpE/UJU3gArgEwRoR95cUhGIrKTfPRJSbXAZ9VyJhKLK YSsxEtfU2ghk+8vtG/4Ix0bppiM0Qn0HpbnkUG2xF2DY3+1Q7XaAfp9tZ T5uMKPiKacYagxDw5C+ZtW4LcBYOViaHbAfQTSMJCS21tOhJnwo2NAmpN Ua9mvST6mLSveY9ZCjbLAv/IKrMMEXO6+7BlXGdNUP5FlorYsAPUhnTnC mC5rUS0OPDKa+++egBp9syE3IIWygKDNYBqrewZrrq+c1y5qcctMaxuge ZedOwQ2PhCjZ7s2bcTmjjNPOqj52XBvOagFo3A6W37vMyoXR+zvL196pg w==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="325016371" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="325016371" 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:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="651232620" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="651232620" 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:34 -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 03/12] cgroup: Add the DRM cgroup controller Date: Thu, 12 Jan 2023 16:56:00 +0000 Message-Id: <20230112165609.1083270-4-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-Type: text/plain; charset=UTF-8 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 Skeleton controller without any functionality. Signed-off-by: Tvrtko Ursulin --- include/linux/cgroup_drm.h | 9 ++++++ include/linux/cgroup_subsys.h | 4 +++ init/Kconfig | 7 +++++ kernel/cgroup/Makefile | 1 + kernel/cgroup/drm.c | 59 +++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 include/linux/cgroup_drm.h create mode 100644 kernel/cgroup/drm.c diff --git a/include/linux/cgroup_drm.h b/include/linux/cgroup_drm.h new file mode 100644 index 000000000000..bf8abc6b8ebf --- /dev/null +++ b/include/linux/cgroup_drm.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2022 Intel Corporation + */ + +#ifndef _CGROUP_DRM_H +#define _CGROUP_DRM_H + +#endif /* _CGROUP_DRM_H */ diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h index 445235487230..49460494a010 100644 --- a/include/linux/cgroup_subsys.h +++ b/include/linux/cgroup_subsys.h @@ -65,6 +65,10 @@ SUBSYS(rdma) SUBSYS(misc) #endif +#if IS_ENABLED(CONFIG_CGROUP_DRM) +SUBSYS(drm) +#endif + /* * The following subsystems are not supported on the default hierarchy. */ diff --git a/init/Kconfig b/init/Kconfig index 7e5c3ddc341d..c5ace0d57007 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1089,6 +1089,13 @@ config CGROUP_RDMA Attaching processes with active RDMA resources to the cgroup hierarchy is allowed even if can cross the hierarchy's limit. +config CGROUP_DRM + bool "DRM controller" + help + Provides the DRM subsystem controller. + + ... + config CGROUP_FREEZER bool "Freezer controller" help diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile index 12f8457ad1f9..849bd2917477 100644 --- a/kernel/cgroup/Makefile +++ b/kernel/cgroup/Makefile @@ -6,4 +6,5 @@ obj-$(CONFIG_CGROUP_PIDS) += pids.o obj-$(CONFIG_CGROUP_RDMA) += rdma.o obj-$(CONFIG_CPUSETS) += cpuset.o obj-$(CONFIG_CGROUP_MISC) += misc.o +obj-$(CONFIG_CGROUP_DRM) += drm.o obj-$(CONFIG_CGROUP_DEBUG) += debug.o diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c new file mode 100644 index 000000000000..48a8d646a094 --- /dev/null +++ b/kernel/cgroup/drm.c @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2022 Intel Corporation + */ + +#include +#include +#include +#include + +struct drm_cgroup_state { + struct cgroup_subsys_state css; +}; + +struct drm_root_cgroup_state { + struct drm_cgroup_state drmcs; +}; + +static inline struct drm_cgroup_state * +css_to_drmcs(struct cgroup_subsys_state *css) +{ + return container_of(css, struct drm_cgroup_state, css); +} + +static struct drm_root_cgroup_state root_drmcs; + +static void drmcs_free(struct cgroup_subsys_state *css) +{ + if (css != &root_drmcs.drmcs.css) + kfree(css_to_drmcs(css)); +} + +static struct cgroup_subsys_state * +drmcs_alloc(struct cgroup_subsys_state *parent_css) +{ + struct drm_cgroup_state *drmcs; + + if (!parent_css) { + drmcs = &root_drmcs.drmcs; + } else { + drmcs = kzalloc(sizeof(*drmcs), GFP_KERNEL); + if (!drmcs) + return ERR_PTR(-ENOMEM); + } + + return &drmcs->css; +} + +struct cftype files[] = { + { } /* Zero entry terminates. */ +}; + +struct cgroup_subsys drm_cgrp_subsys = { + .css_alloc = drmcs_alloc, + .css_free = drmcs_free, + .early_init = false, + .legacy_cftypes = files, + .dfl_cftypes = files, +}; -- 2.34.1