Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp932120pxb; Thu, 28 Jan 2021 04:08:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyb6l0Ox888JXJUwoB0vpYKyeuHne4iHjuBxPufw3dY5RaMVKwXhdHULkWIBMDKr9cHlXxU X-Received: by 2002:a05:6402:ca9:: with SMTP id cn9mr13965735edb.208.1611835703484; Thu, 28 Jan 2021 04:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611835703; cv=none; d=google.com; s=arc-20160816; b=nwCc9jqgilxy38gWmrRfRFRhrM8a12/DYx9fPkGuO9+duEgKXnbdZU9uNDZRo7CUBy 1IrJmB+4JjYsmES8axAoiQxWTs/6NY4dYZulzt195OWH2yWULf8T6GPbsQZ+3vqkiHQc wKiNgCTab+HexYQXdbczzOv0hI4ffH2rhStsp5iw1AcnW5lt6eZETM+e57gFJszkEaaz nazZXCrt2seVrFeHYeymJUZth9QW0tcNSPXZqJ9RRGn9LH4UGZTyM+VPfTixZllPdKed J0qwtk5VY2y6gko8ZQvVvTQ59yyiUygH1lTeYvdOzHPwJvdC22D/5BqTQU2ZTw9b7CSg V1Ng== 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=zf1ySPanLvetljOt9qgQxmsEilLBns8xPwybgR85ftI=; b=EkktoGBu4cfE2Wokv4Fn0zOy/dm/TtWeeDERr3nhteWG5Aodzk1mvRMyMHJYjI7hwr v/QEFR3dZmhUikrHqzEgihpEK7oHaVO9z0p8LK+sPSdiiSLxiOQ+btu3WHtj9Zq3Os5W +zMQeBKLwFUCByf2wfr07JWzTOHQr+BAyV1aH09OQVXaZ2io5br6wt+0ue3aCCcTmDyq k3UpVvNDMty21YVije/RxwsTgizbX6SrfXb7xG9z6YGwEBRbyZPRuzlykxpB/sIJ+RWJ YlYs/tPrxZ6fbDSUgAowR9u3AM/83ppLlAYx5H+BHS3ffVvivt2JOSqjBthN5ky9mvOi wiaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aVSS9NeR; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk14si2883875edb.128.2021.01.28.04.07.57; Thu, 28 Jan 2021 04:08:23 -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=@linaro.org header.s=google header.b=aVSS9NeR; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231374AbhA1MFK (ORCPT + 99 others); Thu, 28 Jan 2021 07:05:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbhA1MEN (ORCPT ); Thu, 28 Jan 2021 07:04:13 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41BEC0613ED for ; Thu, 28 Jan 2021 04:03:32 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id r14so6011778ljc.2 for ; Thu, 28 Jan 2021 04:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zf1ySPanLvetljOt9qgQxmsEilLBns8xPwybgR85ftI=; b=aVSS9NeRyairw1rT+cVF7qopMxVBmNdPXma/Zlt8iNnlAJctcN76hRUHSEGD0idQb2 zYw8DehMHX0EuyLu3bi69YJSpvfjwtAm9MYShHhu9mEbJPEJuzGe49qwnoXKOF2jcVZe ln5X07khbAhAXNwJU+flYEz9iAguyMcwrfcHy9mjRZESZY644mUUW/P7d74egjjzcMPc 71uQKIMZFDoBbbnrLwST/ULL7r00XKa7oJFBx/y/TRGIGhR5vQUfPgTQyXJF9JzJvfJX jxAhvGcTMV06Uw6ENiuHuTf/tAOorwgScKj/MkMXOm4CEc8Q3L9oabBOXi2pfwEk4ga1 MB3w== 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=zf1ySPanLvetljOt9qgQxmsEilLBns8xPwybgR85ftI=; b=LbXzFU6iHHk+1W6jS7gIXiYIPu0QBAw6zskZBgSZGj8fTvuKF+6NxafWG0uChOYz50 ZqDPJxs67CfwXBPLlAOnQMa1rucIBgKAKwUp34y4KnKzknenS2aSQFj6YH+2oBadbZok 5ROGyNHKlL2+rXciH/ILCga08UiumN38S9hAFi739GAtcQPHh0SFjLCmdIubYpIva6wH GumajApD3rC4KT6G/vALFqoHlZQNm3c+ryRJ4j2yEvtXSvYf1zPG7tvTYottzrRytVwQ rSQH1izgWO3e6ufu1fN0kRS5ehY8ELo3BXWOn2G2DBL69OAEcR7xzB/hRhaMaMIPsW+P 53EA== X-Gm-Message-State: AOAM531E8OyNRIRHxUp+oQnyRyFfhTI2qYMPvrqTSTDk5NpvPDk3fdUB yW5emK8RoZ+hyiP6ca5eKV7H/u6FRolv7rhuwQZVGQ== X-Received: by 2002:a2e:3507:: with SMTP id z7mr7792289ljz.32.1611835411071; Thu, 28 Jan 2021 04:03:31 -0800 (PST) MIME-Version: 1.0 References: <20210126204240.418297-1-hridya@google.com> In-Reply-To: From: Sumit Semwal Date: Thu, 28 Jan 2021 17:33:19 +0530 Message-ID: Subject: Re: [Linaro-mm-sig] [PATCH v3] dmabuf: Add the capability to expose DMA-BUF stats in sysfs To: Christian Koenig Cc: kernel test robot , Suren Baghdasaryan , LKML , DRI mailing list , Linaro MM SIG , hyesoo.yu@samsung.com, John Stultz , Greg KH , Hridya Valsaraju , Android Kernel Team , "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, 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 wrot= e: > >> 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//de= vice > >>> /sys/kernel/dmabuf/buffers//attachments//ma= p_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 producti= on, > >>> 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 reports= . > >>> 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 system > >>> 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 read > >>> out the DMA-BUF statistics can be found at [3](suggested by John > >>> Stultz). > >>> > >>> The patch contains the following improvements over the previous versi= on: > >>> 1) Each attachment is represented by its own directory to allow creat= ing > >>> a symlink to the importing device and to also provide room for future > >>> 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 from > >>> Daniel Vetter and Christian K=C3=B6nig. > >>> > >>> [1]: https://lore.kernel.org/patchwork/patch/1088791/ > >>> [2]: https://android-review.googlesource.com/q/topic:%22dmabuf-sysfs%= 22+(status:open%20OR%20status:merged) > >>> [3]: https://android-review.googlesource.com/c/platform/system/memory= /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 some > 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. Daniel, do you still have objections around adding this patch in? > > 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 addit= ion > >>> of other DMA-BUF-related sysfs stats in future. Based on feedback fro= m > >>> Daniel Vetter. > >>> -Each attachment has its own directory to represent attaching devices= as > >>> symlinks and to introduce map_count as a separate file. Based on > >>> feedback from Daniel Vetter and Christian K=C3=B6nig. Thank you both! > >>> -Commit messages updated to point to userspace code in AOSP that will > >>> 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-bu= ffers > >>> 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 o= f > >> 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