Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38241598rwd; Wed, 12 Jul 2023 05:15:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/kJAmyD9DSsU1fVR5p7ToP7NTPGE6/sJbojZWKzM64qYEM0UnIdwXONqL0iT0S5y7VKsz X-Received: by 2002:a17:902:7c93:b0:1b8:4c8e:1885 with SMTP id y19-20020a1709027c9300b001b84c8e1885mr13958353pll.7.1689164108831; Wed, 12 Jul 2023 05:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689164108; cv=none; d=google.com; s=arc-20160816; b=qeHw0NI1bzH72rxzu6GcfeNs/zykOT0ZkAFugWrAJKPRK/x1sDcF/vhFi67PoA9soZ itQ++UvwhnGNchFGw4es+F7roHdBF0DeSp/RuFeG6D8iTsR3XuFziACJ4zdcXTVK7+Vn EI4p9TiI1VCdodDc3uO18Ynr4dZGRxCVAnqcaYKLNTc4NKpzmfCJX3LGI0rmZ9udcV73 +lRMp5Pm1EczfwdyFvx44LQQLm0t/K2+vf6xuStfK+QJcIln5BZHn82RKLYx22GP7nvz fYO4C/bHhoMax2ZlTFFx87Q8lMbAC8kr16E9lnSyopOArkvlz5Us9PkVAm69XgXsRvHK hDPg== 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=ij/DVNwSmDc4e+HjD7Vug9xColderAAwxhBmeT8hIe8=; fh=AB6ahJ7aRRWBRwaRRWg5ebNaiYUkpi/4N4/J23sBvbI=; b=y433M/OSlR2IaP/5pT9yLCsAd0S6Nlk2oAjzA1lsic7qK8WI5fr7O9aQZO7gJiATti n221uSyjQOCmYC8gGiQ1p1vlFngWZCRahuUxzmsjjQxtmw+y5kSBxmGYLnpv2Ea/6K66 ZBPdo8sFWG9m+1Y+mneYok/AkUteukG05YOIZZ+vP3NB2Gs7UNpwcOIqkTiqEeOLR53T UL0taYTsdqDcXnIemsQsgRb/vmEu8YxZCh6McvR8lWLtsPzqhVjiLfoVZ1+b/Qr6PKBV MftEAOasAOIho38rBgy9/vLAha7tckQexSd/z9kB0VZzivDiQFemgCGMz0M+PoZKtaZC 2F6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nAldYU3D; 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 kn3-20020a170903078300b001b89bd6fd59si3212309plb.215.2023.07.12.05.14.56; Wed, 12 Jul 2023 05:15:08 -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=nAldYU3D; 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 S233523AbjGLLuT (ORCPT + 99 others); Wed, 12 Jul 2023 07:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbjGLLtS (ORCPT ); Wed, 12 Jul 2023 07:49:18 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D90268C; Wed, 12 Jul 2023 04:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689162516; x=1720698516; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O0mT3fsjN9R6IJUDFQ9ilAS7HqsxTIefbDtvo5Oqvjw=; b=nAldYU3DSmXfinm9vKbIAqgGxrH1A2FmkxLd1Fn7MEv3EEvFCQ4kMQ89 V+GMvhZp9VNd00IM499v3jvOGPqASaY81hg3WgDU2u23Y0OpYnaUDfZHw iefDnewK640uqJzUmhNKr8yM0eu3TRV0Dk86XXl4mVinI0nlvbWIVX/Re 4TvDYllz77f9oe7tku6FHsAkYxh9whZ3W06UAvEMlEiOgv2+Qc23Tw3Wm YtjD7lNzvUytF2gGgr/kFetA4gGte1rHOLCfnnL4zDeLRxcTgz0lYbuEz VNZo90bIT7X7SctaU3Pk2Ldh6MPGts779zJ49U7/7TYIMoXtgyWaYKtlm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="344469184" X-IronPort-AV: E=Sophos;i="6.01,199,1684825200"; d="scan'208";a="344469184" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 04:46:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="866094109" X-IronPort-AV: E=Sophos;i="6.01,199,1684825200"; d="scan'208";a="866094109" Received: from eamonnob-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.237.202]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 04:46:40 -0700 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: [PATCH 07/17] cgroup: Add the DRM cgroup controller Date: Wed, 12 Jul 2023 12:45:55 +0100 Message-Id: <20230712114605.519432-8-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230712114605.519432-1-tvrtko.ursulin@linux.intel.com> References: <20230712114605.519432-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=-2.0 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_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 | 60 +++++++++++++++++++++++++++++++++++ 5 files changed, 81 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..8ef66a47619f --- /dev/null +++ b/include/linux/cgroup_drm.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2023 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 f7f65af4ee12..485cff856c0b 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1065,6 +1065,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..02c8eaa633d3 --- /dev/null +++ b/kernel/cgroup/drm.c @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2023 Intel Corporation + */ + +#include +#include +#include + +struct drm_cgroup_state { + struct cgroup_subsys_state css; +}; + +struct drm_root_cgroup_state { + struct drm_cgroup_state drmcs; +}; + +static struct drm_root_cgroup_state root_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 void drmcs_free(struct cgroup_subsys_state *css) +{ + struct drm_cgroup_state *drmcs = css_to_drmcs(css); + + if (drmcs != &root_drmcs.drmcs) + kfree(drmcs); +} + +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.39.2