Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1152758pxb; Sat, 15 Jan 2022 04:28:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSkzhnn7jzos4XJUxxz9y50O1j8ZM9TnitgAEVBRaQ84ebommIAeKBdhRz8869PNQ0sFO7 X-Received: by 2002:a17:907:162c:: with SMTP id hb44mr10673497ejc.546.1642249683946; Sat, 15 Jan 2022 04:28:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642249683; cv=none; d=google.com; s=arc-20160816; b=thZdD6VyEula4RbyYYJUZR1TsPw2nDt8PV3MBBTWOdCU7ODsQAHMZT7VjMSpY+Y9p/ GK7TCJ2kDr7HhFsT2D6leqQvUUCVI37G/30wYki8CdIjJB8VxcgEsvLcAc/8SLUDdERH 66CSRNOmsjKAK8+DJa/+1gCXNHx2fkI16YPJTF1LBTgIhhur3RqtD8DZwMZzn/WI1Pda soIrKj7NufG+FVIZKsefI1x/fHiQZk2IZuz5IgHtNpASqD2Rg4aiN9+yXJ+6whBrF+8B RO7rOB+0SQDqxoQQuIFJjvNBqXpIYFy/GTW1FaJ3/Mm8q+vOWFPCJfaNp1PiLJg+M017 DJYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=wG/PbGVmKjgf1eOd11ftVQTDqJEywAnSirRvk8YQoEA=; b=Ps9Xw15G/6w3+C/LtaikoSQI4hRgLHw4/yGu3w2F9CNqAO8sxYTjYfG1E2e/wzL/29 Umt0PyR4Q0cKdV1UNMvGAH84cVeFiP+JdeCV6+gKvpCMYmWu3+r0cOZ/qq/bXYoJtPA9 pP5CiNSac4788SsKY21XEpVJM17+IM7Tzc678OlJpbqf2ffI7pnnAMW1zRW53m/s9zwR 08jcTIy0uamwHzhEohBrNHSu31Pu0Er/VuIweQuwQ3pu/904FHxzOpFusPkC1f9mrEe2 qUu4Zo6pO3KuNDuvsQ5h/0yQmX9GPzHLwNReLCCW4ZqoVFF8cA6ipo5zy4AfxHM0KnvQ PFCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ra40WJSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si799730ejw.219.2022.01.15.04.27.39; Sat, 15 Jan 2022 04:28:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ra40WJSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231756AbiAOBG4 (ORCPT + 99 others); Fri, 14 Jan 2022 20:06:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbiAOBGz (ORCPT ); Fri, 14 Jan 2022 20:06:55 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F22C06173E for ; Fri, 14 Jan 2022 17:06:55 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id v66-20020a256145000000b006115377709aso21648070ybb.3 for ; Fri, 14 Jan 2022 17:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=wG/PbGVmKjgf1eOd11ftVQTDqJEywAnSirRvk8YQoEA=; b=ra40WJSnTd+Sg9D3TIvHREEZJO5QmFxwXzwakhy95Pj15AdCn96Rg7F+gGkzzdoPHL /LCXltr47kWOGGC4J/j+jKdN7xu6RyW7gUeuH5vavWrndAu7BzKurEIyahiOS6sTnazd kjhutzh5GjtqfNnBjsMi1N1OKm+eTNmejUCgViGcOUkB/EFui5twnu1ZKaXi21WPA1C7 hDv3dAKWpj1mixAwX1dUro0zgPo6Npzf7sXOSvaZIstusYMToZmeNzSzidVL3FAMroY6 HrShrnaUArO3g2alaInh2tQWQ8dpEbE6FBLnde1xIXMV4W2bjw4NgeUFBmdKReIihG44 DGmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=wG/PbGVmKjgf1eOd11ftVQTDqJEywAnSirRvk8YQoEA=; b=I2tTCpIyyG09IosKwnegRvNoZ3fMuV6UeX22UsqA2KPWURLOroj1Yj65q+oXuiWPpt KzqS4AxhUPZNXcNmVZ/kWfjojHwpL2iFI/CP/80kAY89HNW64a9Vtz9pE7fxadSqKt7E hoAMnyLp0SP6pXNUhm55JfrNySf3Bjf1rIHJCUfeCBBcmfvXMvHEQjV1ag/3ody4B0Qg qyeOxkKBWLpQxqM5J482tWZw7Sts5xX3FWDAfSmFZd/O1ie+DCScuABcCpyQezXR76uz WwneL2mDBLJ9sU3Lv7mehofI8ZxjB6u+LJo79CL52PsfhoMZ8T6gXDdQQZhCkRIm/vnX IzYg== X-Gm-Message-State: AOAM532HeOs4FJdxKQ+qs6wNCZPyaDwU0koIIyHaRO3DOyv6BLcbte0t uoPaMFcBVnhopShKvDcMTvUKjzuiDd8= X-Received: from hridya.mtv.corp.google.com ([2620:15c:211:200:5860:362a:3112:9d85]) (user=hridya job=sendgmr) by 2002:a25:874a:: with SMTP id e10mr15875623ybn.422.1642208814583; Fri, 14 Jan 2022 17:06:54 -0800 (PST) Date: Fri, 14 Jan 2022 17:05:58 -0800 Message-Id: <20220115010622.3185921-1-hridya@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [RFC 0/6] Proposal for a GPU cgroup controller From: Hridya Valsaraju To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Greg Kroah-Hartman , "=?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?=" , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , Suren Baghdasaryan , Sumit Semwal , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , Tejun Heo , Zefan Li , Johannes Weiner , Dave Airlie , Matthew Brost , Kenneth Graunke , Matthew Auld , Li Li , Marco Ballesio , Finn Behrens , Hang Lu , Wedson Almeida Filho , Masahiro Yamada , Andrew Morton , Nathan Chancellor , Kees Cook , Nick Desaulniers , Miguel Ojeda , Vipin Sharma , Chris Down , Daniel Borkmann , Vlastimil Babka , Arnd Bergmann , 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 Cc: Kenny.Ho@amd.com, daniels@collabora.com, kaleshsingh@google.com, tjmercier@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. History of the GPU cgroup controller ==================================== The GPU/DRM cgroup controller came into being when a consensus[1] was reached that the resources it tracked were unsuitable to be integrated 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 model 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@intel.com/ [3]: https://lore.kernel.org/amd-gfx/YCVOl8%2F87bqRSQei@phenom.ffwll.local/ Hridya Valsaraju (6): gpu: rfc: Proposal for a GPU cgroup controller cgroup: gpu: Add a cgroup controller for allocator attribution of GPU memory dmabuf: heaps: Use the GPU cgroup charge/uncharge APIs dma-buf: Add DMA-BUF exporter op to charge a DMA-BUF to a cgroup. dmabuf: system_heap: implement dma-buf op for GPU cgroup charge transfer android: binder: Add a buffer flag to relinquish ownership of fds Documentation/gpu/rfc/gpu-cgroup.rst | 192 +++++++++++++++++ Documentation/gpu/rfc/index.rst | 4 + drivers/android/binder.c | 32 +++ drivers/dma-buf/dma-heap.c | 27 +++ drivers/dma-buf/heaps/system_heap.c | 68 ++++++ include/linux/cgroup_gpu.h | 120 +++++++++++ include/linux/cgroup_subsys.h | 4 + include/linux/dma-buf.h | 18 ++ include/linux/dma-heap.h | 11 + include/uapi/linux/android/binder.h | 1 + init/Kconfig | 7 + kernel/cgroup/Makefile | 1 + kernel/cgroup/gpu.c | 305 +++++++++++++++++++++++++++ 13 files changed, 790 insertions(+) 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.34.1.703.g22d0c6ccf7-goog