From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACD82C433F5 for ; Fri, 1 Apr 2022 18:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351345AbiDASnr (ORCPT ); Fri, 1 Apr 2022 14:43:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349997AbiDASnk (ORCPT ); Fri, 1 Apr 2022 14:43:40 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC3D9215936 for ; Fri, 1 Apr 2022 11:41:50 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id dr20so7599622ejc.6 for ; Fri, 01 Apr 2022 11:41:50 -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:content-transfer-encoding; bh=DLtOWenxXCw5vQfabcGIJp+Je2gVQjc6VzKW0XdhyiQ=; b=h+rLLWbMQ/iHnS5/pj19fhLvsaEM9Wtdy1qxj2U1tvLPMxqJCjQosFe2F24w4FuEik zSrjnDN8RVUqsGTehE0RLFU9iAnAgsZLy6+HaVFpgiQgyaH0bi2nNoUnW/PN++7erDWp RX2laVeByhssITiwvlf5JqxR9o7iIybqO73rq6iDBg0II0FI27oeey/L41eoch8FqdX9 HSLjysJJ9QsP1Keic9p/q3hcmxjndegS2Td9/sQ/qsgWCFS7CVf9el3ursRzkfzAihRs Haf70E3SoFpNKPytMrE2H1AsOY13tYTorkjDKu54Gzzinf56UPzglOwHHVZBMjHJCiR4 t3yQ== 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=DLtOWenxXCw5vQfabcGIJp+Je2gVQjc6VzKW0XdhyiQ=; b=ymAWtn8GFzugSV6mquWoehIvLej/VQlNFdUTrICCwlpOFSe+7zyiLmUQ+NRk39oa38 /82PVIDnP9qbBxzGRaB0GBLCebw2XhW9wlahOJ786KxNQaFGJSsWWDrequpq/PD3Yem6 jN40jeye/OQbiA/jJaZdnxghOfiusMxUc+HtGg+NUtW4W1NwLrRl1JjceAP1FyWJaqZo XYcsbo8JP4zzVNsokeQA3nFpLEd4puhqVXDnYp0RnQYuRda6LGW0p0H+vkQ2yIeZybq2 Ie7F6qywDJE9LiS2ts1ICXy6DhXAAexF6W1TlE1KjOROEUBVjG/ET524lMFQ2YsSZMnC 95Dg== X-Gm-Message-State: AOAM530nVJ7IOFh6eK+fUTYS/FxBvwSjYLqV4zcwZ/5iIGCGRzgvHncN ikgEnrTmlgso850qSrlmRuJpIYCTUKFMW//+hqWP+Q== X-Google-Smtp-Source: ABdhPJwrYPj1kC3SIVIUHr/U2Akla60gayN+BoFrbJkPw1P4im/SamWlkUSDfJabqc8psCgCaTuKJc519X3Csg6+YUY= X-Received: by 2002:a17:907:3eaa:b0:6df:b058:96a with SMTP id hs42-20020a1709073eaa00b006dfb058096amr1028056ejc.368.1648838508127; Fri, 01 Apr 2022 11:41:48 -0700 (PDT) MIME-Version: 1.0 References: <20220328035951.1817417-1-tjmercier@google.com> <20220328035951.1817417-6-tjmercier@google.com> <20220329152142.GA15794@blackbody.suse.cz> In-Reply-To: <20220329152142.GA15794@blackbody.suse.cz> From: "T.J. Mercier" Date: Fri, 1 Apr 2022 11:41:36 -0700 Message-ID: Subject: Re: [RFC v4 5/8] dmabuf: Add gpu cgroup charge transfer function To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , 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 , Shuah Khan , Kalesh Singh , Kenny.Ho@amd.com, Shuah Khan , 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, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 29, 2022 at 8:21 AM Michal Koutn=C3=BD wrote= : > > Hi. > > On Mon, Mar 28, 2022 at 03:59:44AM +0000, "T.J. Mercier" wrote: > > From: Hridya Valsaraju > > > > The dma_buf_charge_transfer function provides a way for processes to > > (s/dma_bug_charge_transfer/dma_bug_transfer_charge/) > Doh! Thanks. > > transfer charge of a buffer to a different process. This is essential > > for the cases where a central allocator process does allocations for > > various subsystems, hands over the fd to the client who requested the > > memory and drops all references to the allocated memory. > > I understood from [1] some buffers are backed by regular RAM. How are > these charges going to be transferred (if so)? > This link doesn't work for me, but I think you're referring to the discussion about your "RAM_backed_buffers" comment from March 23rd. I wanted to do a simple test to confirm my own understanding here, but that got delayed due to some problems on my end. Anyway the test I did goes like this: enable memcg and gpu cgoups tracking and run a process that allocates 100MiB of dmabufs. Observe memcg and gpu accounting values before and after the allocation. Before # cat memory.current gpu.memory.current 14909440 system 0 After # cat memory.current gpu.memory.current 48025600 system 104857600 So the memcg value increases by about 30 MiB while the gpu values increases by 100 MiB. This is with kmem enabled, and the /proc/maps file for this process indicates that the majority of that 30 MiB is kernel memory. I think this result shows that neither the kernel nor process memory overlap with the gpu cgroup tracking of these allocations. So despite the fact that these buffers are in main memory, they are allocated in a way that does not result in memcg attribution. (It looks to me like __GFP_ACCOUNT is not set for these.) > > Thanks, > Michal > > [1] > https://lore.kernel.org/r/CABdmKX2NSAKMC6rReMYfo2SSVNxEXcS466hk3qF6YFt-j-= +_NQ@mail.gmail.com