[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALAqxLUtK8V9LgC-DY+tkzFYyWfzF+JhbrLZk6UhEG57HQBDSA@mail.gmail.com>
Date: Wed, 19 Jan 2022 12:37:27 -0800
From: John Stultz <john.stultz@...aro.org>
To: "Guangming.Cao" <guangming.cao@...iatek.com>
Cc: Christian König <christian.koenig@....com>,
"Ruhl, Michael J" <michael.j.ruhl@...el.com>,
"sumit.semwal@...aro.org" <sumit.semwal@...aro.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"wsd_upstream@...iatek.com" <wsd_upstream@...iatek.com>,
"libo.kang@...iatek.com" <libo.kang@...iatek.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"yf.wang@...iatek.com" <yf.wang@...iatek.com>,
"linaro-mm-sig@...ts.linaro.org" <linaro-mm-sig@...ts.linaro.org>,
"linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>,
"lmark@...eaurora.org" <lmark@...eaurora.org>,
"benjamin.gaignard@...aro.org" <benjamin.gaignard@...aro.org>,
"bo.song@...iatek.com" <bo.song@...iatek.com>,
"matthias.bgg@...il.com" <matthias.bgg@...il.com>,
"labbott@...hat.com" <labbott@...hat.com>,
"mingyuan.ma@...iatek.com" <mingyuan.ma@...iatek.com>,
"jianjiao.zeng@...iatek.com" <jianjiao.zeng@...iatek.com>,
"linux-media@...r.kernel.org" <linux-media@...r.kernel.org>
Subject: Re: [PATCH v3] dma-buf: dma-heap: Add a size check for allocation
On Wed, Jan 19, 2022 at 1:58 AM Guangming.Cao
<guangming.cao@...iatek.com> wrote:
> On Fri, 2022-01-14 at 17:17 -0800, John Stultz wrote:
> > If the max value is per-heap, why not enforce that value in the
> > per-heap allocation function?
> >
> > Moving the check to the heap alloc to me seems simpler to me than
> > adding complexity to the infrastructure to add a heap max_size
> > callback. Is there some other use for the callback that you envision?
> >
>
> If you think max the value is per-heap, why not add an optional
> callback for dma-heap to solve this issue(prevent consuming too much
> time for a doomed to fail allocation), if the dma-heap doesn't have a
> special size check, just use the default value(totalram) in dma-heap
> framework to do the size check.
As the totalram default isn't correct for all heaps (or necessarily
even most heaps), so those heaps would need to implement the callback.
I'm just not sure adding complexity to the framework to address this
is useful. Instead of an additional check in the allocation function,
heap implementers will need to assess if the default logic in a
framework is correct, and then possibly implement the callback.
> Yes, for linux dma-heaps, only system-heap needs it, so adding it in
> system heap is the simplest. However, there are many vendor dma-heaps
> like system-heap which won't be uploaded to linux codebase, and maybe
> have same limitation, all these heaps need to add the same limitation.
My worry is that without seeing these vendor heaps, this is a bit of a
theoretical concern. We don't have the data on how common this is.
I very much hope that vendors can start submitting their heaps
upstream (along with drivers that benefit from the heaps). Then we can
really assess what makes the most sense for the community maintained
code.
> I just think it's boring. However, If you think discussing these absent
> cases based on current linux code is meaningless, I also agree to it.
So, as a rule, the upstream kernel doesn't create/maintain logic to
accommodate out of tree code.
Now, I agree there is the potential for some duplication in the checks
in the allocation logic, but until it affects the upstream kernel,
community maintainers can't really make an appropriate evaluation.
As a contra-example, if the allocation is some extreme hotpath, adding
an extra un-inlinable function pointer traversal for the size callback
may actually have a negative impact. This isn't likely but again, if
we cannot demonstrate it one way or the other against the upstream
tree, we can't figure out what the best solution might be.
> So, to summarize, if you still think adding it in system_heap.c is
> better, I also agree and I will update the patch to add it in
> system_heap.c
I think this is the best solution for now. As this is not part of an
userland ABI, we can always change it in the future once we see the
need.
thanks
-john
Powered by blists - more mailing lists