linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Peter.Enderborg@sony.com>
To: <rppt@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	<sumit.semwal@linaro.org>, <christian.koenig@amd.com>,
	<adobriyan@gmail.com>, <akpm@linux-foundation.org>,
	<songmuchun@bytedance.com>, <guro@fb.com>, <shakeelb@google.com>,
	<mhocko@suse.com>, <neilb@suse.de>, <samitolvanen@google.com>,
	<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linaro-mm-sig@lists.linaro.org>, <willy@infradead.org>
Subject: Re: [PATCH v5] dma-buf: Add DmaBufTotal counter in meminfo
Date: Thu, 22 Apr 2021 14:08:51 +0000	[thread overview]
Message-ID: <ae091d3d-623b-ce18-e0f2-1591be6db83e@sony.com> (raw)
In-Reply-To: <YIEugg9RIVSReN97@kernel.org>

On 4/22/21 10:06 AM, Mike Rapoport wrote:
> On Wed, Apr 21, 2021 at 05:35:57PM +0000, Peter.Enderborg@sony.com wrote:
>> On 4/21/21 5:31 PM, Mike Rapoport wrote:
>>> On Wed, Apr 21, 2021 at 10:37:11AM +0000, Peter.Enderborg@sony.com wrote:
>>>> On 4/21/21 11:15 AM, Daniel Vetter wrote:
>>>>> We need to understand what the "correct" value is. Not in terms of kernel
>>>>> code, but in terms of semantics. Like if userspace allocates a GL texture,
>>>>> is this supposed to show up in your metric or not. Stuff like that.
>>>> That it like that would like to only one pointer type. You need to know what
>>>>
>>>> you pointing at to know what it is. it might be a hardware or a other pointer.
>>>>
>>>> If there is a limitation on your pointers it is a good metric to count them
>>>> even if you don't  know what they are. Same goes for dma-buf, they
>>>> are generic, but they consume some resources that are counted in pages.
>>>>
>>>> It would be very good if there a sub division where you could measure
>>>> all possible types separately.  We have the detailed in debugfs, but nothing
>>>> for the user. A summary in meminfo seems to be the best place for such
>>>> metric.
>>>  
>>> Let me try to summarize my understanding of the problem, maybe it'll help
>>> others as well.
>> Thanks!
>>
>>
>>> A device driver allocates memory and exports this memory via dma-buf so
>>> that this memory will be accessible for userspace via a file descriptor.
>>>
>>> The allocated memory can be either allocated with alloc_page() from system
>>> RAM or by other means from dedicated VRAM (that is not managed by Linux mm)
>>> or even from on-device memory.
>>>
>>> The dma-buf driver tracks the amount of the memory it was requested to
>>> export and the size it sees is available at debugfs and fdinfo.
>>>
>>> The debugfs is not available to user and maybe entirely disabled in
>>> production systems.
>>>
>>> There could be quite a few open dma-bufs so there is no overall summary,
>>> plus fdinfo in production systems your refer to is also unavailable to the
>>> user because of selinux policy.
>>>
>>> And there are a few details that are not clear to me:
>>>
>>> * Since DRM device drivers seem to be the major user of dma-buf exports,
>>>   why cannot we add information about their memory consumption to, say,
>>>   /sys/class/graphics/drm/cardX/memory-usage?
>> Android is using it for binder that connect more or less everything
>> internally.
>  
> Ok, then it rules out /sys/class/graphics indeed.
>
>>> * How exactly user generates reports that would include the new counters?
>>>   From my (mostly outdated) experience Android users won't open a terminal
>>>   and type 'cat /proc/meminfo' there. I'd presume there is a vendor agent
>>>   that collects the data and sends it for analysis. In this case what is
>>>   the reason the vendor is unable to adjust selinix policy so that the
>>>   agent will be able to access fdinfo?
>> When you turn on developer mode on android you can use
>> usb with a program called adb. And there you get a normal shell.
>>
>> (not root though)
>>
>> There is applications that non developers can use to get
>> information. It is very limited though and there are API's
>> provide it.
>>
>>
>>> * And, as others already mentioned, it is not clear what are the problems
>>>   that can be detected by examining DmaBufTotal except saying "oh, there is
>>>   too much/too little memory exported via dma-buf". What would be user
>>>   visible effects of these problems? What are the next steps to investigate
>>>   them? What other data will be probably required to identify root cause?
>>>
>> When you debug thousands of devices it is quite nice to have
>> ways to classify what the problem it is not. The normal user does not
>> see anything of this. However they can generate bug-reports that
>> collect information about as much they can. Then the user have
>> to provide this bug-report to the manufacture or mostly the
>> application developer. And when the problem is
>> system related we need to reproduce the issue on a full
>> debug enabled unit.
> So the flow is like this:
>
> * a user has a problem and reports it to an application developer; at best
>   the user runs simple and limited app to collect some data
> * if the application developer considers this issue as a system related
>   they can open adb and collect some more information about the system
>   using non-root shell with selinux policy restrictions and send this
>   information to the device manufacturer.
> * the manufacturer continues to debug the issue and at this point as much
>   information is possible would have been useful.
>
> In this flow I still fail to understand why the manufacturer cannot provide
> userspace tools that will be able to collect the required information.
> These tools not necessarily need to target the end user, they may be only
> intended for the application developers, e.g. policy could allow such tool
> to access some of the system data only when the system is in developer
> mode.
>
The manufacture is trying to get the tool to work. This is what the
patch is about. Even for a application developer a commercial
phone is locked down. Many vendors allow that you flash
some other software like a AOSP.  But that can be very
different. Like installing a ubuntu on a PC to debug a Fedora issue.

And sure we can pickup parts of what using the dma-buf. But
we can not get the total and be sure that is the total without a
proper counter.

  reply	other threads:[~2021-04-22 14:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-17 16:38 [PATCH v5] dma-buf: Add DmaBufTotal counter in meminfo Peter Enderborg
2021-04-20  8:58 ` Daniel Vetter
2021-04-20  9:26   ` Peter.Enderborg
2021-04-20  9:41     ` Mike Rapoport
2021-04-20 10:45       ` Peter.Enderborg
2021-04-20 11:52         ` Mike Rapoport
2021-04-20 12:03           ` Peter.Enderborg
2021-04-20 11:14     ` Daniel Vetter
2021-04-20 11:37       ` Peter.Enderborg
2021-04-21  9:15         ` Daniel Vetter
2021-04-21 10:37           ` Peter.Enderborg
2021-04-21 10:57             ` Michal Hocko
2021-04-21 13:05             ` Pekka Paalanen
2021-04-21 15:31             ` Mike Rapoport
2021-04-21 17:35               ` Peter.Enderborg
2021-04-22  8:06                 ` Mike Rapoport
2021-04-22 14:08                   ` Peter.Enderborg [this message]
2021-04-25  7:33                     ` Mike Rapoport
2021-04-25  8:40                       ` Peter.Enderborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae091d3d-623b-ce18-e0f2-1591be6db83e@sony.com \
    --to=peter.enderborg@sony.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=guro@fb.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=neilb@suse.de \
    --cc=rppt@kernel.org \
    --cc=samitolvanen@google.com \
    --cc=shakeelb@google.com \
    --cc=songmuchun@bytedance.com \
    --cc=sumit.semwal@linaro.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).