public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* uncached page allocator
@ 2007-08-20  0:45 Dave Airlie
  2007-08-20  8:41 ` Alan Cox
  0 siblings, 1 reply; 8+ messages in thread
From: Dave Airlie @ 2007-08-20  0:45 UTC (permalink / raw)
  To: dri-devel, Linux Kernel Mailing List

Hi all,

I've started doing some work with using the new DRM memory manager
from TG for pixmaps in the X server using Intel 9xx series hardware.

The intel hardware pretty much requires pages to be uncached for the
GPU to access them. It can use cached memory for some operations but
it isn't very useful and my attempts to use it ended in a lot of
crashiness..

Now one of the major usage patterns for pixmaps is

allocate pixmap
copy data into pixmap
use pixmap from hardware
free pixmap

with the current memory manager + updated change_page_attr (to use
clflush when we have it) fixes from Andi Kleen, it operates something
like this

allocate pixmap gets cached memory
copy data into the pixmap
pre-use from hardware we flush the cache lines and tlb
use the pixmap in hardware
pre-free we need to set the page back to cached so we flush the tlb
free the memory.

The other path is if we don't want to use the memory cached ever is just
allocate pixmap
flush cache lines/tlb
use uncached from CPU
use uncached from GPU
pre-free set the page back to cached, flush the TLB
free the page

Now the big issue here on SMP is that the cache and/or tlb flushes
require IPIs and they are very noticeable on the profiles,

So after all that I'd like to have some sort of uncached page list I
can allocate pages from, so with frequent pixmap creation/destruction
I don't spend a lot of time in the cache flushing routines and avoid
the IPI in particular.

The options I can sorta see roughly are:
1. the DRM just allocates a bunch of uncached pages and manages a
cache of them for interacting with the hardware, this sounds wrong and
we run into how do we correctly size the pool issues.

2. (Is this idea crazy??) We modify the VM somehow so we have an
uncached list, when we first allocate pages with the GFP_UNCACHED they
get migrated to the uncached zone and the pages use a page flag to say
they are uncached. Then the DRM just re-uses things from that list. If
later we end up with memory pressure, the free pages on the uncached
list could be migrated back to the normal page lists by modifying the
page attributes and flushing the tlb....

Any other ideas and suggestions?

Dave.

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: uncached page allocator
@ 2007-08-20 12:36 Daniel J Blueman
  2007-08-21  6:06 ` Dave Airlie
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel J Blueman @ 2007-08-20 12:36 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Linux Kernel

On 20 Aug, 01:50, "Dave Airlie" <airlied@gmail.com> wrote:
> Hi all,
>
> I've started doing some work with using the new DRM memory manager
> from TG for pixmaps in the X server using Intel 9xx series hardware.
>
> The intel hardware pretty much requires pages to be uncached for the
> GPU to access them. It can use cached memory for some operations but
> it isn't very useful and my attempts to use it ended in a lot of
> crashiness..

Write-combining access seems the correct thing here, followed by a
wmb(). Uncached writing would be horrendously slow.

[snip]
> So after all that I'd like to have some sort of uncached page list I
> can allocate pages from

This is exactly what Intel's PAT mechanism exists for - just mark the
desired access type (index) on the pages you've been allocated.

It's documented in the Intel Architecture Software Design manuals, but
Linux's support is lacking in certain areas [discussions on LKML],
which a number of developers have been trying to move forward.

Quite a few significant graphics/HPC etc vendors are forced to use it
without this complete support, so it would be good to get this
additional impetus involved...

Daniel
-- 
Daniel J Blueman

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

end of thread, other threads:[~2007-08-30  7:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-20  0:45 uncached page allocator Dave Airlie
2007-08-20  8:41 ` Alan Cox
2007-08-21  6:05   ` Dave Airlie
2007-08-21 14:56     ` Peter Zijlstra
2007-08-27 20:00       ` Christoph Lameter
2007-08-30  7:23       ` Nick Piggin
  -- strict thread matches above, loose matches on Subject: below --
2007-08-20 12:36 Daniel J Blueman
2007-08-21  6:06 ` Dave Airlie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox