Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4036280pxb; Mon, 1 Feb 2021 10:40:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMmEgpz22/uSHdqlT0bYayzzYJHjzTcvQvFPEYNhrB7znlzBM9tEfOXvcG1rBdPVD9Z8p3 X-Received: by 2002:a17:906:c05a:: with SMTP id bm26mr19939387ejb.288.1612204847499; Mon, 01 Feb 2021 10:40:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612204847; cv=none; d=google.com; s=arc-20160816; b=mIs1eZ+9wcOipR9xDZGzHEe8JhAa5hkOyNsYcSx15Pn0D7j/rJpSo/FDlFVmReP7ls QYqlW90gOd1EATGjoLM8TKTPJMe8wmSZ0OwG+ej3GhxBwwSrKjCEfTE0ghUomZ1h1lED /RYzGsZs6hm2S3iJ9MxoAlSOUxX4ItJ45gkRNRaZPEMXOZHXog807pb8fBD2mjwoKYGR 2NkhDQHOO+2cRztC4Cot6odsPa0ilICeWTneeavp+QbRlOyT8apGRwAnsqo3NptHlzt9 Dro8mAAkTM/K3jd06hLm9ngybqOFjMVo/ADqcasGlC4aueQFo1Dzwx8L73Z/VwQUchdL lA7A== 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=OK3/yMIGSV86DUvu0dfJ5TR43VEdRRr2kp7r5QmuJMg=; b=L7jRCL4eJIUpfTdSNeCdpcRBkcCdJnYlBMAFEEBXiGxrgoRNR1MkGTKoclAvXJ+2fp Lzx5695Od/ldj+Ddglxpy9rFtiYwd0Xe6cQJ2gcgR7IjnrVMjCWiiccMN5kclVT0O/6+ JxYVdJJMADMLM4qvYTdApPh5d8zxmDQ6/fx4RtkhsloP+axugT6QpTtuxP56gcvCgr3L 79svO3qcO9rGUG13FSaYOsObdztpHR6NlsOmamUu5zX9pQWJo1ksEePatNJEVgdSLgdB r+KoFn+DGzVanrgdryThdhRefZB/Pg+llrsQVmtvQsiHV5eucqGrMgrmlQ1sHOu12cbm ItTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=SqoymMDv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si11412945ejb.223.2021.02.01.10.40.19; Mon, 01 Feb 2021 10:40:47 -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=@ffwll.ch header.s=google header.b=SqoymMDv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbhBASje (ORCPT + 99 others); Mon, 1 Feb 2021 13:39:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232014AbhBASiK (ORCPT ); Mon, 1 Feb 2021 13:38:10 -0500 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4D4C061573 for ; Mon, 1 Feb 2021 10:37:30 -0800 (PST) Received: by mail-ot1-x329.google.com with SMTP id i30so17317679ota.6 for ; Mon, 01 Feb 2021 10:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=OK3/yMIGSV86DUvu0dfJ5TR43VEdRRr2kp7r5QmuJMg=; b=SqoymMDvywSVy60i1yydFlMnRr6P1zz7cWovIo5AorDgsrF4DGEc/PU3NRtCbAkjAL X6cAbWktocFq1320H7gStljcXXpuJ+un57AgMJDW/STkwFYzZbou6R71onFSn0S1+X0f VhQDGyf9DvwKspvxgiZ4u1+zZ8+izN6s6FD+Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OK3/yMIGSV86DUvu0dfJ5TR43VEdRRr2kp7r5QmuJMg=; b=FANr7ztGIL4SiATRHg5dvAh0TfqxiQZ7dn9sCHZBx0Srx3Bi1ZGiWtavJCerVux2IG PurErZ6ofICZyVhCvphf8VBrc+uWEX7230pTGGZbFGSKvbuOB61d1TRG6i1KPzgybYyH D9yZ8Xv2CtzAZzOiESXOQ+w06mKQ/C97uRXGoh+5X8kcUaGltLYk0uiPmNyk0pIGI40e V4au/RymS9ZQPBPtYochuhh6KjBj1v1MfPAQUEss0ykCj4t5uvfz86CU5rdtrxh/4aYx L1sw6MkQOHlIRWA3qsaGKIz77qf1yiytaLsFz884EYiWXiyi9HI4J/BVeT8lCj4B8smu 8wsQ== X-Gm-Message-State: AOAM530d4DgP8KqGvik9QQgIfOWKAgUlkoW4mPmg5wqG9osIFAbsMeUN CLtsdB3dnhx+3YS2nsecbZ/yMWI2JNLsrIKoYMd1DQ== X-Received: by 2002:a9d:6c96:: with SMTP id c22mr12345078otr.303.1612204649387; Mon, 01 Feb 2021 10:37:29 -0800 (PST) MIME-Version: 1.0 References: <20210126204240.418297-1-hridya@google.com> In-Reply-To: From: Daniel Vetter Date: Mon, 1 Feb 2021 19:37:18 +0100 Message-ID: Subject: Re: [Linaro-mm-sig] [PATCH v3] dmabuf: Add the capability to expose DMA-BUF stats in sysfs To: Sumit Semwal Cc: Christian Koenig , Android Kernel Team , kernel test robot , Greg KH , LKML , DRI mailing list , Linaro MM SIG , hyesoo.yu@samsung.com, Hridya Valsaraju , Suren Baghdasaryan , "open list:DMA BUFFER SHARING FRAMEWORK" 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 Thu, Jan 28, 2021 at 1:03 PM Sumit Semwal wrot= e: > > On Thu, 28 Jan 2021 at 17:23, Christian K=C3=B6nig > wrote: > > > > Am 28.01.21 um 12:00 schrieb Sumit Semwal: > > > Hi Hridya, > > > > > > On Wed, 27 Jan 2021 at 17:36, Greg KH wr= ote: > > >> On Tue, Jan 26, 2021 at 12:42:36PM -0800, Hridya Valsaraju wrote: > > >>> This patch allows statistics to be enabled for each DMA-BUF in > > >>> sysfs by enabling the config CONFIG_DMABUF_SYSFS_STATS. > > >>> > > >>> The following stats will be exposed by the interface: > > >>> > > >>> /sys/kernel/dmabuf/buffers//exporter_name > > >>> /sys/kernel/dmabuf/buffers//size > > >>> /sys/kernel/dmabuf/buffers//attachments//= device > > >>> /sys/kernel/dmabuf/buffers//attachments//= map_counter > > >>> > > >>> The inode_number is unique for each DMA-BUF and was added earlier [= 1] > > >>> in order to allow userspace to track DMA-BUF usage across different > > >>> processes. > > >>> > > >>> Currently, this information is exposed in > > >>> /sys/kernel/debug/dma_buf/bufinfo. > > >>> However, since debugfs is considered unsafe to be mounted in produc= tion, > > >>> it is being duplicated in sysfs. > > >>> > > >>> This information will be used to derive DMA-BUF > > >>> per-exporter stats and per-device usage stats for Android Bug repor= ts. > > >>> The corresponding userspace changes can be found at [2]. > > >>> Telemetry tools will also capture this information(along with other > > >>> memory metrics) periodically as well as on important events like a > > >>> foreground app kill (which might have been triggered by Low Memory > > >>> Killer). It will also contribute to provide a snapshot of the syste= m > > >>> memory usage on other events such as OOM kills and Application Not > > >>> Responding events. > > >>> > > >>> A shell script that can be run on a classic Linux environment to re= ad > > >>> out the DMA-BUF statistics can be found at [3](suggested by John > > >>> Stultz). > > >>> > > >>> The patch contains the following improvements over the previous ver= sion: > > >>> 1) Each attachment is represented by its own directory to allow cre= ating > > >>> a symlink to the importing device and to also provide room for futu= re > > >>> expansion. > > >>> 2) The number of distinct mappings of each attachment is exposed in= a > > >>> separate file. > > >>> 3) The per-buffer statistics are now in /sys/kernel/dmabuf/buffers > > >>> inorder to make the interface expandable in future. > > >>> > > >>> All of the improvements above are based on suggestions/feedback fro= m > > >>> Daniel Vetter and Christian K=C3=B6nig. > > >>> > > >>> [1]: https://lore.kernel.org/patchwork/patch/1088791/ > > >>> [2]: https://android-review.googlesource.com/q/topic:%22dmabuf-sysf= s%22+(status:open%20OR%20status:merged) > > >>> [3]: https://android-review.googlesource.com/c/platform/system/memo= ry/libmeminfo/+/1549734 > > >>> > > >>> Signed-off-by: Hridya Valsaraju > > >>> Reported-by: kernel test robot > > > Thanks for the patch! > > > > > > Christian: If you're satisfied with the explanation around not > > > directly embedding kobjects into the dma_buf and dma_buf_attachment > > > structs, then with Greg's r-b from sysfs PoV, I think we can merge it= . > > > Please let me know if you feel otherwise! > > > > From the technical side it looks clean to me, feel free to add my > > acked-by while pushing. > > > > But I would at least try to convince Daniel on the design. At least som= e > > of his concerns seems to be valid and keep in mind that we need to > > support this interface forever. > > Naturally. > > Since he didn't comment over Hridya's last clarification about the > tracepoints to track total GPU memory allocations being orthogonal to > this series, I assumed he agreed with it. The tracepoint being orthogonal didn't really look convincing to me, since I do expect we'll need that at a much more generic level, at allocators. Whether that's dma-buf heaps or in drm or wherever. And we probably also need that to somehow align with cgroups accounting. But I guess for this it should be easy to extend however we see fit, so retrofitting allocator sources and anything else we want/need for the overall gpu memory account shouldn't be a problem. Also, it's first, so the proof for showing it all works together is more on the tracepoints :-) > Daniel, do you still have objections around adding this patch in? Needs docs (especially the uapi I think would be useful to document), igt tests, that kind of stuff still I think? It's meant to be generic uapi across drivers, generally we're a pile stricter for that (and yes dma-buf heaps I think didn't do all that, so maybe there's an argument for doing this a bit more sloppy or at least "the testsuite is somewhere else"). But I think it would be good to have this all done. -Daniel > > > > > Regards, > > Christian. > > Best, > Sumit. > > > > > > > >>> --- > > >>> Changes in v3: > > >>> Fix a warning reported by the kernel test robot. > > >>> > > >>> Changes in v2: > > >>> -Move statistics to /sys/kernel/dmabuf/buffers in oder to allow add= ition > > >>> of other DMA-BUF-related sysfs stats in future. Based on feedback f= rom > > >>> Daniel Vetter. > > >>> -Each attachment has its own directory to represent attaching devic= es as > > >>> symlinks and to introduce map_count as a separate file. Based on > > >>> feedback from Daniel Vetter and Christian K=C3=B6nig. Thank you bot= h! > > >>> -Commit messages updated to point to userspace code in AOSP that wi= ll > > >>> read the DMA-BUF sysfs stats. > > >>> > > >>> > > >>> .../ABI/testing/sysfs-kernel-dmabuf-buffers | 52 ++++ > > >>> drivers/dma-buf/Kconfig | 11 + > > >>> drivers/dma-buf/Makefile | 1 + > > >>> drivers/dma-buf/dma-buf-sysfs-stats.c | 285 +++++++++++++= +++++ > > >>> drivers/dma-buf/dma-buf-sysfs-stats.h | 62 ++++ > > >>> drivers/dma-buf/dma-buf.c | 37 +++ > > >>> include/linux/dma-buf.h | 20 ++ > > >>> 7 files changed, 468 insertions(+) > > >>> create mode 100644 Documentation/ABI/testing/sysfs-kernel-dmabuf-= buffers > > >>> create mode 100644 drivers/dma-buf/dma-buf-sysfs-stats.c > > >>> create mode 100644 drivers/dma-buf/dma-buf-sysfs-stats.h > > >> I don't know the dma-buf code at all, but from a sysfs/kobject point= of > > >> view, this patch looks good to me: > > >> > > >> Reviewed-by: Greg Kroah-Hartman > > > Best, > > > Sumit. > > > _______________________________________________ > > > Linaro-mm-sig mailing list > > > Linaro-mm-sig@lists.linaro.org > > > https://lists.linaro.org/mailman/listinfo/linaro-mm-sig > > > > > -- > Thanks and regards, > > Sumit Semwal > Linaro Consumer Group - Tech Lead > Linaro.org =E2=94=82 Open source software for ARM SoCs > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch