Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp788430rwb; Wed, 9 Nov 2022 08:37:04 -0800 (PST) X-Google-Smtp-Source: AMsMyM7/0YsTrlHcc8MQkivlKjYgm2Bo8YkL5oRu9BOeR2hiqjVYB6m6xQagMho0yIjWq5XSO0ef X-Received: by 2002:a17:906:3750:b0:78d:bc56:8f22 with SMTP id e16-20020a170906375000b0078dbc568f22mr1299821ejc.256.1668011824314; Wed, 09 Nov 2022 08:37:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668011824; cv=none; d=google.com; s=arc-20160816; b=Lne+FKUp+q4W9UCv+s5pOKnWVM2+dSVeAmB8qjX/njvmFrr4KcaWIvl9gtn7Bp+zAE 4euE4I9vALsUEdZYIftDFSuteJMBDknSr+C1KforOCeUWekFkiT0ZzrWmGyKmc1zLIRy xdCH0BdVBic0kf8e+IfunFIS1xwG20364z5ifG/xa9grc7sERtx7+dAsckI2ZuLsd6n8 hllGUs8LbsKkyIcS8KbLwSMJnFIBYFX7KqbHesA3IbBuBbvK9dryXTnePvVna4QhQYU4 DUH9xrK5ILzzTa5QDH0ChdCh6D6LdyBRnA5NvT2j3Woq1RTFPrNp8ShSNuFUKemooNRi sXgw== 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=mJ/RjGQYjmHvoiSn91DMDt5Fn8MPQU1GeV6ZZ4CgEh8=; b=OkNcFf6/gd7j/McbtNqY2DTjoMxXhETPlF0HtiDGNrmuyQ0Wqs5zKVfziVbBBcc63q G/5Yrei8x7aSYB3X/X4r7HlFd0GxxQNeHqsp0zR+ZyfmPJ2bA1eaYSxiVEHXl5/BGG4X eX/fLXfCeXlTtuxY533I/M8pmEYouuuXWCPiAlrHGNyOVk9/zm8/3wxbUHcfYdf70jjW FjIP+xwIeQJlX9dg6NEDsKWHhlNPy4ORiPFzonyIhTsEiqTXi3OM4adOBJyDSSAJuv8C vnfjUSiT6jHxk3eXAdugD4hBtUn1nYtzZ2e5zWCRGzdW1MPw5N233JhYbiuhPvMzfyo8 ZwJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WTKMsaYJ; 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 wy8-20020a170906fe0800b0078334ccc570si14950187ejb.328.2022.11.09.08.36.41; Wed, 09 Nov 2022 08:37:04 -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=WTKMsaYJ; 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 S232087AbiKIQMZ (ORCPT + 93 others); Wed, 9 Nov 2022 11:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbiKIQMS (ORCPT ); Wed, 9 Nov 2022 11:12:18 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C654A22BC4; Wed, 9 Nov 2022 08:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668010334; x=1699546334; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2BMu5cQFprtCxtPp+oUiMxCkYO0RYwczmemKP8KDzJQ=; b=WTKMsaYJ0KnqM1xg3jzS6hlD5dGy951FBSilNa2goOgtiB84Q9IOC1MC Wf7EgABXbjbtyJiY/zQkNM1q5wrCeNC8soTSC6/r1suN6dSX2z5HLpc68 PcHiohgCp62NSr39OFYqa3NaHsW7RP1NW79Nxay4Qk4RXKl9kj7mGOGH3 XRUrYKUj3WoW2cNKCEPVXwbdr9K5mWX7e8L18ghPEp1SblHeYCv9iomfr mB3cuidkTFymGArlO6bHqiGC6eFxx97rPnv7YmkKCv92gspXlTcOJKueF 4SglUyBw9DXi6WtnOG6qWSINDFvfkyPdF98ZWirFYjub06yUPdZepXoiU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="312181332" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="312181332" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:12:13 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="811684449" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="811684449" Received: from smurnane-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.196.238]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:12:10 -0800 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 04/13] cgroup: Add the DRM cgroup controller Date: Wed, 9 Nov 2022 16:11:32 +0000 Message-Id: <20221109161141.2987173-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109161141.2987173-1-tvrtko.ursulin@linux.intel.com> References: <20221109161141.2987173-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.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 | 54 +++++++++++++++++++++++++++++++++++ 5 files changed, 75 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 abf65098f1b6..70c08f340961 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1087,6 +1087,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..b88c93661df3 --- /dev/null +++ b/kernel/cgroup/drm.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2022 Intel Corporation + */ + +#include +#include +#include +#include + +struct drm_cgroup_state { + struct cgroup_subsys_state css; +}; + +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) +{ + kfree(css_to_drmcs(css)); +} + +static struct drm_cgroup_state root_drmcs = { +}; + +static struct cgroup_subsys_state * +drmcs_alloc(struct cgroup_subsys_state *parent_css) +{ + struct drm_cgroup_state *drmcs; + + if (!parent_css) + return &root_drmcs.css; + + 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