diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2007-11-06 16:26:09 -0500 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil> | 2007-11-06 16:26:09 -0500 |
commit | d7c5e8bfc1aecbd23a4cbb2eab08656587aac2e8 (patch) | |
tree | 79cedf01ed0a533a9ab9611ae95f113159aab383 /Xext/xace.c | |
parent | aaa50b64113b122aaebd46e3b78e3fb7a8d70500 (diff) |
Modified performance patches from Arjan van de Ven <arjan@infradead.org>
Subject: [PATCH] fix some performance gaps in Xace
The XaceHook function is used in several hotpaths.
The problem with it (performance wise) is twofold:
* The XaceHook function has a big switch() statement for the hook number in it
* The XaceHook function uses varargs to reassemble the final dispatch arguments again
Both are expensive operations... for something that is known at compile time
This patch turns the hotpath XaceHook call into a direct call to avoid
the switch and varargs; this gives me over 10% performance gain
on the x11perf benchmark.
Diffstat (limited to 'Xext/xace.c')
-rw-r--r-- | Xext/xace.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/Xext/xace.c b/Xext/xace.c index 00c3b8f9b..b4e0eee5f 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -44,6 +44,22 @@ static int (*SwappedUntrustedProcVector[256])( ClientPtr /*client*/ ); +/* Special-cased hook functions. Called by Xserver. + */ +void XaceHookAuditBegin(ClientPtr ptr) +{ + XaceAuditRec rec = { ptr, 0 }; + /* call callbacks, there is no return value. */ + CallCallbacks(&XaceHooks[XACE_AUDIT_BEGIN], &rec); +} + +void XaceHookAuditEnd(ClientPtr ptr, int result) +{ + XaceAuditRec rec = { ptr, result }; + /* call callbacks, there is no return value. */ + CallCallbacks(&XaceHooks[XACE_AUDIT_END], &rec); +} + /* Entry point for hook functions. Called by Xserver. */ int XaceHook(int hook, ...) @@ -60,15 +76,6 @@ int XaceHook(int hook, ...) */ switch (hook) { - case XACE_CORE_DISPATCH: { - XaceCoreDispatchRec rec = { - va_arg(ap, ClientPtr), - TRUE /* default allow */ - }; - calldata = &rec; - prv = &rec.rval; - break; - } case XACE_RESOURCE_ACCESS: { XaceResourceAccessRec rec = { va_arg(ap, ClientPtr), @@ -190,22 +197,6 @@ int XaceHook(int hook, ...) calldata = &rec; break; } - case XACE_AUDIT_BEGIN: { - XaceAuditRec rec = { - va_arg(ap, ClientPtr), - 0 - }; - calldata = &rec; - break; - } - case XACE_AUDIT_END: { - XaceAuditRec rec = { - va_arg(ap, ClientPtr), - va_arg(ap, int) - }; - calldata = &rec; - break; - } default: { va_end(ap); return 0; /* unimplemented hook number */ @@ -271,11 +262,15 @@ XaceCatchDispatchProc(ClientPtr client) { REQUEST(xReq); int major = stuff->reqType; + XaceCoreDispatchRec rec = { client, TRUE /* default allow */ }; if (!ProcVector[major]) return (BadRequest); - if (!XaceHook(XACE_CORE_DISPATCH, client)) + /* call callbacks and return result, if any. */ + CallCallbacks(&XaceHooks[XACE_CORE_DISPATCH], &rec); + + if (!rec.rval) return (BadAccess); return client->swapped ? |