[xserver,2/3] res: Fix accounting of redirected window pixmaps for Composite

Submitted by Adam Jackson on Feb. 2, 2016, 7:30 p.m.

Details

Message ID 1454441452-3445-3-git-send-email-ajax@redhat.com
State Accepted
Commit 5d6ad0d3a7611c4dff2d79b6af9eb5c0885656ef
Headers show
Series "Accounting fixes for ResQueryClientPixmapBytes" ( rev: 1 ) in X.org (DEPRECATED - USE GITLAB)

Not browsing as part of any series.

Commit Message

Adam Jackson Feb. 2, 2016, 7:30 p.m.
The previous change removed the special case that matched resources of
CompositeClientWindowType and walked back from that to the window
pixmap. That was intentional, since that logic was broken anyway. CCWTs
don't map 1:1 to references on the backing pixmap; a window redirected
by multiple clients (say, by the server since it's on the synthetic
visual, and then manually by a compositor) would have a window pixmap
refcount of 1, but would have those bytes accounted twice.

The right thing is to have Composite wrap window accounting, and add the
pixmap bytes once and only once for the redirection reference.

Note that the view from the client can still be non-intuitive in the
face of Composite.  xcompmgr, for example, holds _two_ references to
each window pixmap (one each from CompositeNameWindowPixmap and
RenderCreatePicture), so a synthetic-visual window will have its bytes
split 2/3 to xcompmgr and 1/3 to the server-client.  Nothing to be done
about that, and at least this way we're not over-accounting.

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 composite/compext.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/composite/compext.c b/composite/compext.c
index f1a8255..944deb0 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -510,16 +510,17 @@  SProcCompositeDispatch(ClientPtr client)
 }
 
 /** @see GetDefaultBytes */
+static SizeType coreGetWindowBytes;
+
 static void
-GetCompositeClientWindowBytes(void *value, XID id, ResourceSizePtr size)
+GetCompositeWindowBytes(void *value, XID id, ResourceSizePtr size)
 {
     WindowPtr window = value;
 
-    /* Currently only pixmap bytes are reported to clients. */
-    size->resourceSize = 0;
+    /* call down */
+    coreGetWindowBytes(value, id, size);
 
-    /* Calculate pixmap reference sizes. */
-    size->pixmapRefSize = 0;
+    /* account for redirection */
     if (window->redirectDraw != RedirectDrawNone)
     {
         SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
@@ -563,8 +564,8 @@  CompositeExtensionInit(void)
     if (!CompositeClientWindowType)
         return;
 
-    SetResourceTypeSizeFunc(CompositeClientWindowType,
-                            GetCompositeClientWindowBytes);
+    coreGetWindowBytes = GetResourceTypeSizeFunc(RT_WINDOW);
+    SetResourceTypeSizeFunc(RT_WINDOW, GetCompositeWindowBytes);
 
     CompositeClientSubwindowsType = CreateNewResourceType
         (FreeCompositeClientSubwindows, "CompositeClientSubwindows");