From patchwork Wed Nov 9 16:11:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 17654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp424415wru; Wed, 9 Nov 2022 08:13:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM5hoUBQHGFn1JXGjc0m7vg3wvBNnapX+1avg/tRMiF6u66fQ6+VPy9ybu3yrfXRXEM7yOg2 X-Received: by 2002:a05:6402:27cf:b0:462:75b3:a277 with SMTP id c15-20020a05640227cf00b0046275b3a277mr63096375ede.175.1668010411924; Wed, 09 Nov 2022 08:13:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668010411; cv=none; d=google.com; s=arc-20160816; b=NV9zQCBg/qtjjIzEGxkdzdHkKObr3YL5kvEmn1MDK5NpuPVSy6vuf+LdRhUQYUZYXF HDW7AJ/7i3MgKtcZaLw9isy6GGgHplFDjAhx3JkmNspwBzWpbAE9L89CL/+qc8n1HAbD z0MHA7hGv4C84cTpaQHTbQr6RTsrQjDsceBRac4DlVe7/k3mwztppQdOW/bZaGGYjaRj Uxs2Fdo9o/oSc2n7UroD+TCsMtgCdtwwOvcDz+kGq0pJrRxszZfyFU7A5uH9A7mGIpOC nba+eeMy8OG8y7Reuh8ALmAwDtcW3/x912dQ/aHYH1pbWzSYfAM4NoJBIXmiIvakg8kq zcdA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm5-20020a170907948500b0073d6c0facdcsi17080251ejc.259.2022.11.09.08.13.07; Wed, 09 Nov 2022 08:13:31 -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 + 99 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_Marchesin?= , "T . J . Mercier" , Kenny.Ho@amd.com, =?utf-8?q?Chris?= =?utf-8?q?tian_K=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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749035685763786113?= X-GMAIL-MSGID: =?utf-8?q?1749035685763786113?= 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, +};