Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp339770ima; Fri, 15 Mar 2019 04:07:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqycZ88FMgUj/ZKGm1rrgEPCYd2cNDXW1O+1W/aPsfkZSfhg3C1udY0XzjDS6DVRwBO93/o0 X-Received: by 2002:a17:902:900a:: with SMTP id a10mr3632772plp.183.1552648064349; Fri, 15 Mar 2019 04:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552648064; cv=none; d=google.com; s=arc-20160816; b=JQz5XiF3g99r+zwVqw56P//wM0oeWbSK9bgcg7lDT8em7NA9yRX7+84rS6IegzU6aw Lbhszb05hwY268lg0AB/vwbsfnefwDSrnZicC6wJ42WIlgM94sGaFkEOyxXWeJseULfn jW7MvGNybS78gdkqXQbYex5grhn4gL6KFbmM65r84b4TJngoNSmxVAjK0Fen0iMIh+0Y AN60AFkdVgEYFhJf2qf+YEfHrwnieqYDPYBMiV4Pp2WdJ+OufpgwDdH8ESbWq4JBCRKb rorhflFflnVqjOe0jvHf1UHlg+2975V0j8/1uwCCVgSJwyKCsRjXOEsFCOnsH2Z+6Zhx GSzQ== 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=5vwE1mK2LrSVRCDcCWmkPt3eZILJfwhggvzcUc68doY=; b=rNzHM8BrhD5fBFsVZKxfEtQt6gMYszJaO1hYO6VsRnYroiysmZ/JlDEpS/Lf6+IaQp Jv0t/lBMYwksLIR9dWmZ9mUYQlSYs266fM4EfB8E/9ei3EacSak1ZM2bECC6AR9q11I0 6DCVYmRTlJZBSgfKNOLGQ30JIfhfzk2S+Ecz4EyVUT7Pg9lGU1kiVVol58bpitmCmBLW x0dlBW7wKWiHCdtfeZbNBAPB59coqZT5c+PaXnmQvfNNUf0Y/GMn1ycva9u7AVoB/0/2 7cnCxmcI35pF4faSZze5FLykPrnO8f/SAckW+yfAU/p6M2W5NsDLnkK7jGV4axrw4qYj AyGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=MbW34w26; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g90si1618317plb.51.2019.03.15.04.07.29; Fri, 15 Mar 2019 04:07:44 -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=@ffwll.ch header.s=google header.b=MbW34w26; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729005AbfCOLG2 (ORCPT + 99 others); Fri, 15 Mar 2019 07:06:28 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:53019 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbfCOLG2 (ORCPT ); Fri, 15 Mar 2019 07:06:28 -0400 Received: by mail-it1-f193.google.com with SMTP id g17so9545940ita.2 for ; Fri, 15 Mar 2019 04:06:27 -0700 (PDT) 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=5vwE1mK2LrSVRCDcCWmkPt3eZILJfwhggvzcUc68doY=; b=MbW34w26diimFJ2anjGBESlXtxkzKuUyyUAxk7NuBAtLSl6TRNnGaFQdTzp+IKX87K Z5B2DPw6w5GiS8HJcpCiZp4PhDpV0GXnLXxnyKoBPJweTY3fTgrv4y3msu4dENWlO/gT sisYwayO+IIXWyZByRiC8m5D8OqIoJ2N9TIFQ= 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=5vwE1mK2LrSVRCDcCWmkPt3eZILJfwhggvzcUc68doY=; b=eDfSFu3ZZZ0FX7mBWzLNdCWIRgkmnd5YL0wKpscj0JoOjcYxG/ZK8ZAT6OKyv5nd5d FyeYIPoEmwEgUQk4ctP1myNWZZ3MwOo0RQTtBb2aOsWjzvq49ylXTX6OYG9gUz+3BXBR 1Bo8TBkdd0pWPUbOc3LqUz4QqUFIaoWJscYINf3ILGfA1BA4TP3h3B+8+/iiQFTrRX2V uPSBIet13BiePuMAzRSFGBTeD3vZ3aHVcpR/jcHssQN0ArSk5VM+OFZB2CpvroaLN/Tq glRx0l6AcmPvqEcdKFE+L6QBI+/XQGjZJyuD4dPIxRqFlmxQi9f7a8GSUma//0wzMM2o mMiA== X-Gm-Message-State: APjAAAVhe0lQCL0txqEHrMqCU2Fy5LK4X7jHCRxcgGLutNIonvAbiaT2 aOS+LRj0RZIgCsFvLN3X5f+8LDmv7ZzYfTaFlAP2HA== X-Received: by 2002:a02:1ac3:: with SMTP id 186mr2042087jai.96.1552647987268; Fri, 15 Mar 2019 04:06:27 -0700 (PDT) MIME-Version: 1.0 References: <20190227035448.117169-1-fengc@google.com> In-Reply-To: From: Daniel Vetter Date: Fri, 15 Mar 2019 12:06:15 +0100 Message-ID: Subject: Re: [RFC dma-buf 0/3] Improve the dma-buf tracking To: Sumit Semwal 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 On Thu, Mar 14, 2019 at 6:49 PM Sumit Semwal wrot= e: > > 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 co= unt > > how many dma-buf fds or mappings a process has, we can't get the size o= f > > the backing buffers or tell if two entries point to the same dma-buf. A= nd > > in debugfs, we can get a per-buffer breakdown of size and reference cou= nt, > > but can't tell which processes are actually holding the references to e= ach > > buffer. > > > > To resolve the issue above and provide better method for userspace to t= rack > > the dma-buf usage across different processes, the following changes are > > proposed in dma-buf kernel side. First of all, replace the singleton in= ode > > inside the dma-buf subsystem with a mini-filesystem, and assign each > > dma-buf a unique inode out of this filesystem. With this change, calli= ng > > stat(2) on each entry gives the caller a unique ID (st_ino), the buffer= 's > > size (st_size), and even the number of pages assigned to each dma-buffe= r. > > Secoundly, add the inode information to /sys/kernel/debug/dma_buf/bufin= fo > > so in the case where a buffer is mmap()ed into a process=E2=80=99s addr= ess 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-bufs > > which lets userspace assign short names (e.g., "CAMERA") to buffers. Th= is > > information can be extremely helpful for tracking and accounting shared > > 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() handl= er > > to dma_buf_file_operations. The handler will print the file_count and n= ame > > 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. Aside from that sounds like a good idea overall, but I can't see any detail= s. -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 --=20 Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch