Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp569274img; Mon, 18 Mar 2019 09:18:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZ+9UepCoO1/AozJTPBnhBdMZhVUVLOg8e9C830z0tveIFg30FFOMvlBzIZxVVVEbUpZ0E X-Received: by 2002:a63:9246:: with SMTP id s6mr1868022pgn.316.1552925931841; Mon, 18 Mar 2019 09:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552925931; cv=none; d=google.com; s=arc-20160816; b=D7H0qH4cyBPOhR8SGxrGhyyVuYEx9ugL9dmlQJBJIvUQxwDXc6/dQmexN69vEmzuNa 0TbKFYQo1uIwpTcOszQ1OSQG5n42Q40vMWbmBpiU0kEonaJ8CEd93c7d6Kj0oocAr1zK Pzecrocgvb7iLgC9zHFNY54oWGYitn0hXEu+MSkZONP5UO2eYXC8uMLj0Vzxemopi6eF Dx71ZasDTWgyjO0oBVY814JvBPlM/NJ4X1fBSKsS6W3nsGjMOBbzLXKiH/uo41VQ4Ow6 bm33mSUI9L1/8ljS8DVUGu7K9vGftOU8qwUMKSeaiUAtNDq6f8AH2w8w7ySo5TR4MxH7 pDug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oM7GzbsX6BXcI27/2wLinFMr6i84e0pxvUNOIyDhlk0=; b=q8xlAvAzqAkHgUiv+4wbUpuSKIobPlS/pIq1iXHk7PHUQ5bPB3YfNEEfma9oWLa75b XswJmlEloALonmHlN3SzThPKIL+xmvgBiFvAf5p5+SKhS1WqjnwU4kgn7ncgcFCzG5Xl cUiRewbB7MO0dsui71bIiZalo+x0A0L9UpjlTNkfXo+BAa4evc0CPB2VQGbTAK8Meqvw ufpPvCh3106ItKFgEI3MHqO7lVfwxu4TVvcX7FpJEYFgNpfw5AomOUYuuz7ctL5fUE/P 4DXw8V161F8ZuUDryDijnmdbwqYJxhvSVc+Ss5B80IirdMX+JIUBfpASf9AW/wp9Xzag VU8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o3oDtvf8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p9si9447335pls.151.2019.03.18.09.18.36; Mon, 18 Mar 2019 09:18:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o3oDtvf8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727397AbfCRQRZ (ORCPT + 99 others); Mon, 18 Mar 2019 12:17:25 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:46877 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfCRQRZ (ORCPT ); Mon, 18 Mar 2019 12:17:25 -0400 Received: by mail-ot1-f67.google.com with SMTP id c18so14895801otl.13 for ; Mon, 18 Mar 2019 09:17:24 -0700 (PDT) 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=oM7GzbsX6BXcI27/2wLinFMr6i84e0pxvUNOIyDhlk0=; b=o3oDtvf83CZqt6RoVFvrJgraX8zxwpQgZl+XhQPBpdYxqIkuyS3O7M3v0h9IIPBKeO M47sODs4f9Ip2rzcYcApveumryjwS9D5bHyRsCoG/zXCCJYE0f4+qJYaBA7yXjTNFiCO JaQ6gkufwIVfhdlVoPmPj3frnaaJ5D3NSs7y2lJNry1FNoYAqpXIJ93j/EGysQn2gf5p rDeOkK5vVKPraqRYnzkVmpiY5upB13Il0JAgrL/ZYyLZTRXsn+sub9te1ae2jJtOrc/T KLdj1Yb0toMkewPetvXS7pl9LM4blWJZtD1TzYtRH6+fzPuGV447TVdXQDY22uKWzdPE jgPA== 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=oM7GzbsX6BXcI27/2wLinFMr6i84e0pxvUNOIyDhlk0=; b=jR/EON+rr8iwT7O15U1fAoPx5yXX05okTNg1VykI6dphsrGkJFW8Kipudhx9UWI+io p4Y4J885+GXe8O3kpF+u7+cO7rIZwfQ2vGaS6xyBF0oVXZtFsC5yuPEWlMnfOzp2GFYz F5YUBY4ke+/xi5imIlNh1MSAogvi4NzBiKezk8TCjz6+WBSDbTHQQ96LFsQQOrsxeKMn Rj9RemxQ1gqGexivMC0m0d09o7Xe5dvQqMdaR7zDxVrn/a1yuZP3F1mnWf4Ep4/TTtSQ kW4mLzRGZasP3rcNjV1YG2zbomAlfCs/GUrXEc1hDuxYpFTh/vBwf5TPSZgopqNL0g0F CR3Q== X-Gm-Message-State: APjAAAVd13FQ3jP9MJ3wiQJGjBZUuF6abomUZCL9OsO/R8sbGoj0uZXZ Od+/v1tU64/s7SQkyLaAof0r1SFL3hCAnJtR/4hbKw== X-Received: by 2002:a9d:ef4:: with SMTP id 107mr2959918otj.152.1552925844096; Mon, 18 Mar 2019 09:17:24 -0700 (PDT) MIME-Version: 1.0 References: <20190227035448.117169-1-fengc@google.com> In-Reply-To: From: Sumit Semwal Date: Mon, 18 Mar 2019 21:47:12 +0530 Message-ID: Subject: Re: [RFC dma-buf 0/3] Improve the dma-buf tracking To: Daniel Vetter Cc: Chenbo Feng , erickreyes@google.com, LKML , DRI mailing list , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On Fri, 15 Mar 2019 at 16:36, Daniel Vetter wrote: > > On Thu, Mar 14, 2019 at 6:49 PM Sumit Semwal wr= ote: > > > > Hello Chenbo,Thank you for your RFC series. > > > > On Wed, 27 Feb 2019 at 09:24, Chenbo Feng wrote: > > > > > > Currently, all dma-bufs share the same anonymous inode. While we can = count > > > how many dma-buf fds or mappings a process has, we can't get the size= of > > > the backing buffers or tell if two entries point to the same dma-buf.= And > > > in debugfs, we can get a per-buffer breakdown of size and reference c= ount, > > > but can't tell which processes are actually holding the references to= each > > > buffer. > > > > > > To resolve the issue above and provide better method for userspace to= track > > > the dma-buf usage across different processes, the following changes a= re > > > proposed in dma-buf kernel side. First of all, replace the singleton = inode > > > inside the dma-buf subsystem with a mini-filesystem, and assign each > > > dma-buf a unique inode out of this filesystem. With this change, cal= ling > > > stat(2) on each entry gives the caller a unique ID (st_ino), the buff= er's > > > size (st_size), and even the number of pages assigned to each dma-buf= fer. > > > Secoundly, add the inode information to /sys/kernel/debug/dma_buf/buf= info > > > so in the case where a buffer is mmap()ed into a process=E2=80=99s ad= dress space > > > but all remaining fds have been closed, we can still get the dma-buf > > > information and try to accociate it with the process by searching the > > > proc/pid/maps and looking for the corresponding inode number exposed = in > > > dma-buf debug fs. Thirdly, created an ioctl to assign names to dma-bu= fs > > > which lets userspace assign short names (e.g., "CAMERA") to buffers. = This > > > information can be extremely helpful for tracking and accounting shar= ed > > > buffers based on their usage and original purpose. Last but not least= , add > > > dma-buf information to /proc/pid/fdinfo by adding a show_fdinfo() han= dler > > > to dma_buf_file_operations. The handler will print the file_count and= name > > > of each buffer. > > > > In general, I think I like the idea as it contributes to a much more > > relevant usage analysis of dma-buf backed buffers. > > I will get to doing a more detailed review soon, but immediately, we > > might want to think a bit about the get/set_name IOCTLS - do we need > > to think of disallowing multiple renaming of buffers once they start > > getting used? It could otherwise make the whole metrics a lot > > confused? > > > > > > > > Greg Hackmann (3): > > > dma-buf: give each buffer a full-fledged inode > > > dma-buf: add DMA_BUF_{GET,SET}_NAME ioctls > > > dma-buf: add show_fdinfo handler > > I'm not seeing the patches, so just quick comment here: Some drivers > (at least vc4) already have the concept of buffer names. Would be neat > to integrate this between dma-buf and drm_gem in prime. > FYI, here's the patch series - https://patchwork.freedesktop.org/series/572= 82/ Best, Sumit. > Aside from that sounds like a good idea overall, but I can't see any deta= ils. > -Daniel > > > > > > > drivers/dma-buf/dma-buf.c | 121 ++++++++++++++++++++++++++++++++-= -- > > > include/linux/dma-buf.h | 5 +- > > > include/uapi/linux/dma-buf.h | 4 ++ > > > include/uapi/linux/magic.h | 1 + > > > 4 files changed, 122 insertions(+), 9 deletions(-) > > > > > > -- > > > 2.21.0.rc2.261.ga7da99ff1b-goog > > > > > > > Best, > > Sumit. > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch --=20 Thanks and regards, Sumit Semwal Linaro Consumer Group - Kernel Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs