[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Etch for ARM / Netwinder: where is NPTL support?



On Fri, May 11, 2007 at 12:57:17PM +0100, Martin Guy wrote:

> >> If it's any consolation, its userland thread switches between
> >> the same process are much faster than the NPTL kernel version at
> >> present (fixes are in course, if not already mainline).
> >
> >Hm?  What is this referring to?
> 
> When I pulled out, switches between different threads on ARM NPTL
> implied the same overhead as a process switch,

Hmm.  No?

>From include/asm-arm/mmu_context.h:

	static inline void
	switch_mm(struct mm_struct *prev, struct mm_struct *next,
		  struct task_struct *tsk)
	{
		unsigned int cpu = smp_processor_id();

		if (prev != next) {
			cpu_set(cpu, next->cpu_vm_mask);
			check_context(next);
			cpu_switch_mm(next->pgd, next);
			if (cache_is_vivt())
				cpu_clear(cpu, prev->cpu_vm_mask);
		}
	}

I.e. when we switch to a task that uses the same mm (i.e. a thread of
the same process), we don't actually call ->switch_mm().

(switch_mm() is the CPU core-specific routine that flushes the D cache
and invalidates the I cache (if they are virtual caches), invalidates
the TLBs, etc.)

This is true for both NPTL and linuxthreads.


> WIth linuxthreads instead, no kernel context switch happens cos it's
> all done within one Unix process anyway, no?

No, that is not true.

Both NPTL and linuxthreads are 1:1 threading models, i.e. every thread
in your app corresponds to a process/thread on the host.

You might be confused with the older NGPT (Next-Generation POSIX
Threads thread library), which is a userland thread package which
_does_ run multiple application threads in the same task.  It
never really caught on.


> I can try and dig up the mail thread if that'll help

That would definitely help, please do.



Reply to: