Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1996703rda; Tue, 24 Oct 2023 09:12:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2osKVlNRG/BRRALSwP3TLR23gn4Ip7s6yQ56MJI5hY5XRq79t7/yup7sFup+2iCe8kEgB X-Received: by 2002:a17:902:eed5:b0:1c9:ccbc:4ca0 with SMTP id h21-20020a170902eed500b001c9ccbc4ca0mr8938537plb.68.1698163937058; Tue, 24 Oct 2023 09:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698163937; cv=none; d=google.com; s=arc-20160816; b=x3amNV5MIrbaFkgdoypnkf5fP8ISS+2vbt9LcAR6yOlvh0NzqWDLFyGUk1EUd/D+hU WZKVkAGMZDTT9fEMDD1bRswr7CH4gJrgQEIjPX1FVAPf+Iv33qq2Wdu6xXazZVMk62Bl y1/Fm9SwlHRsB1hfexyNMO5v7YHoQDhIeQrhZfBfn8fh0XC0zwzw4iIyfTsTR47RYbmv Px5pyni/a/6BDRY+yBbmvh4eIGpsMZ6/UU599OVSUDsqFlvslsAMqCLJvH4pouDa1BvG JSXOjJfqJmyt2ipmcEb0zwGQFtReIARC/U39OUiVQwExL/a9m2Q6bDyayePkQ79hltMr Iwnw== 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=/RgwBj1Ne77O8fwBXoqM1BwDqN3dAGz11FXQOrhmhRg=; fh=2HBAlzlAa9r6oEay2NbkpJS0xF7sQwPTpkwcUWUf5js=; b=ebQGSadQVQn8JmylRaWmXfizWDayD5s1nX+YgW+cOsJBKw92lsQHb3j8KGFO8cZdBy c+5LyPn5bPa5NtoMswhs2hSTHBFLHqDd9Vz7lSLEC1fNvtIf9PH5aJ8Iu2MCBGkRs81o WqqwBfJHQjiRTx9GzH4fHflBEdiSHgQ6fgxHWF4LTuuls7Wkf1zlII7n5pcs7slHrEJE kFuGHHbWhHZFhoR6RSDJSn2ZutBPjm3Um9VBp4lwknxx3IncFCpzCogo6qGAzRCa/4e+ nHPk+RYdl3gPo0IBKVdNofm2Gchen54/2IzpHJPPiEwBlbfuvqI6A1BpP+pqzYKYNezp an2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YznZcid9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q23-20020a170902bd9700b001c62e8c0a38si8611361pls.256.2023.10.24.09.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 09:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YznZcid9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 63B948050FB7; Tue, 24 Oct 2023 09:12:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343599AbjJXQMC (ORCPT + 99 others); Tue, 24 Oct 2023 12:12:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234875AbjJXQMB (ORCPT ); Tue, 24 Oct 2023 12:12:01 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D842112B; Tue, 24 Oct 2023 09:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698163917; x=1729699917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DDR9QYygtf/mqSlMDbJLfsleqL3tuJUQWKqqud2aweU=; b=YznZcid9SWgjMY5SsTi46/61eC/yrKSeHKwWWw1mPIyaOgWraHGtV8I5 1QRcU4GVQW01IPLK2h+whOxblUgYgFGbamWFbg/OaJeECMUMP3gbUujTO Q3e8UO4wHwAqHaYFB8NSyMAEKwvQo7bZfnxL3w3cYAx+XCEpn1LQXgWiP j2Hr3j3NonznX+T8yUqs5aaPjVJ6G+bGRou0rZOI6oyw3Br+e962deQh+ 7RfyaVFU06qeX67PfrZS28nK6WGeotntYFZeR+9Mz41bsbfGlqlI8P218 C7aIuQOygtKeoLEKofojnuDn6Mo/o1jsQiT6AJN/W55Ka/TdT/ECdKek3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="451328086" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="451328086" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 09:07:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="902237142" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="902237142" Received: from aidenbar-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.219.125]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 09:05:16 -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: [RFC 1/8] cgroup: Add the DRM cgroup controller Date: Tue, 24 Oct 2023 17:07:20 +0100 Message-Id: <20231024160727.282960-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231024160727.282960-1-tvrtko.ursulin@linux.intel.com> References: <20231024160727.282960-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=0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 24 Oct 2023 09:12:11 -0700 (PDT) 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 6d35728b94b2..ed8ffa444e37 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1066,6 +1066,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