[PATCH] EXA: Defragment offscreen memory.

Michel Dänzer michel at daenzer.net
Sat Feb 14 10:03:41 PST 2009


On Sat, 2009-02-14 at 09:01 -0800, Keith Packard wrote:
> On Sat, 2009-02-14 at 14:28 +0100, Michel Dänzer wrote:
> 
> > * The server is going idle.
> 
> The server calls the block handler every 20ms, not just when it is truly
> idle.

You learn something new every day...

> If this operation is expensive, you may want to hack up the block
> and wakeup handlers to pend this until the server actually ended up
> sleeping.

How can I tell that? It shouldn't be too expensive usually and will only
actually run at most once per second anyway, but it would probably still
be better only to do it when the server is idle if that can be achieved
without too much effort.

> Also, make sure this stuff is only used when you're using the exa
> off-screen allocation stuff.

I'm checking for !pExaScr->info->CreatePixmap, but I should probably
also check for EXA_OFFSCREEN_PIXMAPS. Does the below on top look good
for this?


diff --git a/exa/exa.c b/exa/exa.c
index 55e83bf..9de57d9 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -879,6 +879,23 @@ exaCreateScreenResources(ScreenPtr pScreen)
     return TRUE;
 }
 
+static void
+ExaBlockHandler(int screenNum, pointer blockData, pointer pTimeout,
+		pointer pReadmask)
+{
+    ScreenPtr pScreen = screenInfo.screens[screenNum];
+    ExaScreenPriv(pScreen);
+
+    /* Try and keep the offscreen memory area tidy every now and then when we're
+     * going idle anyway.
+     */
+    ExaOffscreenDefragment(pScreen);
+
+    unwrap(pExaScr, pScreen, BlockHandler);
+    (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
+    wrap(pExaScr, pScreen, BlockHandler, ExaBlockHandler);
+}
+
 /**
  * exaCloseScreen() unwraps its wrapped screen functions and tears down EXA's
  * screen private, before calling down to the next CloseSccreen.
@@ -894,7 +911,7 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     if (ps->Glyphs == exaGlyphs)
 	exaGlyphsFini(pScreen);
 
-    if (!pExaScr->info->CreatePixmap)
+    if (pScreen->BlockHandler == ExaBlockHandler)
 	unwrap(pExaScr, pScreen, BlockHandler);
     unwrap(pExaScr, pScreen, CreateGC);
     unwrap(pExaScr, pScreen, CloseScreen);
@@ -924,23 +941,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
-static void
-ExaBlockHandler(int screenNum, pointer blockData, pointer pTimeout,
-		pointer pReadmask)
-{
-    ScreenPtr pScreen = screenInfo.screens[screenNum];
-    ExaScreenPriv(pScreen);
-
-    /* Try and keep the offscreen memory area tidy every now and then when we're
-     * going idle anyway.
-     */
-    ExaOffscreenDefragment(pScreen);
-
-    unwrap(pExaScr, pScreen, BlockHandler);
-    (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
-    wrap(pExaScr, pScreen, BlockHandler, ExaBlockHandler);
-}
-
 /**
  * This function allocates a driver structure for EXA drivers to fill in.  By
  * having EXA allocate the structure, the driver structure can be extended
@@ -1072,7 +1072,8 @@ exaDriverInit (ScreenPtr		pScreen,
     /*
      * Replace various fb screen functions
      */
-    if (!pExaScr->info->CreatePixmap)
+    if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) &&
+	!pExaScr->info->CreatePixmap)
 	wrap(pExaScr, pScreen, BlockHandler, ExaBlockHandler);
     wrap(pExaScr, pScreen, CreateGC, exaCreateGC);
     wrap(pExaScr, pScreen, CloseScreen, exaCloseScreen);


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the xorg-devel mailing list