linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
       [not found] ` <20210630013421.735092-2-john.stultz@linaro.org>
@ 2021-07-07  6:38   ` Christoph Hellwig
  2021-07-07  7:10     ` Christian König
  2021-07-07 19:35     ` John Stultz
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-07-07  6:38 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Daniel Vetter, Christian Koenig, Sumit Semwal, Liam Mark,
	Chris Goldsworthy, Laura Abbott, Brian Starkey, Hridya Valsaraju,
	Suren Baghdasaryan, Sandeep Patil, Daniel Mentz, ??rjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel, Mel Gorman, linux-mm

On Wed, Jun 30, 2021 at 01:34:17AM +0000, John Stultz wrote:
> This adds a shrinker controlled page pool, extracted
> out of the ttm_pool logic, and abstracted out a bit
> so it can be used by other non-ttm drivers.

Can you explain in detail why you need a differnt page pool over the one
maintained by the page allocator?  Fragmenting the memory into all kinds
of pools has lots of downsides, so the upsides need to be explained in
detail.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-07  6:38   ` page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation Christoph Hellwig
@ 2021-07-07  7:10     ` Christian König
  2021-07-07  7:14       ` Christoph Hellwig
  2021-07-07 19:35     ` John Stultz
  1 sibling, 1 reply; 8+ messages in thread
From: Christian König @ 2021-07-07  7:10 UTC (permalink / raw)
  To: Christoph Hellwig, John Stultz
  Cc: lkml, Daniel Vetter, Sumit Semwal, Liam Mark, Chris Goldsworthy,
	Laura Abbott, Brian Starkey, Hridya Valsaraju,
	Suren Baghdasaryan, Sandeep Patil, Daniel Mentz, ??rjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel, Mel Gorman, linux-mm

Am 07.07.21 um 08:38 schrieb Christoph Hellwig:
> On Wed, Jun 30, 2021 at 01:34:17AM +0000, John Stultz wrote:
>> This adds a shrinker controlled page pool, extracted
>> out of the ttm_pool logic, and abstracted out a bit
>> so it can be used by other non-ttm drivers.
> Can you explain in detail why you need a differnt page pool over the one
> maintained by the page allocator?  Fragmenting the memory into all kinds
> of pools has lots of downsides, so the upsides need to be explained in
> detail.

Well, the original code all this is based on already had the comment 
that this really belong into the page allocator.

The key point is traditionally only GPUs used uncached and 
write-combined memory in such large quantities that having a pool for 
them makes sense.

Because of this we had this separately to reduce the complexity in the 
page allocator to handle another set of complexity of allocation types.

For the upside, for those use cases it means huge performance 
improvements for those drivers. See the numbers John provided in the 
cover letter.

But essentially at least I would be totally fine moving this into the 
page allocator, but moving it outside of TTM already helps with this 
goal. So this patch set is certainly a step into the right direction.

Regards,
Christian.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-07  7:10     ` Christian König
@ 2021-07-07  7:14       ` Christoph Hellwig
  2021-07-07  9:32         ` Christian König
  2021-07-07 19:42         ` John Stultz
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-07-07  7:14 UTC (permalink / raw)
  To: Christian K??nig
  Cc: Christoph Hellwig, John Stultz, lkml, Daniel Vetter,
	Sumit Semwal, Liam Mark, Chris Goldsworthy, Laura Abbott,
	Brian Starkey, Hridya Valsaraju, Suren Baghdasaryan,
	Sandeep Patil, Daniel Mentz, ??rjan Eide, Robin Murphy,
	Ezequiel Garcia, Simon Ser, James Jones, linux-media, dri-devel,
	Mel Gorman, linux-mm

On Wed, Jul 07, 2021 at 09:10:26AM +0200, Christian K??nig wrote:
> Well, the original code all this is based on already had the comment that
> this really belong into the page allocator.
> 
> The key point is traditionally only GPUs used uncached and write-combined
> memory in such large quantities that having a pool for them makes sense.
> 
> Because of this we had this separately to reduce the complexity in the page
> allocator to handle another set of complexity of allocation types.
> 
> For the upside, for those use cases it means huge performance improvements
> for those drivers. See the numbers John provided in the cover letter.
> 
> But essentially at least I would be totally fine moving this into the page
> allocator, but moving it outside of TTM already helps with this goal. So
> this patch set is certainly a step into the right direction.

Unless I'm badly misreading the patch and this series there is nothing
about cache attributes in this code.  It just allocates pages, zeroes
them, eventually hands them out to a consumer and registers a shrinker
for its freelist.

