From 96bf1d3ebd2f9a1051a60e880fb158ea4341b0bc Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 6 Oct 2024 16:02:13 +0000 Subject: [PATCH] kernel: remove unused lockstats and make lock() return type void remove the global statistics counters from taslock.c as they'r not particularily usefull nor precise and just cause unneccessary cache traffic. if we want them back, we should place them into the Mach structure. also change the lock() function prototype to return void. --- sys/src/9/port/portfns.h | 2 +- sys/src/9/port/taslock.c | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/sys/src/9/port/portfns.h b/sys/src/9/port/portfns.h index 02f298ef7..b3c598190 100644 --- a/sys/src/9/port/portfns.h +++ b/sys/src/9/port/portfns.h @@ -166,7 +166,7 @@ void (*kproftimer)(uintptr); void ksetenv(char*, char*, int); void kstrcpy(char*, char*, int); void kstrdup(char**, char*); -int lock(Lock*); +void lock(Lock*); void logopen(Log*); void logclose(Log*); char* logctl(Log*, int, char**, Logflag*); diff --git a/sys/src/9/port/taslock.c b/sys/src/9/port/taslock.c index 4a6330833..637240630 100644 --- a/sys/src/9/port/taslock.c +++ b/sys/src/9/port/taslock.c @@ -16,13 +16,6 @@ uintptr maxilockpc; uintptr ilockpcs[0x100] = { [0xff] = 1 }; #endif -struct -{ - ulong locks; - ulong glare; - ulong inglare; -} lockstats; - void lockloop(Lock *l, uintptr pc) { @@ -39,7 +32,7 @@ lockloop(Lock *l, uintptr pc) dumpaproc(p); } -int +void lock(Lock *l) { int i; @@ -47,7 +40,6 @@ lock(Lock *l) pc = getcallerpc(&l); - lockstats.locks++; if(up) up->nlocks++; /* prevent being scheded */ if(tas(&l->key) == 0){ @@ -60,14 +52,12 @@ lock(Lock *l) #ifdef LOCKCYCLES l->lockcycles = -lcycles(); #endif - return 0; + return; } if(up) up->nlocks--; - lockstats.glare++; for(;;){ - lockstats.inglare++; i = 0; while(l->key){ if(conf.nmach < 2 && up && up->edf && (up->edf->flags & Admitted)){ @@ -96,7 +86,7 @@ lock(Lock *l) #ifdef LOCKCYCLES l->lockcycles = -lcycles(); #endif - return 1; + return; } if(up) up->nlocks--; @@ -110,18 +100,15 @@ ilock(Lock *l) uintptr pc; pc = getcallerpc(&l); - lockstats.locks++; x = splhi(); if(tas(&l->key) != 0){ - lockstats.glare++; /* * Cannot also check l->pc, l->m, or l->isilock here * because they might just not be set yet, or * (for pc and m) the lock might have just been unlocked. */ for(;;){ - lockstats.inglare++; splx(x); while(l->key) ;