Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9384877rwp; Thu, 20 Jul 2023 04:17:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwfG/5d24D10THHVtw9bxbk3Z5mSoQ8YmGL/S4KITML5sog0scujmZ93rdJznRMFRml1IE X-Received: by 2002:a17:906:209d:b0:992:2f67:cd34 with SMTP id 29-20020a170906209d00b009922f67cd34mr5639228ejq.22.1689851872343; Thu, 20 Jul 2023 04:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689851872; cv=none; d=google.com; s=arc-20160816; b=dZjPa90a6YUJZHIm+pcfLbFn6UdztEmIVTvnbJ6OaUWvDSLjl4uPcc8FPjkrAmmwdS 3eLL7Hy/3ZtWMDSYozSaVfhR9PGp1hYYLcI/83LpWOfU6GPlY7cC5ccAM8mAWDWIrKwg m+e6dJUOJ4i/fvMFtj3OG9ApxAgT/HgqqKDASCNU8IA0mWnirWsNouFsfVnGJFTAbXQi kAqR66qQ7LjOscv9Eilq/f/kSTztfJRxYvT4JEx2WG0r1qNcGNvk2dOxMY9K5COhNkgn v6u3JqmDPRZ3nFn4xoiQrTvBO+7nZ3CT2lm2lLZhcwkFcLD6KbNWg2rT+V5XeBxt1GdW nfEQ== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=3QQTp2rXC6OyRfXOU7rAOwyjHCzy6Va5A728T5cH3KA=; fh=FCSHnmUKcTIqurhiKd7J3I6CH9+bJ4dhwAfRMj8fECE=; b=YbufcqzNX4yplMAfqnXfuTh74nnDSS0MTlPfyCZj5IuQsYxpAjnTvXWVx8OtAVa3yN cpNI8/UVoRvQC5PmGqJpVT1hX5TBbWjoCrXjzWwEYnZsxkuR42P2OYZyNURcYZrNNJMu 0wMtCZruQIksHpS76k1rnNDF04BfUbPT4epZrWu7vDP/6EGbF10JPkWE/JG3YyaS8DHd Ov5KcfNKz+z45COvX9qR3QLj6q/HIAHnkYbYZ7Yj4MAIwQV9Wp+uiy7NkFx2SmEJcNey fCZ9BsS4Q2LTUj5ngmvK+9P9Rhw6koY/IHUA3EnSD5QzonulhMzCorBB/rjVXCkdmpO2 mvOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cVnn+wme; 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 ga23-20020a170906b85700b00983f499fbd7si534724ejb.836.2023.07.20.04.17.27; Thu, 20 Jul 2023 04:17:52 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=cVnn+wme; 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 S230221AbjGTKzU (ORCPT + 99 others); Thu, 20 Jul 2023 06:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbjGTKzT (ORCPT ); Thu, 20 Jul 2023 06:55:19 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36FA61982; Thu, 20 Jul 2023 03:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689850518; x=1721386518; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=1nzPh2ldW7JFgjNWEhtnVlvHO52nCzC4d7AFlh05n7E=; b=cVnn+wmexiQEqOxlofbZGplFs6GulSrxjEtfvEJFbDlqGRKE537h5wSj yzaVbv9aIfs2grPxKeOYq+JVUuPXiTZQIxBwISyi5a/zpQ/Y56HcjoLyI uprlf2rKQalk9JBctkKiSB8CljYKZPwRhHXVniiEDr70Upz5EIZpTi6/3 zxqJXctyHggP7ToyltD+VsHwVl0g99nHZ/RSS93Wu1jkUbdQ1cwR2XJv7 EcAA7wZTZ/5MZ1dhOJ1HX31ZyYfSVUeFInLKQY+8zxW9WzEu/hUVyUwqG b2keXxaMj/cWpoWzBHMrBw3h109zoglbBsjXM+zyPf2X8BEt9sZDSd096 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="397574318" X-IronPort-AV: E=Sophos;i="6.01,218,1684825200"; d="scan'208";a="397574318" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 03:55:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10776"; a="727644776" X-IronPort-AV: E=Sophos;i="6.01,218,1684825200"; d="scan'208";a="727644776" Received: from ctuohy-mobl1.ger.corp.intel.com (HELO [10.213.193.21]) ([10.213.193.21]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 03:55:13 -0700 Message-ID: <95de5c1e-f03b-8fb7-b5ef-59ac7ca82f31@linux.intel.com> Date: Thu, 20 Jul 2023 11:55:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [RFC v5 00/17] DRM cgroup controller with scheduling control and memory stats Content-Language: en-US To: "T.J. Mercier" Cc: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, 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?= , 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> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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 Hi, On 19/07/2023 21:31, T.J. Mercier wrote: > On Wed, Jul 12, 2023 at 4:47 AM Tvrtko Ursulin > wrote: >> >> drm.memory.stat >> A nested file containing cumulative memory statistics for the whole >> sub-hierarchy, broken down into separate GPUs and separate memory >> regions supported by the latter. >> >> For example:: >> >> $ 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 >> >> Card designation corresponds to the DRM device names and multiple line >> entries can be present per card. >> >> Memory region names should be expected to be driver specific with the >> exception of 'system' which is standardised and applicable for GPUs >> which can operate on system memory buffers. >> >> Sub-keys 'resident' and 'purgeable' are optional. >> >> Per category region usage is reported in bytes. >> >> * Feedback from people interested in drm.active_us and drm.memory.stat is >> required to understand the use cases and their usefulness (of the fields). >> >> Memory stats are something which was easy to add to my series, since I was >> already working on the fdinfo memory stats patches, but the question is how >> useful it is. >> > Hi Tvrtko, > > I think this style of driver-defined categories for reporting of > memory could potentially allow us to eliminate the GPU memory tracking > tracepoint used on Android (gpu_mem_total). This would involve reading > drm.memory.stat at the root cgroup (I see it's currently disabled on I can put it available under root too, don't think there is any technical reason to not have it. In fact, now that I look at it again, memory.stat is present on root so that would align with my general guideline to keep the two as similar as possible. > the root), which means traversing the whole cgroup tree under the > cgroup lock to generate the values on-demand. This would be done > rarely, but I still wonder what the cost of that would turn out to be. Yeah that's ugly. I could eliminate cgroup_lock by being a bit smarter. Just didn't think it worth it for the RFC. Basically to account memory stats for any sub-tree I need the equivalent one struct drm_memory_stats per DRM device present in the hierarchy. So I could pre-allocate a few and restart if run out of spares, or something. They are really small so pre-allocating a good number, based on past state or something, should would good enough. Or even total number of DRM devices in a system as a pessimistic and safe option for most reasonable deployments. > The drm_memory_stats categories in the output don't seem like a big > value-add for this use-case, but no real objection to them being You mean the fact there are different categories is not a value add for your use case because you would only use one? The idea was to align 1:1 with DRM memory stats fdinfo and somewhat emulate how memory.stat also offers a breakdown. > there. I know it's called the DRM cgroup controller, but it'd be nice > if there were a way to make the mem tracking part work for any driver > that wishes to participate as many of our devices don't use a DRM > driver. But making that work doesn't look like it would fit very Ah that would be a challenge indeed to which I don't have any answers right now. Hm if you have a DRM device somewhere in the chain memory stats would still show up. Like if you had a dma-buf producer which is not a DRM driver, but then that buffer was imported by a DRM driver, it would show up in a cgroup. Or vice-versa. But if there aren't any in the whole chain then it would not. > cleanly into this controller, so I'll just shut up now. Not all all, good feedback! Regards, Tvrtko