If OTOH it actually dealt with cachability that should be documented
in the commit log and probably also the naming of the implementation.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-07  7:14       ` Christoph Hellwig
@ 2021-07-07  9:32         ` Christian König
  2021-07-07 19:42         ` John Stultz
  1 sibling, 0 replies; 8+ messages in thread
From: Christian König @ 2021-07-07  9:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: John Stultz, lkml, Daniel Vetter, Sumit Semwal, Liam Mark,
	Chris Goldsworthy, Laura Abbott, Brian Starkey, Hridya Valsaraju,
	Suren Baghdasaryan, Sandeep Patil, Daniel Mentz, ??rjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel, Mel Gorman, linux-mm



Am 07.07.21 um 09:14 schrieb Christoph Hellwig:
> On Wed, Jul 07, 2021 at 09:10:26AM +0200, Christian K??nig wrote:
>> Well, the original code all this is based on already had the comment that
>> this really belong into the page allocator.
>>
>> The key point is traditionally only GPUs used uncached and write-combined
>> memory in such large quantities that having a pool for them makes sense.
>>
>> Because of this we had this separately to reduce the complexity in the page
>> allocator to handle another set of complexity of allocation types.
>>
>> For the upside, for those use cases it means huge performance improvements
>> for those drivers. See the numbers John provided in the cover letter.
>>
>> But essentially at least I would be totally fine moving this into the page
>> allocator, but moving it outside of TTM already helps with this goal. So
>> this patch set is certainly a step into the right direction.
> Unless I'm badly misreading the patch and this series there is nothing
> about cache attributes in this code.  It just allocates pages, zeroes
> them, eventually hands them out to a consumer and registers a shrinker
> for its freelist.
>
> If OTOH it actually dealt with cachability that should be documented
> in the commit log and probably also the naming of the implementation.

Mhm, good point. In this case all left is the clearing overhead from the 
allocation hot path to the free path and I'm not really sure why the 
core page allocator shouldn't do that as well.

Regards,
Christian.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-07  6:38   ` page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation Christoph Hellwig
  2021-07-07  7:10     ` Christian König
@ 2021-07-07 19:35     ` John Stultz
  2021-07-08  4:20       ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: John Stultz @ 2021-07-07 19:35 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: lkml, Daniel Vetter, Christian Koenig, Sumit Semwal, Liam Mark,
	Chris Goldsworthy, Laura Abbott, Brian Starkey, Hridya Valsaraju,
	Suren Baghdasaryan, Sandeep Patil, Daniel Mentz, ??rjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel, Mel Gorman, linux-mm

On Tue, Jul 6, 2021 at 11:38 PM Christoph Hellwig <hch@infradead.org> wrote:
> On Wed, Jun 30, 2021 at 01:34:17AM +0000, John Stultz wrote:
> > This adds a shrinker controlled page pool, extracted
> > out of the ttm_pool logic, and abstracted out a bit
> > so it can be used by other non-ttm drivers.
>
> Can you explain in detail why you need a differnt page pool over the one
> maintained by the page allocator?  Fragmenting the memory into all kinds
> of pools has lots of downsides, so the upsides need to be explained in
> detail.

So, as Christian mentioned, on the TTM side it's useful, as they are
trying to avoid TLB flushes when changing caching attributes.

For the dmabuf system heap purposes, the main benefit is moving the
page zeroing to the free path, rather than the allocation path. This
on its own doesn't save much, but allows us to defer frees (and thus
the zeroing) to the background, which can get that work out of the hot
path.

thanks
-john


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-07  7:14       ` Christoph Hellwig
  2021-07-07  9:32         ` Christian König
