Remove silly debug path from get_vsid()
Andrew, please apply.
Currently the get_vsid() and get_kernel_vsid() functions have a test which enables a different VSID algorithm for debugging. Using a dumb VSID algorithm for stressing the hash table is a reasonable debugging tool, but switching it at runtime makes no sense at all. Plus it adds another test and memory access to the performance critical SLB miss path.
This patch removes the test, replacing it with a compile time switch. It seems to make a measurable, although small speedup to the SLB miss path (maybe 0.5%).
include/asm-ppc64/mmu_context.h +14 -14
@@ -189,15 +189,15 @@ ordinal = (((ea >>28 ) &0x1fff ) *LAST_USER_CONTEXT ) | (ea >>60 ); vsid = (ordinal *VSID_RANDOMIZER ) &VSID_MASK ; -ifppcdebug (PPCDBG_HTABSTRESS ) { -/* For debug, this path creates a very poor vsid distribuition. -* A user program can access virtual addresses in the form -* 0x0yyyyxxxx000 where yyyy = xxxx to cause multiple mappings -* to hash to the same page table group. -*/ - ordinal = ((ea >>28 ) &0x1fff ) | (ea >>44 ); - vsid = ordinal &VSID_MASK ; - } +#ifdef HTABSTRESS +/* For debug, this path creates a very poor vsid distribuition. +* A user program can access virtual addresses in the form +* 0x0yyyyxxxx000 where yyyy = xxxx to cause multiple mappings +* to hash to the same page table group. +*/ + ordinal = ((ea >>28 ) &0x1fff ) | (ea >>44 ); + vsid = ordinal &VSID_MASK ; +#endif /* HTABSTRESS */ return vsid; }
@@ -212,11 +212,11 @@ ordinal = (((ea >>28 ) &0x1fff ) *LAST_USER_CONTEXT ) | context; vsid = (ordinal *VSID_RANDOMIZER ) &VSID_MASK ; -ifppcdebug (PPCDBG_HTABSTRESS ) { -/* See comment above. */ - ordinal = ((ea >>28 ) &0x1fff ) | (context <<16 ); - vsid = ordinal &VSID_MASK ; - } +#ifdef HTABSTRESS +/* See comment above. */ + ordinal = ((ea >>28 ) &0x1fff ) | (context <<16 ); + vsid = ordinal &VSID_MASK ; +#endif /* HTABSTRESS */ return vsid; }
Signature · 4 lines
David Gibson | For every complex problem there is a david AT gibson.dropbear.id.au | solution which is simple, neat and | wrong. http://www.ozlabs.org/people/dgibson
Quoted 3 lines · David Gibson
This patch removes the test, replacing it with a compile time switch. It seems to make a measurable, although small speedup to the SLB miss path (maybe 0.5%).
Looking at include/asm-ppc64/ppcdebug.h the ifppcdebug() macro is defined:
#ifdef CONFIG_PPCDBG
#define ifppcdebug(FLAGS) if (udbg_ifdebug(FLAGS)) #else
#define ifppcdebug(...) if (0)
#endif
so presumably if you don't select CONFIG_PPCDBG it is also a no-op unless the compiler is broken and doesn't optimize away "if (0)" stanzas. The original construct gives you the option to enable this particular debugging at runtime (without necessarily enabling all debugging at one time) if wanted.
Quoted 57 lines
Index:
working-2.6/include/asm-ppc64/mmu_context.h
===================================================================include/asm-ppc64/mmu_context.h +14
-14@@ -189,15 +189,15 @@ ordinal = (((ea >>28 ) &0x1fff ) *LAST_USER_CONTEXT ) | (ea >>60 ); vsid = (ordinal *VSID_RANDOMIZER ) &VSID_MASK ; -ifppcdebug (PPCDBG_HTABSTRESS ) { -/* For debug, this path creates a very poor vsid distribuition. -* A user program can access virtual addresses in the form -* 0x0yyyyxxxx000 where yyyy = xxxx to cause multiple mappings -* to hash to the same page table group. -*/ - ordinal = ((ea >>28 ) &0x1fff ) | (ea >>44 ); - vsid = ordinal &VSID_MASK ; - } +#ifdef HTABSTRESS +/* For debug, this path creates a very poor vsid distribuition. +* A user program can access virtual addresses in the form +* 0x0yyyyxxxx000 where yyyy = xxxx to cause multiple mappings +* to hash to the same page table group. +*/ + ordinal = ((ea >>28 ) &0x1fff ) | (ea >>44 ); + vsid = ordinal &VSID_MASK ; +#endif /* HTABSTRESS */ return vsid; }@@ -212,11 +212,11 @@ ordinal = (((ea >>28 ) &0x1fff ) *LAST_USER_CONTEXT ) | context; vsid = (ordinal *VSID_RANDOMIZER ) &VSID_MASK ; -ifppcdebug (PPCDBG_HTABSTRESS ) { -/* See comment above. */ - ordinal = ((ea >>28 ) &0x1fff ) | (context <<16 ); - vsid = ordinal &VSID_MASK ; - } +#ifdef HTABSTRESS +/* See comment above. */ + ordinal = ((ea >>28 ) &0x1fff ) | (context <<16 ); + vsid = ordinal &VSID_MASK ; +#endif /* HTABSTRESS */ return vsid; }Signature · 10 lines
-- David Gibson | For every complex problem there is a david AT gibson.dropbear.id.au | solution which is simple, neat and | wrong. http://www.ozlabs.org/people/dgibson - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
Quoted 4 lines · Andreas Dilger
so presumably if you don't select
CONFIG_PPCDBGit is also a no-op unless the compiler is broken and doesn't optimize away "if (0)" stanzas. The original construct gives you the option to enable this particular debugging at runtime (without necessarily enabling all debugging at one time) if wanted.
And the effect of suddenly changing your VSID calculation algorithm in mid-stream is pretty catastrophic. There is no sensible reason wanting to be able to turn this on and off at runtime. This is not just some extra checking.
Paul.