Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp2516045pxb; Sat, 19 Feb 2022 13:58:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYW1RpEGoEqD0urT7NgazauVF4NSOF2UtAP9DH5PBy854/s8XOhnI4xaC/OZyUcVMpFfE+ X-Received: by 2002:a17:906:350d:b0:6b9:5871:8f34 with SMTP id r13-20020a170906350d00b006b958718f34mr10910677eja.493.1645307883229; Sat, 19 Feb 2022 13:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645307883; cv=none; d=google.com; s=arc-20160816; b=ofX3zouxjzwQ20vjCazQPbcv+6u1a/oPzHJZe3hiuyYKX1WnuD18g+H+QtSIPY/Jz+ KLfohkoY5DG1/1fJ4Sy2Uob293llHK5qimvQ/tCdghDmdUmUwjSpihHQDGamB7MU8IPJ 1vATWpXoJOh3/+f+DO0nqyaC8igzz3Dbmmka1Vyci2zRQlmPCsgxmUSOJuc5dF2MCwpy 2yO94Crfb64axkYgVenZy3QNFZXSbt1c1Jv5BqE62tL5yS1Dz9StLTOWkuruNB4tJIqD Cgsp639xfOajY9KE4QaVkjC/uNlHEdPsGkeBjIGmNjxjPz7zUigKqLY6zVBvtU/CawBa BJQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kFx5mVaEHwZpR1G+osdopjqc+OzJyT2vvM3+pSprCFk=; b=JFa7pWI0wzEiKS8TitOleKYlMvAROiHxLo/iulxljHvI7LOMSi1qPTCZ+jG7Tnr2ut ZqVvXfGsaF6nPAEIglfn+2LpHSOOrzzy+A1g+VLa1zr5z9tIv8TzxyvPUX/0AmDlvuu8 K7zoUPgtsh0lZOGc9veFejTtj7MrxDs5qRBuJfskShFaq4TyQVDiyDbrX5y+7hWQBCu+ WaPp7463dkmTv8r3lWPzdtE3Aj4XL4e5k/jI2BXpctRH4ikn/GkkWTOtEv57gQ0pttKj p9fU2x1wxKCd2+YvjBQTHGk1zS2gJtmm6HUOZCCqcLp3CPSdBgbp+bxu/6MoVwBkAO1Z m2AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EQ+kstcs; 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 5si5528553ejh.208.2022.02.19.13.57.40; Sat, 19 Feb 2022 13:58:03 -0800 (PST) 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=EQ+kstcs; 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 S236646AbiBRTNQ (ORCPT + 99 others); Fri, 18 Feb 2022 14:13:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236628AbiBRTNP (ORCPT ); Fri, 18 Feb 2022 14:13:15 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A6A84D9C2 for ; Fri, 18 Feb 2022 11:12:57 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id h15so146404edv.7 for ; Fri, 18 Feb 2022 11:12:57 -0800 (PST) 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:content-transfer-encoding; bh=kFx5mVaEHwZpR1G+osdopjqc+OzJyT2vvM3+pSprCFk=; b=EQ+kstcsfvyoiVxpZH4DOveKWuo8ZLZzYUIop0Vlthf3r2DTADG1kDnjLZlmhEiEk+ 6G1pQYgdE0Nh9wv/F/mr614cojFdmQRp2bm+wGYz7pZOcacHQguC10UzY7EM+1ffc44f Wm1l5TaMSkrezOOuca+rkd439a22duxj7f/9y8nVcQJWPTcyz8zTDf/7iz5H+ApzRhTQ NbqGdRr/U/H9RUKkTlGKY86fsffbY3C0Y3yyKrxlpGI6ol/qaBZxmLnCbHD8+AclEyv0 7/rPTsF6rq9ujxffbMlZt2i1zvBQfzL4TUlU49jq+ZYhmHm7rxl9MwWPEqQDFslXytJ8 Gf+w== 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:content-transfer-encoding; bh=kFx5mVaEHwZpR1G+osdopjqc+OzJyT2vvM3+pSprCFk=; b=RDBMTjts3TwdbWJL4aBZTVNbd9XjkzYLD2r3egjotwbAwGwQAiR0tysz/Ot5X72esd XeMJTaldrCFBxxgNJu1lY7edwGvgsA7yqaftlUgpIpocGZWcSNbPDsnMuf/bhBICmosY 3GSJhwr0hLKeF6J8KpBCV+X8ZsQMv92qedIJlst3FThbvYDKZRBVMOmgV/CAn05FiA6O /FO6++c+Y8NxVKSCgYlyuECMCNFh5dDPEtfiUW/n2+b/pU8UhwIFFx/HhpG3BXPRAXJM MoeizhNRq8N/dm8HSlS02ONNnhYZODFMCf40+eSh9FEsZVu1sI+C+dtgbO0PvCAkNWAq ojXw== X-Gm-Message-State: AOAM532NoowleiFhM5wbhZPMP6eO80GkYOFAyZntrcjpcNLeVscthFz5 +B99CZyHS+CjsDq+GNblHEwRLYsVALzuKYyOylOQZA== X-Received: by 2002:aa7:c0d0:0:b0:410:d576:8808 with SMTP id j16-20020aa7c0d0000000b00410d5768808mr9831902edp.340.1645211575981; Fri, 18 Feb 2022 11:12:55 -0800 (PST) MIME-Version: 1.0 References: <20220211161831.3493782-1-tjmercier@google.com> In-Reply-To: <20220211161831.3493782-1-tjmercier@google.com> From: "T.J. Mercier" Date: Fri, 18 Feb 2022 11:12:44 -0800 Message-ID: Subject: Re: [RFC v2 0/6] Proposal for a GPU cgroup controller To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , 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 , Tejun Heo , Zefan Li , Johannes Weiner Cc: Kalesh Singh , Kenny.Ho@amd.com, dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, Feb 11, 2022 at 8:18 AM T.J. Mercier wrote: > > This patch series revisits the proposal for a GPU cgroup controller to > track and limit memory allocations by various device/allocator > subsystems. The patch series also contains a simple prototype to > illustrate how Android intends to implement DMA-BUF allocator > attribution using the GPU cgroup controller. The prototype does not > include resource limit enforcements. > > Changelog: > > v2: > See the previous revision of this change submitted by Hridya Valsaraju > at: https://lore.kernel.org/all/20220115010622.3185921-1-hridya@google.co= m/ > > Move dma-buf cgroup charge transfer from a dma_buf_op defined by every > heap to a single dma-buf function for all heaps per Daniel Vetter and > Christian K=C3=B6nig. Pointers to struct gpucg and struct gpucg_device > tracking the current associations were added to the dma_buf struct to > achieve this. > > Fix incorrect Kconfig help section indentation per Randy Dunlap. > > History of the GPU cgroup controller > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > The GPU/DRM cgroup controller came into being when a consensus[1] > was reached that the resources it tracked were unsuitable to be integrate= d > into memcg. Originally, the proposed controller was specific to the DRM > subsystem and was intended to track GEM buffers and GPU-specific > resources[2]. In order to help establish a unified memory accounting mode= l > for all GPU and all related subsystems, Daniel Vetter put forth a > suggestion to move it out of the DRM subsystem so that it can be used by > other DMA-BUF exporters as well[3]. This RFC proposes an interface that > does the same. > > [1]: https://patchwork.kernel.org/project/dri-devel/cover/20190501140438.= 9506-1-brian.welty@intel.com/#22624705 > [2]: https://lore.kernel.org/amd-gfx/20210126214626.16260-1-brian.welty@i= ntel.com/ > [3]: https://lore.kernel.org/amd-gfx/YCVOl8%2F87bqRSQei@phenom.ffwll.loca= l/ > > T.J. Mercier (6): > gpu: rfc: Proposal for a GPU cgroup controller > cgroup: gpu: Add a cgroup controller for allocator attribution of GPU > memory > dmabuf: Use the GPU cgroup charge/uncharge APIs > dmabuf: heaps: export system_heap buffers with GPU cgroup charging > dmabuf: Add gpu cgroup charge transfer function > android: binder: Add a buffer flag to relinquish ownership of fds > > Documentation/gpu/rfc/gpu-cgroup.rst | 195 +++++++++++++++++ > Documentation/gpu/rfc/index.rst | 4 + > drivers/android/binder.c | 26 +++ > drivers/dma-buf/dma-buf.c | 100 +++++++++ > drivers/dma-buf/dma-heap.c | 27 +++ > drivers/dma-buf/heaps/system_heap.c | 3 + > include/linux/cgroup_gpu.h | 127 +++++++++++ > include/linux/cgroup_subsys.h | 4 + > include/linux/dma-buf.h | 22 +- > include/linux/dma-heap.h | 11 + > include/uapi/linux/android/binder.h | 1 + > init/Kconfig | 7 + > kernel/cgroup/Makefile | 1 + > kernel/cgroup/gpu.c | 304 +++++++++++++++++++++++++++ > 14 files changed, 830 insertions(+), 2 deletions(-) > create mode 100644 Documentation/gpu/rfc/gpu-cgroup.rst > create mode 100644 include/linux/cgroup_gpu.h > create mode 100644 kernel/cgroup/gpu.c > > -- > 2.35.1.265.g69c8d7142f-goog > Gentle nudge to GPU maintainers to please provide their feedback on this RFC. Thanks!