@ 2021-07-07 19:42         ` John Stultz
  1 sibling, 0 replies; 8+ messages in thread
From: John Stultz @ 2021-07-07 19:42 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Christian K??nig, lkml, Daniel Vetter, Sumit Semwal, Liam Mark,
	Chris Goldsworthy, Laura Abbott, Brian Starkey, Hridya Valsaraju,
	Suren Baghdasaryan, Sandeep Patil, Daniel Mentz, ??rjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel, Mel Gorman, linux-mm

On Wed, Jul 7, 2021 at 12:15 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Jul 07, 2021 at 09:10:26AM +0200, Christian K??nig wrote:
> > Well, the original code all this is based on already had the comment that
> > this really belong into the page allocator.
> >
> > The key point is traditionally only GPUs used uncached and write-combined
> > memory in such large quantities that having a pool for them makes sense.
> >
> > Because of this we had this separately to reduce the complexity in the page
> > allocator to handle another set of complexity of allocation types.
> >
> > For the upside, for those use cases it means huge performance improvements
> > for those drivers. See the numbers John provided in the cover letter.
> >
> > But essentially at least I would be totally fine moving this into the page
> > allocator, but moving it outside of TTM already helps with this goal. So
> > this patch set is certainly a step into the right direction.
>
> Unless I'm badly misreading the patch and this series there is nothing
> about cache attributes in this code.  It just allocates pages, zeroes
> them, eventually hands them out to a consumer and registers a shrinker
> for its freelist.
>
> If OTOH it actually dealt with cachability that should be documented
> in the commit log and probably also the naming of the implementation.

So the cache attributes are still managed in the tmm_pool code. This
series just pulls the pool/shrinker management out into common code so
we can use it in the dmabuf heap code without duplicating things.

thanks
-john


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-07 19:35     ` John Stultz
@ 2021-07-08  4:20       ` Christoph Hellwig
  2021-07-08  7:37         ` Christian König
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2021-07-08  4:20 UTC (permalink / raw)
  To: John Stultz
  Cc: Christoph Hellwig, lkml, Daniel Vetter, Christian Koenig,
	Sumit Semwal, Liam Mark, Chris Goldsworthy, Laura Abbott,
	Brian Starkey, Hridya Valsaraju, Suren Baghdasaryan,
	Sandeep Patil, Daniel Mentz, ??rjan Eide, Robin Murphy,
	Ezequiel Garcia, Simon Ser, James Jones, linux-media, dri-devel,
	Mel Gorman, linux-mm

On Wed, Jul 07, 2021 at 12:35:23PM -0700, John Stultz wrote:
> So, as Christian mentioned, on the TTM side it's useful, as they are
> trying to avoid TLB flushes when changing caching attributes.
> 
> For the dmabuf system heap purposes, the main benefit is moving the
> page zeroing to the free path, rather than the allocation path. This
> on its own doesn't save much, but allows us to defer frees (and thus
> the zeroing) to the background, which can get that work out of the hot
> path.

I really do no think that is worth it to fragment the free pages.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation
  2021-07-08  4:20       ` Christoph Hellwig
@ 2021-07-08  7:37         ` Christian König
  0 siblings, 0 replies; 8+ messages in thread
From: Christian König @ 2021-07-08  7:37 UTC (permalink / raw)
  To: Christoph Hellwig, John Stultz
  Cc: lkml, Daniel Vetter, Sumit Semwal, Liam Mark, Chris Goldsworthy,
	Laura Abbott, Brian Starkey, Hridya Valsaraju,
	Suren Baghdasaryan, Sandeep Patil, Daniel Mentz, ??rjan Eide,
	Robin Murphy, Ezequiel Garcia, Simon Ser, James Jones,
	linux-media, dri-devel, Mel Gorman, linux-mm

Am 08.07.21 um 06:20 schrieb Christoph Hellwig:
> On Wed, Jul 07, 2021 at 12:35:23PM -0700, John Stultz wrote:
>> So, as Christian mentioned, on the TTM side it's useful, as they are
>> trying to avoid TLB flushes when changing caching attributes.
>>
>> For the dmabuf system heap purposes, the main benefit is moving the
>> page zeroing to the free path, rather than the allocation path. This
>> on its own doesn't save much, but allows us to defer frees (and thus
>> the zeroing) to the background, which can get that work out of the hot
>> path.
> I really do no think that is worth it to fragment the free pages.

And I think functionality like that should be part of the common page 
allocator.

I mean we already have __GFP_ZERO, why not have a background kernel 
thread which zeros free pages when a CPU core is idle? (I'm pretty sure 
we already have that somehow).

Christian.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-08  8:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210630013421.735092-1-john.stultz@linaro.org>
     [not found] ` <20210630013421.735092-2-john.stultz@linaro.org>
2021-07-07  6:38   ` page pools, was Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation Christoph Hellwig
2021-07-07  7:10     ` Christian König
2021-07-07  7:14       ` Christoph Hellwig
2021-07-07  9:32         ` Christian König
2021-07-07 19:42         ` John Stultz
2021-07-07 19:35     ` John Stultz
2021-07-08  4:20       ` Christoph Hellwig
2021-07-08  7:37         ` Christian König

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).