The busybox "printf" command is always 32 bit even when the shell isn't.

Denys Vlasenko vda.linux at googlemail.com
Sat Jan 10 16:10:06 UTC 2009


On Monday 05 January 2009 23:59, Rob Landley wrote:
> > It still destroys L1 dcache IIRC.
> 
> You go out of L1 cache every time you touch a new cache line.  Fetching that 
> back from L2 is cheap.  If it destroyed the L2 cache, then I'd worry.

You effectively are saying L1 is worthless.

> Cloning existing page tables doesn't require an mmu flush, nor does switching 
> between processes with existing page tables.  Slowaris invented threading so 
> they could avoid an mmu flush when switching between threads with identical 
> page tables; but Linux is smarter about page table switching in general and 
> only flushes what it needs to when switching process contexts.  (Hence Linux 
> processes being cheaper than solaris threads.)  That's why the kernel area is 
> mapped (but masked) into all process address spaces, otherwise you'd need an 
> MMU reload to make a system call.
> 
> My frame of reference here is that Ingo Molnar managed 2 million fork/exit 
> pairs per second on a threading benchmark five years ago,

Ingo was creating _threads_ (processes with shared memory map).
fork() is creating separate memory map.
Considering that typical L1 cache is 64k == 16 pages,
and kernel stack requires two pages, page tables require about 6 pages minimum,
new process touches its own userspace stack and usually a data page or two...

I don't have this data handy now, but I instrumented the kernel
to count page clearing ops sometime ago.
I definitely saw more page clears per fork than L1 size.

> and the Linux guys  
> have made it a point of pride that threads and processes are essentially the 
> same thing on Linux and perform the same.

I am not saying that processes in Linux are especially heavy.
I think that both fork and exec syscalls have approximately
the came cost (for small executables) - cost of losing L1
contents.

> Have you benchmarked the difference?

No, I didnt bencmark what is better - "fork but no exec"
or "no fork but exec". It is not that interesting, considering
that we can only use "fork + no exec" (NOXEC applets),
and "no fork, and no exec" (NOFORK applets).

IOW: at no time in busybox we need to decide what is less expensive
- to fork or to exec?

And lastly, all applets except ash use vfork (on NOMMU,
on MMU a few still use fork because it makes them simpler).
--
vda


More information about the busybox mailing list