Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp799178iog; Fri, 24 Jun 2022 14:31:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vKjldrQP6ou1jvUICdGwiHKWecAUK9w7sYNavbY7gCGf8uIvRABCj97Aj2RI1t+FuwAEUN X-Received: by 2002:a05:6a00:1a0e:b0:523:1e7c:e26e with SMTP id g14-20020a056a001a0e00b005231e7ce26emr914179pfv.60.1656106318342; Fri, 24 Jun 2022 14:31:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656106318; cv=none; d=google.com; s=arc-20160816; b=Zu3iPX1feCgDfxrFyh/FX7xsRkaCp5Cm7C7Ib+mb9+sd0PJ106Wp/ee9S2ll4FtrR0 TLRBPtMELJ+d1mZmXZpxl8xzQA+EMhhqWTVcBM6165X7LijRAatCzh3w2yaXHkgQSsC8 hQBtbBWS+v84rb5jGeVIIbbtJF43qdbpo3lOGRXk574ba/NpZWpjqhBqxveoDtPKSoyA jKgiGlcdQL8rhx6swQaKgk3IyU3SeJgNsX068zUQg8Uxowz1F09335Y/fYBfIdFxc/Wt wyGcZqhl2nTdXrbFQ2WoNsngHtnnpmPUk1tbxFxJ5aM8rtpyR0MqyPgcQ2n9d48X0PHl Hd8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kOvhoEpSE/InAZniXEti7vxsLeyf1a5ZFLlDrYfEPAA=; b=Nik8SejzFqgKfIuwNb/nAvBHJkxKNSr29E4Ckz/nq+CG5g4ldS/RlhbeJoRlXg+kZv gC2bH3v2uVkCAP+4qfk/mbZXxOz+w7wJN8VPaPt+iY+V0cGzA0wj05VgK8D35c1ygBkX BNMSXRsvEG68NRJ0KHK1PbewdGGcig4JhVAZsvQ/x5OXVhQqq8ehq+qUxY8Ti48r711z Wu2ilzANeYPycL3sVjpcxNTVkE7yMt7pkyZVZ4nqpMqyYIWYXG275rxhRis3+HGOU/gh HczYrMFoLWY4K586G64WkCyatoUJTadeqRNYeIkkYG1xQPLc/Oq0Bu6DLpCpW4HWVQTT AP2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=M1hPxnJU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020aa79ac3000000b005255489198esi3939964pfp.24.2022.06.24.14.31.38; Fri, 24 Jun 2022 14:31:58 -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=@google.com header.s=20210112 header.b=M1hPxnJU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbiFXVSH (ORCPT + 99 others); Fri, 24 Jun 2022 17:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbiFXVSF (ORCPT ); Fri, 24 Jun 2022 17:18:05 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4971063DF for ; Fri, 24 Jun 2022 14:18:02 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id u12so7115453eja.8 for ; Fri, 24 Jun 2022 14:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kOvhoEpSE/InAZniXEti7vxsLeyf1a5ZFLlDrYfEPAA=; b=M1hPxnJUFy/KS9mddV1ZPCrOTUCJOFrbdOpyi7j0ftrXkyhBEEnYliwfUMRIJpc302 UerGSaJuJ0U+ZQOOBbu9YnTTWBPqzn6BGm20kcHK021zUKyUQcLbeROv76yKvkCA4wL5 TKPV/NeXPSFred9jnh+TebuOPhqPca6DgiiGGp4t7notg/0HrutadjdFHCaRzrR60/SS kEf+UPdtfuMWWyAGy3sWvPgk2BDAIWToAkVEoiSpYe94Nv1jd3nvOoAgAb/ln/G4XSiC GAFPYKei8IcLsfKWZvc/9gQfNai9RmMKWnJqWlZq+QZRlzREX3RhLKN999kWcpZY7b77 80Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kOvhoEpSE/InAZniXEti7vxsLeyf1a5ZFLlDrYfEPAA=; b=ahOeQ0ESiNX3lNbIdT0S3oBwbm0kEytPDHik+7ZSZ9aGuAkvHtQc9eKG5cOLxqwd53 9m1VmyvmMeKIJAon2FIXgmYqTS4H/wmO3UcuWrYwo8/MzIfm2+bR+wpFDqYxgtS6fa7p ABhtpxVQmSK+fA97D2REAHoNQGE26UOTjrq8oyO0CHhonKgD1KW1KFLlbotUxmS1+A5z 2RfcOf3/susUrUm6aUJQVXv4bB7YuAde9E5Un5MmNO8+cc7L3T9iPMet+3lh8hVCWhVG vaxBrNyapQ+OWC3LbESYUu8xhV2aeRlBwZ3wJXTEp+1OP3k3omp3/JneUSg/UA7tRhXI 8rTw== X-Gm-Message-State: AJIora+v64z1SJFETZGdA6jm2eWGXMIHhAaHFWYD90OUrxEYZwbaiv3n fzqOp+1f5XXXATQZ+UI70X+OIgcFoHsq18BUXKB5jQ== X-Received: by 2002:a17:907:d25:b0:711:ea61:63aa with SMTP id gn37-20020a1709070d2500b00711ea6163aamr992776ejc.584.1656105480525; Fri, 24 Jun 2022 14:18:00 -0700 (PDT) MIME-Version: 1.0 References: <81026ef07c1ce20f8673b75b17bab79a2b39c548.camel@ndufresne.ca> In-Reply-To: From: "T.J. Mercier" Date: Fri, 24 Jun 2022 14:17:49 -0700 Message-ID: Subject: Re: [PATCH v7 0/6] Proposal for a GPU cgroup controller To: John Stultz , "T.J. Mercier" , Tejun Heo , Nicolas Dufresne , Zefan Li , Johannes Weiner , Jonathan Corbet , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , Suren Baghdasaryan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , Shuah Khan , Carlos Llamas , Kalesh Singh , Kenny.Ho@amd.com, =?UTF-8?Q?Michal_Koutn=C3=BD?= , Shuah Khan , kernel-team@android.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kselftest@vger.kernel.org Cc: Daniel Vetter Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Fri, Jun 24, 2022 at 1:36 PM Daniel Vetter wrote: > > On Fri, Jun 24, 2022 at 01:32:45PM -0700, John Stultz wrote: > > On Fri, Jun 24, 2022 at 1:17 PM Daniel Vetter wrote: > > > > > > On Wed, Jun 15, 2022 at 10:31:21AM -0700, T.J. Mercier wrote: > > > > On Fri, May 20, 2022 at 9:25 AM T.J. Mercier wrote: > > > > > > > > > > On Fri, May 20, 2022 at 12:47 AM Tejun Heo wrote: > > > > > > > > > > > > Hello, > > > > > > > > > > > > On Tue, May 17, 2022 at 04:30:29PM -0700, T.J. Mercier wrote: > > > > > > > Thanks for your suggestion. This almost works. "dmabuf" as a key could > > > > > > > work, but I'd actually like to account for each heap. Since heaps can > > > > > > > be dynamically added, I can't accommodate every potential heap name by > > > > > > > hardcoding registrations in the misc controller. > > > > > > > > > > > > On its own, that's a pretty weak reason to be adding a separate gpu > > > > > > controller especially given that it doesn't really seem to be one with > > > > > > proper abstractions for gpu resources. We don't want to keep adding random > > > > > > keys to misc controller but can definitely add limited flexibility. What > > > > > > kind of keys do you need? > > > > > > > > > > > Well the dmabuf-from-heaps component of this is the initial use case. > > > > > I was envisioning we'd have additional keys as discussed here: > > > > > https://lore.kernel.org/lkml/20220328035951.1817417-1-tjmercier@google.com/T/#m82e5fe9d8674bb60160701e52dae4356fea2ddfa > > > > > So we'd end up with a well-defined core set of keys like "system", and > > > > > then drivers would be free to use their own keys for their own unique > > > > > purposes which could be complementary or orthogonal to the core set. > > > > > Yesterday I was talking with someone who is interested in limiting gpu > > > > > cores and bus IDs in addition to gpu memory. How to define core keys > > > > > is the part where it looks like there's trouble. > > > > > > > > > > For my use case it would be sufficient to have current and maximum > > > > > values for an arbitrary number of keys - one per heap. So the only > > > > > part missing from the misc controller (for my use case) is the ability > > > > > to register a new key at runtime as heaps are added. Instead of > > > > > keeping track of resources with enum misc_res_type, requesting a > > > > > resource handle/ID from the misc controller at runtime is what I think > > > > > would be required instead. > > > > > > > > > Quick update: I'm going to make an attempt to modify the misc > > > > controller to support a limited amount of dynamic resource > > > > registration/tracking in place of the new controller in this series. > > > > > > > > Thanks everyone for the feedback. > > > > > > Somehow I missed this entire chain here. > > > > > > I'm not a fan, because I'm kinda hoping we could finally unify gpu memory > > > account. Atm everyone just adds their one-off solution in a random corner: > > > - total tracking in misc cgroup controller > > > - dma-buf sysfs files (except apparently too slow so it'll get deleted > > > again) > > > - random other stuff on open device files os OOM killer can see it > > > > > > This doesn't look good. > > > > But I also think one could see it as "gpu memory" is the drm subsystem > > doing the same thing (in that it's artificially narrow to gpus). It > > seems we need something to account for buffers allocated by drivers, > > no matter which subsystem it was in (drm, v4l2, or networking or > > whatever). > > This is what the gpucg was. It wasn't called the dmabuf cg because we want > to account also memory of other types (e.g. drm gem buffer objects which > aren't exported), and I guess people didn't dare call it an xpu. > > But this was absolutely for a lot more than just "gpu drivers in drm". > Better names welcome. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch From an API perspective the two approaches (misc vs GPU) seem similar to me. Someone comes up with a name of a resource they want to track, and it's added as a key in a cgroup interface file as drivers register and perform accounting on that resource. Considering just the naming, what do you see as the appeal of a controller named GPU/XPU vs one named Misc? Folks seem to have assumptions about the type of resources a "GPU" controller should be tracking, and potentially also how different resources are grouped under a single resource name. So is your thought that non-graphics related accounting of the same sort should be using a differently named controller, even if that controller could have the same implementation? My thought is that the resource names should be as specific as possible to allow fine-grained accounting, and leave any grouping of resources to userspace. We can do that under any controller. If you'd like to see a separate controller for graphics related stuff... well that's what I was aiming for with the GPU cgroup controller. It's just that dmabufs from heaps are the first use-case wired up. I haven't put much time into the misc controller effort yet, and I'd still be happy to see the GPU controller accepted if we can agree about how it'd be used going forward. Daniel, I think you're in a great position to comment about this. :) If there's a place where the implementation is missing the mark, then let's change it. Are the controller and resource naming the only issues?