Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp585258pxb; Wed, 27 Jan 2021 15:54:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeVaC79Bxx+UVeLi+e8HOyoXo8eHkwruLWhjqkeVMTYSrfo4MMDN32qor6mG76rhkviKk3 X-Received: by 2002:a17:906:f895:: with SMTP id lg21mr8706394ejb.321.1611791668601; Wed, 27 Jan 2021 15:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611791668; cv=none; d=google.com; s=arc-20160816; b=debQB/kKKLo/6fVu5KMkxWHb2m6b/3ABkhViVzbn1uXK68GarmrlSdAgrTkcV2J440 7+UH1AqrroL0FSR6hCJAYcuDU445aN1gC7O7elyinpFG37OWYgqxDa/2PnS9wJCkScxO giF73bTmCan3n2Ot6b+M9FxdLEXGd+SB6YaWSvSkldLSrHI3wNCABZb0lIIwezq5XQN5 6nu8m+IseSCLIfyqOADfYB2oxMOCPQ+lPjSaVJUNi9SIUBMOB4/bBO0EKc3XI7IyWhyq n1lf9+5zNRf1SphWAxda1IRwNh+R/9MP2HQqQVmGCb+2569EyLp296Lb/2VU/1qbQbmV r3BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YkeVUau2+B2CPW5i/+mFb63TjwS79qtzS0WQRUk8KF0=; b=kENPINzrTJVVFs6ugAJpeN4Na9ScIsxCkv4ZW6q81fKUlWpqgWS5w+kk2xjShWGn9g HKJoYhI9YndPQ7yACfGbe5qNCpFoumf1vsHNcXVhqnzUO9rAXwvHZGMsOXrJNk5NW4Xx pXESql0/9Uz2wmHB19zKai4ws8+FA+4/2XsgkuZxaGTu4DWDy+O5KLtKE2nvvPOgHUOy B1dP/BfKkCCq1z+BHDuY1ZBu77CB60tpAkl6bk5b1bthYwYsojqf5MhJM9LvsDhivt5s c2VThK+pByk44FG/YCT35kr6qe5Zqit2LD00X28Tx5vS/Jj/uxK7TJ6gsf2CryPvzY1f ywTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qDieFINu; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si1505909ejb.482.2021.01.27.15.54.03; Wed, 27 Jan 2021 15:54:28 -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=@linuxfoundation.org header.s=korg header.b=qDieFINu; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237596AbhA0MLC (ORCPT + 99 others); Wed, 27 Jan 2021 07:11:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:42484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237638AbhA0MHF (ORCPT ); Wed, 27 Jan 2021 07:07:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95D7920784; Wed, 27 Jan 2021 12:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611749184; bh=dVANB09LwALkp+sTk1/RHGXfqYtVo6LFn5maSabxK30=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qDieFINuIfQ5HlI+Q7d4qhudf9ZCuiTBRaas2DMe7dboSfmIU5iWI+Qev11I7Xil8 1ek08I89gKNZBTTj7gDXhuYErxetiuAhTydHkj1+ei+GCJl5hqUiIKCIsE3ht+Muml CLfsbz52X/gHRe7p5poUYUB6LM4yJOnB4UwjDXdA= Date: Wed, 27 Jan 2021 13:06:21 +0100 From: Greg KH To: Hridya Valsaraju Cc: Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kernel-team@android.com, john.stultz@linaro.org, surenb@google.com, hyesoo.yu@samsung.com, kernel test robot Subject: Re: [PATCH v3] dmabuf: Add the capability to expose DMA-BUF stats in sysfs Message-ID: References: <20210126204240.418297-1-hridya@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210126204240.418297-1-hridya@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 production, > 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 version: > 1) Each attachment is represented by its own directory to allow creating > 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?nig. > > [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 > --- > 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 addition > of other DMA-BUF-related sysfs stats in future. Based on feedback from > 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?nig. 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-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