Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp818724rwb; Wed, 26 Jul 2023 03:29:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlEiIZ2hQ8fKXn0sJA8QO7XTP+Z7h1z03ZVChKb8SRwGUdCeX6CTmtRypOLEXi6XlkZSXF+8 X-Received: by 2002:a05:6358:999e:b0:135:6d9:2399 with SMTP id j30-20020a056358999e00b0013506d92399mr1916613rwb.30.1690367362749; Wed, 26 Jul 2023 03:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690367362; cv=none; d=google.com; s=arc-20160816; b=Y6LFMTBL320cz+/SZ+fhfA+UVIg/9GOEoqrq+kPyLjX+V3ZKCRhl5B7e2xlwwmLOw+ rqiEiPjG/QYVl+E5YziVSQKGgueOhCQ4oZfgOIZV/BCC9KkROsoAgKDrk7ANKMYZBpAm SgCsI3z8zfDGjBv/ba0esqdgnu2My6ZCHWYSp4rM8skNiVFK2P4yBFDkpJU1QcQYBvda muFyFaGnODK27LT33a77sh5jI+lgZqD3jnzMgZ/hpj279+29ncc7402xXB5352XJTWgN Ysv9ZwtVlpiWoAQ+2KQ5ETSBG9wBPo3ZDl9qcxckPf5TcdikpbMs+d4/Vi+HQjtgFPu0 X6eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=JqAbp3LZguyHurILUtzyR9hbr66GIXP0pVbgnl2e3TU=; fh=9/fuJX2wmjIR8/Au+rtDLKAyGiP1APfezhMIdg3z/OM=; b=MoQbxjLhbXMamI3fuj8rFf4EUPKcZmXKRYHNYbZy10+LP793yn2NbCPkuhlSWusXhg S2wIJMcablDiH1/9lYzCw4jhxv3nnOqOZju96/wguIL6jlg45HF2cYROcraSYVK6x3gg 5d2cXWZamvT/DnZdPLbBXgc/aLE5PnUcuaS5yHTXBzfPosqX5ZeqbtnNUKsJOSrsNVfu 8gVCNKbeO+GhThbcZYeFXGSjiBpashcqyVMq4DDhaD/T9+PJcL9P9RG1uCVWxPAWasmX 6xaQ6RUbmb1sZYfCtVBManpqlrV6nuDJVHuNCRmhG58kfocs1rslDzd9YC9EBPpv5E+c wBqQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 k69-20020a638448000000b00563e0e86f17si1084628pgd.573.2023.07.26.03.29.10; Wed, 26 Jul 2023 03:29:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232892AbjGZKOe (ORCPT + 99 others); Wed, 26 Jul 2023 06:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjGZKOc (ORCPT ); Wed, 26 Jul 2023 06:14:32 -0400 Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF871995 for ; Wed, 26 Jul 2023 03:14:30 -0700 (PDT) Message-ID: Date: Wed, 26 Jul 2023 12:14:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 16/17] cgroup/drm: Expose memory stats Content-Language: en-US To: Tejun Heo , Tvrtko Ursulin Cc: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, 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?Christian_K=c3=b6nig?= , Brian Welty , Tvrtko Ursulin , Eero Tamminen References: <20230712114605.519432-1-tvrtko.ursulin@linux.intel.com> <20230712114605.519432-17-tvrtko.ursulin@linux.intel.com> From: Maarten Lankhorst In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Hey, On 2023-07-22 00:21, Tejun Heo wrote: > On Wed, Jul 12, 2023 at 12:46:04PM +0100, Tvrtko Ursulin wrote: >> $ cat drm.memory.stat >> card0 region=system total=12898304 shared=0 active=0 resident=12111872 purgeable=167936 >> card0 region=stolen-system total=0 shared=0 active=0 resident=0 purgeable=0 >> >> Data is generated on demand for simplicty of implementation ie. no running >> totals are kept or accounted during migrations and such. Various >> optimisations such as cheaper collection of data are possible but >> deliberately left out for now. >> >> Overall, the feature is deemed to be useful to container orchestration >> software (and manual management). >> >> Limits, either soft or hard, are not envisaged to be implemented on top of >> this approach due on demand nature of collecting the stats. > > So, yeah, if you want to add memory controls, we better think through how > the fd ownership migration should work. I've taken a look at the series, since I have been working on cgroup memory eviction. The scheduling stuff will work for i915, since it has a purely software execlist scheduler, but I don't think it will work for GuC (firmware) scheduling or other drivers that use the generic drm scheduler. For something like this, you would probably want it to work inside the drm scheduler first. Presumably, this can be done by setting a weight on each runqueue, and perhaps adding a callback to update one for a running queue. Calculating the weights hierarchically might be fun.. I have taken a look at how the rest of cgroup controllers change ownership when moved to a different cgroup, and the answer was: not at all. If we attempt to create the scheduler controls only on the first time the fd is used, you could probably get rid of all the tracking. This can be done very easily with the drm scheduler. WRT memory, I think the consensus is to track system memory like normal memory. Stolen memory doesn't need to be tracked. It's kernel only memory, used for internal bookkeeping only. The only time userspace can directly manipulate stolen memory, is by mapping the pinned initial framebuffer to its own address space. The only allocation it can do is when a framebuffer is displayed, and framebuffer compression creates some stolen memory. Userspace is not aware of this though, and has no way to manipulate those contents. Cheers, ~Maarten