mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] do_execve() perf improvement opportunity?
@ 2005-06-21  6:42 cutaway
  2005-06-21 13:56 ` Rik van Riel
  0 siblings, 1 reply; 4+ messages in thread
From: cutaway @ 2005-06-21  6:42 UTC (permalink / raw)
  To: linux-kernel

do_execve() on EVERY entry/exit allocates and frees a structure pointed to
by the 'bprm' variable.

I'm thinking it may be possible to very cheaply cache a pointer to the last
allocation here rather than freeing it and just recycle it for the next exec
saving a trip through the slab machanism.

On x86 I'm pretty sure this could be done very racy and lockless (other than
XCHG's implied locks).  Other architectures that don't have an implied
locking instruction might need a hard lock of some sort.

Something along the lines of (pseudocode):

static volatile struct blahblah *p = NULL;

/* ...before the exec... */
bprm = NULL
xchg(bprm, p)
if (bprm == NULL) kmalloc like it is now

/*
  blah, blah, blah...exec triage blob as it exists today
*/

/* ...after the exec...*/
xchg(bprm, p) /* cache what we just used */
if (bprm)     /* Maybe free someone else's if it was still available */
    kfree(bprm);

For things that proceed mostly sequentially like a lot of shell scripts,
Linux builds, etc this simple minded high-speed low-drag, single structure
racy implementation might provide a nice gain for minimal cost.



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

end of thread, other threads:[~2005-06-21 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-21  6:42 [RFC] do_execve() perf improvement opportunity? cutaway
2005-06-21 13:56 ` Rik van Riel
2005-06-21 17:06   ` cutaway
2005-06-21 17:15     ` Rik van Riel

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

all inboxes | Powered by JetHome®