Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4710045pxu; Thu, 10 Dec 2020 03:40:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJykoZjQORWueka3X2xGW3lKp9hI5meazGpDNqZu/Z/xXhTyvy9yU/gb5m/pTtQVmiRCiH2G X-Received: by 2002:aa7:d459:: with SMTP id q25mr6234785edr.279.1607600402679; Thu, 10 Dec 2020 03:40:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607600402; cv=none; d=google.com; s=arc-20160816; b=xlaKunO3OW0Y5nQLQ2LT0a3xqTkbDvuHW99o9EhrRIyEaEDxTL+qIxFz7K/PofLLcR Z7ufwDd5W60m3kLD4h+e25i8E+t+bt/3Aw9W5rvhVP8m/IRzMxGsgrmwWsJ+pymXHKsP dm9pA1sS7atBm3V3GkjftxLHJaGCYNN7JUoQcQtA8XKUCSbawmnber9p26Org0XbNAxB fI7YEcEwL9+QZ+EDPSMnNrdLPSBevuhwdOKCqvSt2ReDO1FO/gkLWjhEtBU8sNLfZcN2 62JADfOOQxv2B0nMGzAvM+tISwL7neq5luTbDMyaFK648rVIHVp0BRoSb+I+sBTv/qvL iBnA== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=l92zaKGCsUqQ/gxEstrfL6NDn1q+kjEay4OgM6ksKek=; b=jlXiFYlCw3ir3vN+NbyW3y04vCkEVuojgF5+jXlQuVr5Ed9IBSsB3rSVitBTItijLP EQOHXINgFwBMJRXqH6t4nPtZ1AB/YkYNCaNz8lzLdinyLT31LFM5AmL8AQyuB2IlkMFi GeHk62KQ7mWLuCrhS19g44pwP0phH6BaE9ijz80Qi14Wkz15Vg1XJuUYC4Xx6PBpFR0K m0L9RDSWb9upqE67S62I/dmtwKFNNc1CQhcXXnBsMd0ReCfepK8B6inWhCJID9c4CC/X zDU/DzBxxD4lhqOxwG09NmKGlnQdy5oPosJLL2zMTs4HCZZzY6HJY/u4hZmf/GPJPX+g w4mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lZnohFRO; 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 e12si2353979eje.644.2020.12.10.03.39.40; Thu, 10 Dec 2020 03:40:02 -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=lZnohFRO; 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 S1727337AbgLJK2N (ORCPT + 99 others); Thu, 10 Dec 2020 05:28:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbgLJK2M (ORCPT ); Thu, 10 Dec 2020 05:28:12 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F863C0613CF for ; Thu, 10 Dec 2020 02:27:31 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id x22so4142765wmc.5 for ; Thu, 10 Dec 2020 02:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=l92zaKGCsUqQ/gxEstrfL6NDn1q+kjEay4OgM6ksKek=; b=lZnohFRO2aVOHIRtc3z7i6lGYCNLnPZdXaB3qWvhukrz58enBHe7EHIJSqX/nuzAHW yCJOYIELLDkG00HMP/i9sB90hTKotuEEX6XtZ6vbPgpiCE8od//LiE17cKbqsGFu6+WI k8DYSm7F76nBrjKCaWmwkM3P9FtvSoRRTYJ2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=l92zaKGCsUqQ/gxEstrfL6NDn1q+kjEay4OgM6ksKek=; b=cCr3LG3AyCbZP2BITFloflJOfzGiegP8vZVMG/PmLotTemZHUc9+zEkFHpvqSXQ/hy Lujm+QyS8HdVe/DRL3cBgOk14n93qQM1iXXL9C/0MVwyMiUyh02dBW4Zu0FIT8xSUh5j WlXDUXkh+ZVKg36KqNLGgG+4TvSdU7xM9EHao5NyqDgmVrC+Uw7xOmnkCcYlDdpHzKUm PJUdBhpNsVttqsMtYu5+s2tzRZJD0dgObaQavMJMZz32QHRtjCbm2A+qgEz1OPqrGlT2 gFGSCJjCPuIBvw05sKtm0/DWYwPNusseBuhSvaxn9mDzMMfxEtZ9aY3uOxihVQ05YBbK 78Aw== X-Gm-Message-State: AOAM530/YeatJ9s5VApVECjho8JIr1LunymvTx6PNbtNi/W/TTBctoVn HfhKv1oFhLTc/ujbWl4ahWburA== X-Received: by 2002:a1c:f405:: with SMTP id z5mr7288798wma.93.1607596050214; Thu, 10 Dec 2020 02:27:30 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id z64sm8259746wme.10.2020.12.10.02.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 02:27:29 -0800 (PST) Date: Thu, 10 Dec 2020 11:27:27 +0100 From: Daniel Vetter To: Greg KH Cc: Christian =?iso-8859-1?Q?K=F6nig?= , surenb@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Hridya Valsaraju , kernel-team@android.com, linux-media@vger.kernel.org Subject: Re: [PATCH] dmabuf: Add the capability to expose DMA-BUF stats in sysfs Message-ID: <20201210102727.GE401619@phenom.ffwll.local> Mail-Followup-To: Greg KH , Christian =?iso-8859-1?Q?K=F6nig?= , surenb@google.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Hridya Valsaraju , kernel-team@android.com, linux-media@vger.kernel.org References: <20201210044400.1080308-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: X-Operating-System: Linux phenom 5.7.0-1-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2020 at 11:10:45AM +0100, Greg KH wrote: > On Thu, Dec 10, 2020 at 10:58:50AM +0100, Christian K?nig wrote: > > In general a good idea, but I have a few concern/comments here. > > > > Am 10.12.20 um 05:43 schrieb Hridya Valsaraju: > > > 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//exporter_name > > > /sys/kernel/dmabuf//size > > > /sys/kernel/dmabuf//dev_map_info > > > > > > 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. > > > > Mhm, this makes it part of the UAPI. What is the justification for this? > > > > In other words do we really need those debug information in a production > > environment? > > Production environments seem to want to know who is using up memory :) This only shows shared memory, so it does smell a lot like $specific_issue and we're designing a narrow solution for that and then have to carry it forever. E.g. why is the list of attachments not a sysfs link? That's how we usually expose struct device * pointers in sysfs to userspace, not as a list of things. Furthermore we don't have the exporter device covered anywhere, how is that tracked? Yes Android just uses ion for all shared buffers, but that's not how all of linux userspace works. Then I guess there's the mmaps, you can fish them out of procfs. A tool which collects all that information might be useful, just as demonstration of how this is all supposed to be used. Finally we have kernel internal mappings too. Not tracked. There's also some things to make sure we're at least having thought about how other things fit in here. E.d. dma_resv attached to the dma-buf matters in general a lot. It doesn't matter on Android because everything's pinned all the time anyway. Also I thought sysfs was one value one file, dumping an entire list into dev_info_map with properties we'll need to extend (once you care about dma_resv you also want to know which attachments are dynamic) does not smell like sysfs design at all. So yeah, why? worksformeonandroidweneeditthere not good enough for uapi of something this core to how the gpu stack works on linux in general, at least imo. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch