Skip to contentSkip to conversation

i386 - pte update optimizations

PATCH In review Zachary Amsden 5 participants 9 messages Apr 12, 2007 – Apr 13, 2007 virtio core

lore
Share & tools
lore
#0 lore raw

cover i386 - pte update optimizations

Some PTE optimizations for native and paravirt-ops kernels; this provides a huge win for shadow mode hypervisors and gets rid of some unnecessary atomic instructions in native kernels, saving even more on UP by getting rid of implicit LOCK on xchg instruction.

Zach

#1 lore raw
Quoted 4 lines · Zachary Amsden

Some PTE optimizations for native and paravirt-ops kernels; this provides a huge win for shadow mode hypervisors and gets rid of some unnecessary atomic instructions in native kernels, saving even more on UP by getting rid of implicit LOCK on xchg instruction.

You do know that P6 and higher don't do locked bus references as long as the value is in the cache, right?

-hpa

#2 lore raw
Quoted 7 lines · H. Peter Anvin
Quoted 4 lines · Zachary Amsden

Some PTE optimizations for native and paravirt-ops kernels; this provides a huge win for shadow mode hypervisors and gets rid of some unnecessary atomic instructions in native kernels, saving even more on UP by getting rid of implicit LOCK on xchg instruction.

You do know that P6 and higher don't do locked bus references as long as the value is in the cache, right?

Yes. Even then, last time I clocked instructions, xchg was still slower than read / write, although I could be misremembering. And it's not totally clear that they will always be in cached state, however, and for SMP, we still want to drop the implicit lock in cases where the processor might not know they are cached exclusive, but we know there are no other racing users. And there are plenty of old processors out there to still make it worthwhile.

Zach

#3 lore raw
Quoted 3 lines · Zachary Amsden

Yes. Even then, last time I clocked instructions, xchg was still slower than read / write, although I could be misremembering. And it's not totally clear that they will always be in cached state, however, and for SMP, we still want to drop the implicit lock in cases where the processor might not know they are cached exclusive, but we know there are no other racing users. And there are plenty of old processors out there to still make it worthwhile.

Is there one processor that benefit from this patch then ?

I couldnt get a win on my test machines, maybe they are not old enough ;)

umask() doesnt need xchg() atomic semantic. If several threads are using umask() concurrently results are not guaranted anyway.

kernel/sys.c +4 -2
@@ -2138,8 +2138,10 @@ asmlinkage long sys_getrusage(int who, s
 
 asmlinkage long sys_umask(int mask)
 {
-	mask = xchg(&current->fs->umask, mask & S_IRWXUGO);
-	return mask;
+	struct fs_struct *fs = current->fs;
+	int old = fs->umask;
+	fs->umask = mask & S_IRWXUGO;
+	return old;
 }
     
 asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
#4 lore raw
Quoted 3 lines · Eric Dumazet

Is there one processor that benefit from this patch then ?

At least P5 systems should benefit.

-hpa

#5 lore raw
In reply to Zachary Amsden
Quoted 10 lines · Zachary Amsden
Quoted 2 lines

You do know that P6 and higher don't do locked bus references as long as the value is in the cache, right?

Yes. Even then, last time I clocked instructions, xchg was still slower than read / write, although I could be misremembering. And it's not totally clear that they will always be in cached state, however, and for SMP, we still want to drop the implicit lock in cases where the processor might not know they are cached exclusive, but we know there are no other racing users. And there are plenty of old processors out there to still make it worthwhile.

LOCKed instruction suck really badly on the netburst microarchitecture (like factor of 10x, or not far off). I think it's probably because of their side effect of serialising memory accesses, causing horrible pipeline stalls.

-- Keir

#6 lore raw
Quoted 13 lines · Keir Fraser
Quoted 10 lines · Zachary Amsden
Quoted 2 lines

You do know that P6 and higher don't do locked bus references as long as the value is in the cache, right?

Yes. Even then, last time I clocked instructions, xchg was still slower than read / write, although I could be misremembering. And it's not totally clear that they will always be in cached state, however, and for SMP, we still want to drop the implicit lock in cases where the processor might not know they are cached exclusive, but we know there are no other racing users. And there are plenty of old processors out there to still make it worthwhile.

Quoted 3 lines

LOCKed instruction suck really badly on the netburst microarchitecture (like factor of 10x, or not far off). I think it's probably because of their side effect of serialising memory accesses, causing horrible pipeline stalls.

Unfortunately they tend to be HyperThreaded usually (except for early ones and Celerons) and need the LOCK anyways.

-Andi

#7 lore raw
Quoted 6 lines · Andi Kleen
Quoted 3 lines

LOCKed instruction suck really badly on the netburst microarchitecture (like factor of 10x, or not far off). I think it's probably because of their side effect of serialising memory accesses, causing horrible pipeline stalls.

Unfortunately they tend to be HyperThreaded usually (except for early ones and Celerons) and need the LOCK anyways.

Fair point, although quite a few people disable HT.

-- Keir

#8 lore raw
Quoted 9 lines · Keir Fraser
Quoted 5 lines · Andi Kleen
Quoted 3 lines

LOCKed instruction suck really badly on the netburst microarchitecture (like factor of 10x, or not far off). I think it's probably because of their side effect of serialising memory accesses, causing horrible pipeline stalls.

Unfortunately they tend to be HyperThreaded usually (except for early ones and Celerons) and need the LOCK anyways.

Fair point, although quite a few people disable HT.

Note we're talking a UP-only hack.

-hpa