Re: COW optimization on exec

From: Nick Piggin
Date: Sat Mar 14 2009 - 23:58:42 EST


On Sunday 15 March 2009 13:57:54 sidc7 wrote:
> The Linux kernel uses the COW optimization for fork, so the processes share
> the same pages, till on of the processes writes to the page. I was
> wondering, if I do a fork and do an exec immediately following the fork,
> will the COW optimization still be applied as it is most likely that the
> new process is going to write to the shared pages? So doing a COW will not

exec throws out all those pages, so go away without ever having been
copied. However it still costs memory CPU time TLB flushes etc in order
to set up the COW optimisation in the first place, so if you are doing
fork/exec, then I think vfork is the better option.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/