Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1331686rwb; Fri, 28 Jul 2023 08:01:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlHCmCvhW0kNITCeBm41XY1y8mk/3w7SK5miRzLzeHmXc93ssteAVPpZ6aouWix0cy3ZbWEr X-Received: by 2002:aa7:915a:0:b0:666:6c01:2e9e with SMTP id 26-20020aa7915a000000b006666c012e9emr2224724pfi.15.1690556501794; Fri, 28 Jul 2023 08:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690556501; cv=none; d=google.com; s=arc-20160816; b=aH8Y4Gbc4Hwu7oZcRhBmS/EUQ2B/dg5485KHzegwvwcZVy8kWwIvhu1ex3NcB+0GOt lAocPu87KTLeYXTFMO+xEx+1Vk0N7gly6/gp2XRnDy+2BX+R+qZk8xIK9D4Kc8OmtOw7 1K674O+wDp5KTuAscerGzOdezwK3DAq6LGObJqR5IM1jSW7KBZ5rEqvsmwWoxWV6giCm ZDt+2gE70XDtlae6cBPeDPdv0A+bOgoyDPOH1C6YTfBxfzYGOr5+zRJ6vlJ20FVDudPy HqRlKbUvDL7gHb5GqEbnDxMQwlq+MYjz6+XgMrJ0O8JWpE6CGf53nsbIGKjvytmtQUD/ olcA== 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:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=Ro849C0jtMBgaki2fHFGRSzQ30ZtZqBl3bzKLcJW3B8=; fh=pnz/vJCHxoIxwl57s627ZFPZSEeBjiDOnxldeBBdgTU=; b=vmz0GpuUpSsXKFJRpXixSY0Bo35X5pjykPuPtENdgacBSwqV92cnJ/Pe6099DI9G7x lcM7iD7Fn0iY8UTznRefBL23xd5AKHEJo+O5cCc6zgN1Ua4+iazDLDNmjW5eADvmZxwu KCUBZr70uzYqeo3r1d1+kHsCTeglpcVqNArm3LMd/MVEufZarx0b7DR3fzcprWPuGZAJ vVVjMeK6ctEeaHvtiyIIiAkOpt3diWw38yF4USse5oEv7s+ysla2kEJgS2iOFtf8CkMP TJ7GdJAl3NRIRwf25bhgNPPc5/JwVjJOYkdl/IBELlr5r78rwQh2dtqk7qq+GtIvMYbR lekQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MMohJhwR; 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 o15-20020a63a80f000000b0055793097dbesi3109469pgf.469.2023.07.28.08.01.24; Fri, 28 Jul 2023 08:01:41 -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=MMohJhwR; 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 S236967AbjG1OPl (ORCPT + 99 others); Fri, 28 Jul 2023 10:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234453AbjG1OPk (ORCPT ); Fri, 28 Jul 2023 10:15:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B593A94; Fri, 28 Jul 2023 07:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690553739; x=1722089739; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=AZ/ocz0hEyx4b7zjwB+nv50Nb+TCW7LuxkGS/3Orf7M=; b=MMohJhwRXLC5sVZtoRZsxTLJc5rdelLxmOOy6SOJyzDlIyD0hSdwxYB8 bvLziTmxNWkWra1cyo/3T1Zl2YQBEnS9GQVf3IRqfKf9UF+lCR9m7dIY0 qVAw2n2nQ+YgISJY7W9mY8g3ikXbrOEGUbxQUuQRHde4sMuInjKyFaUGF KteOn7qdUQO2+uOO3kV4Jo1Cn3g1JnBZoY8j0jGh/YUwjDG7K9J2h4SwT AfTCPtxmTbdjtI0WunbaDVbcxVXohz8qvGw9Oth4W/8zWBW2BbmxaRdyJ +OvRbXcNTcJC2t/hNE4e5tTDsGSSNp8ejkfwS2T9sMQbK/G5nDzN9vQFK A==; X-IronPort-AV: E=McAfee;i="6600,9927,10784"; a="454959091" X-IronPort-AV: E=Sophos;i="6.01,237,1684825200"; d="scan'208";a="454959091" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2023 07:15:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10784"; a="974085643" X-IronPort-AV: E=Sophos;i="6.01,237,1684825200"; d="scan'208";a="974085643" Received: from atoomey-mobl.amr.corp.intel.com (HELO [10.213.197.30]) ([10.213.197.30]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2023 07:15:31 -0700 Message-ID: <0d51725f-d4d3-ae75-1d14-e9816cb8d33c@linux.intel.com> Date: Fri, 28 Jul 2023 15:15:29 +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: [PATCH 16/17] cgroup/drm: Expose memory stats Content-Language: en-US From: Tvrtko Ursulin To: Maarten Lankhorst , Tejun Heo 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> <89d7181c-6830-ca6e-0c39-caa49d14d474@linux.intel.com> <5d65d387-2718-06c3-ee5d-8a7da6e3ddfd@linux.intel.com> Organization: Intel Corporation UK Plc In-Reply-To: <5d65d387-2718-06c3-ee5d-8a7da6e3ddfd@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 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_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 One additional thought on one sub-topic: On 27/07/2023 18:08, Tvrtko Ursulin wrote: [snip] >>>> 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.. >>> >>> It is not needed to work in drm scheduler first. In fact drm >>> scheduler based drivers can plug into what I have since it already >>> has the notion of scheduling priorities. >>> >>> They would only need to implement a hook which allow the cgroup >>> controller to query client GPU utilisation and another to received >>> the over budget signal. >>> >>> Amdgpu and msm AFAIK could be easy candidates because they both >>> support per client utilisation and priorities. >>> >>> Looks like I need to put all this info back into the cover letter. >>> >>> Also, hierarchic weights and time budgets are all already there. What >>> could be done later is make this all smarter and respect the time >>> budget with more precision. That would however, in many cases >>> including Intel, require co-operation with the firmware. In any case >>> it is only work in the implementation, while the cgroup control >>> interface remains the same. >>> >>>> 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. >>> >>> Can you send a CPU file descriptor from process A to process B and >>> have CPU usage belonging to process B show up in process' A cgroup, >>> or vice-versa? Nope, I am not making any sense, am I? My point being >>> it is not like-to-like, model is different. >>> >>> No ownership transfer would mean in wide deployments all GPU >>> utilisation would be assigned to Xorg and so there is no point to any >>> of this. No way to throttle a cgroup with un-important GPU clients >>> for instance. >> If you just grab the current process' cgroup when a drm_sched_entity >> is created, you don't have everything charged to X.org. No need for >> complicated ownership tracking in drm_file. The same equivalent should >> be done in i915 as well when a context is created as it's not using >> the drm scheduler. > > Okay so essentially nuking the concept of DRM clients belongs to one > cgroup and instead tracking at the context level. That is an interesting > idea. I suspect implementation could require somewhat generalizing the > concept of an "execution context", or at least expressing it via the DRM > cgroup controller. > > I can give this a spin, or at least some more detailed thought, once we > close on a few more details regarding charging in general. I didn't get much time to brainstorm this just yet, only one downside randomly came to mind later - with this approach for i915 we wouldn't correctly attribute any GPU activity done in the receiving process against our default contexts. Those would still be accounted to the sending process. How much problem in practice that would be remains to be investigated, including if it applies to other drivers too. If there is a good amount of deployed userspace which use the default context, then it would be a bit messy. Regards, Tvrtko *) For non DRM and non i915 people, default context is a GPU submission context implicitly created during the device node open. It always remains valid, including in the receiving process if SCM_RIGHTS is used.