From patchwork Tue Nov 20 18:58:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ho, Kenny" X-Patchwork-Id: 10691143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00FE15A4 for ; Tue, 20 Nov 2018 18:59:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2E972ACD3 for ; Tue, 20 Nov 2018 18:59:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D62312ACD5; Tue, 20 Nov 2018 18:59:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D32642ACD3 for ; Tue, 20 Nov 2018 18:59:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B93DC6E40F; Tue, 20 Nov 2018 18:59:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680054.outbound.protection.outlook.com [40.107.68.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31F626E375; Tue, 20 Nov 2018 18:59:00 +0000 (UTC) Received: from CY4PR1201CA0018.namprd12.prod.outlook.com (2603:10b6:910:16::28) by SN1PR12MB0752.namprd12.prod.outlook.com (2a01:111:e400:c45b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.21; Tue, 20 Nov 2018 18:58:58 +0000 Received: from BY2NAM03FT025.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::201) by CY4PR1201CA0018.outlook.office365.com (2603:10b6:910:16::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1361.14 via Frontend Transport; Tue, 20 Nov 2018 18:58:58 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by BY2NAM03FT025.mail.protection.outlook.com (10.152.84.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1339.10 via Frontend Transport; Tue, 20 Nov 2018 18:58:57 +0000 Received: from kho-5039A.amd.com (10.180.168.240) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.389.1; Tue, 20 Nov 2018 12:58:56 -0600 From: Kenny Ho To: , , , , , Subject: [PATCH RFC 1/5] cgroup: Introduce cgroup for drm subsystem Date: Tue, 20 Nov 2018 13:58:10 -0500 Message-ID: <20181120185814.13362-2-Kenny.Ho@amd.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120185814.13362-1-Kenny.Ho@amd.com> References: <20181120185814.13362-1-Kenny.Ho@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(136003)(39860400002)(2980300002)(428003)(199004)(189003)(126002)(2201001)(1076002)(476003)(575784001)(478600001)(2616005)(11346002)(97736004)(86362001)(446003)(104016004)(217873002)(14444005)(5024004)(186003)(26005)(77096007)(53936002)(39060400002)(50466002)(47776003)(48376002)(486006)(316002)(7696005)(51416003)(6346003)(2870700001)(76176011)(356004)(6666004)(305945005)(110136005)(53416004)(426003)(336012)(8936002)(68736007)(72206003)(105586002)(106466001)(81156014)(36756003)(2906002)(5660300001)(81166006)(8676002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0752; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT025; 1:HPwHI09rod2hzYpImCLbGhIIpQQ6FoBsnQayFkJeooJuZPoK4vow6RP4rG0ud6vLi7QppZey5JpSQwcdfeU0kWN0+m7OcOgWqwQZd6dUEND3eo0ArA++OjvPOIJojchn X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ebf9dc29-d0fb-4cdb-7ad9-08d64f1a39ed X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:SN1PR12MB0752; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0752; 3:GccYtE4F4q9fbHjwpPdkS1BJOksHTxzI/7JdUvP3abu3tbn0jGDrCdK2Nwk0kSCAMd+bfWTL4oyPxukG58Yh9IKqFDbiHc62ucdeXnpNhtdpwb1lDPNwKaItphtbQe7WQuz7Yuj5O6FL6fsnKVqIkbdll7lHI9uCisQW9uHF7UkUzaAooFleuKbRvorSnEu/K11cnkvQeom9t3n5aoH410+WAVZCb7F3yS0gZ1hvN501Le4o1JyfjMHXyMSEn6kV2G6HAGvtkC6IIOuPB+FHrkNBxnqOFIYdVlFJbz+7YN1QLEhlaknnwvLqVSPqZqWSSoECobZBsVH9hYJ0pvTlxCV4bgKnIaqjWsM5akkiw0w=; 25:bQmXOFdQcOn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Msbd117rHeNwLixJTckuet8lvcj/Z7Y1ePe2mNipYG4w84M+9+3+iG5XflTlBCFrco0jmZkj73mdGkqmLOLCUaYuRM+6Q/qbY2JH0x X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231442)(944501410)(52105112)(93006095)(93003095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:SN1PR12MB0752; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0752; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0752; 4:FFJUQNZXxr35239LFAsagD9pXD/Cif2MOtM0771cvivjzGdpesKPcHl65OUMi7OwFSIjj8r6piPalBEWmCaK9/OKIP1c5moC7abKd7M4a/+sPwbw5ZLMrz2kZhTMC6jbk5kYJ4qGyYpMe9KCskpHnKTJWSyK7Zf2RpCFeKB3HzcA+vkGQTpl/f16XNbu7+kPlbcF4vYPZboom2+xL9Uv7vNjhLBLO+R6ou+cERdaKnJW+9N7WozSc+UDdaPmxKUmT7E56smXktrXgd4q10bWkQ== X-Forefront-PRVS: 08626BE3A5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0752; 23:Vd2ELo04dbCj9a7sB9zoBRj9m4T1xNGAC8WbG+j3C?= 8mYEhIqWldl+f1LMNsxpbvl7M39eoLrfk4W6fLb8qUtv2MjvZ+6F/6G6n500URa4OX0AQsEqNQuy3wRd6MFt+CbMDMKnIRDogfDKBi0TcNXagn7xS/EHhRBuMiJD1uoZ8E6vxUl4G8IgpUsaOzo+NNaK5PE0SgXrXeDNJH2fXHVl0mHyN0zIcaUJF9b5PhDMc/tlmaJ01P6+85MzcI4y0+UxUNBWFkXMR/0qmq6k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2vi8fmFuSWxszDSmUsppRHiih3QIqUcsLHCWuvxJ6wPdr8ZSkGIS4d/2snr4/zsutJoQ443Aj5BNwq5HLdZckBf/Gi5kF/MVtDVg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0752; 20:6uT+orSZvM5t5I5JK755MgtE3yiSSAsMINOXFzQQX62qxZl7QPiYkUTcau6kF0UiqeIbuThBSiMm10ydS/KQFZfMSBDKbapok8L06sOJbY8qTbh0Ao9I0setJadx+ueLUrKIGkGwxN3j3wrO9F40ROoMEpMPcjE7w5/U/730yvrIQrL049DuzmaaMQtrHk+hXryZcRHs2ZF9i2T49dwjJ6brG4WFzvyk+LRHxCqMJuBkQGo1Hwhdq8Bs5zXryBE+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2018 18:58:57.7081 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebf9dc29-d0fb-4cdb-7ad9-08d64f1a39ed X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0752 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change-Id: I6830d3990f63f0c13abeba29b1d330cf28882831 Signed-off-by: Kenny Ho --- include/linux/cgroup_drm.h | 32 ++++++++++++++++++++++++ include/linux/cgroup_subsys.h | 4 +++ init/Kconfig | 5 ++++ kernel/cgroup/Makefile | 1 + kernel/cgroup/drm.c | 46 +++++++++++++++++++++++++++++++++++ 5 files changed, 88 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..79ab38b0f46d --- /dev/null +++ b/include/linux/cgroup_drm.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT + * Copyright 2018 Advanced Micro Devices, Inc. + */ +#ifndef _CGROUP_DRM_H +#define _CGROUP_DRM_H + +#ifdef CONFIG_CGROUP_DRM + +#include + +struct drmcgrp { + struct cgroup_subsys_state css; +}; + +static inline struct drmcgrp *css_drmcgrp(struct cgroup_subsys_state *css) +{ + return css ? container_of(css, struct drmcgrp, css) : NULL; +} + +static inline struct drmcgrp *get_drmcgrp(struct task_struct *task) +{ + return css_drmcgrp(task_get_css(task, drm_cgrp_id)); +} + + +static inline struct drmcgrp *parent_drmcgrp(struct drmcgrp *cg) +{ + return css_drmcgrp(cg->css.parent); +} + +#endif /* CONFIG_CGROUP_DRM */ +#endif /* _CGROUP_DRM_H */ diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h index acb77dcff3b4..ddedad809e8b 100644 --- a/include/linux/cgroup_subsys.h +++ b/include/linux/cgroup_subsys.h @@ -61,6 +61,10 @@ SUBSYS(pids) SUBSYS(rdma) #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 a4112e95724a..bee1e164443a 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -836,6 +836,11 @@ 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 (EXPERIMENTAL)" + help + Provides accounting and enforcement of resources in the DRM subsystem. + config CGROUP_FREEZER bool "Freezer controller" help diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile index bfcdae896122..6af14bd93050 100644 --- a/kernel/cgroup/Makefile +++ b/kernel/cgroup/Makefile @@ -4,5 +4,6 @@ obj-y := cgroup.o rstat.o namespace.o cgroup-v1.o obj-$(CONFIG_CGROUP_FREEZER) += freezer.o obj-$(CONFIG_CGROUP_PIDS) += pids.o obj-$(CONFIG_CGROUP_RDMA) += rdma.o +obj-$(CONFIG_CGROUP_DRM) += drm.o obj-$(CONFIG_CPUSETS) += cpuset.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..d9e194b9aead --- /dev/null +++ b/kernel/cgroup/drm.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: MIT +// Copyright 2018 Advanced Micro Devices, Inc. +#include +#include +#include + +static u64 drmcgrp_test_read(struct cgroup_subsys_state *css, + struct cftype *cft) +{ + return 88; +} + +static void drmcgrp_css_free(struct cgroup_subsys_state *css) +{ + struct drmcgrp *drmcgrp = css_drmcgrp(css); + + kfree(css_drmcgrp(css)); +} + +static struct cgroup_subsys_state * +drmcgrp_css_alloc(struct cgroup_subsys_state *parent_css) +{ + struct drmcgrp *drmcgrp; + + drmcgrp = kzalloc(sizeof(struct drmcgrp), GFP_KERNEL); + if (!drmcgrp) + return ERR_PTR(-ENOMEM); + + return &drmcgrp->css; +} + +struct cftype files[] = { + { + .name = "drm_test", + .read_u64 = drmcgrp_test_read, + }, + { } /* terminate */ +}; + +struct cgroup_subsys drm_cgrp_subsys = { + .css_alloc = drmcgrp_css_alloc, + .css_free = drmcgrp_css_free, + .early_init = false, + .legacy_cftypes = files, + .dfl_cftypes = files, +};