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.
This commit is contained in:
cinap_lenrek 2024-10-06 16:02:13 +00:00
parent 40177b86bf
commit 96bf1d3ebd
2 changed files with 4 additions and 17 deletions

View file

@ -166,7 +166,7 @@ void (*kproftimer)(uintptr);
void ksetenv(char*, char*, int); void ksetenv(char*, char*, int);
void kstrcpy(char*, char*, int); void kstrcpy(char*, char*, int);
void kstrdup(char**, char*); void kstrdup(char**, char*);
int lock(Lock*); void lock(Lock*);
void logopen(Log*); void logopen(Log*);
void logclose(Log*); void logclose(Log*);
char* logctl(Log*, int, char**, Logflag*); char* logctl(Log*, int, char**, Logflag*);

View file

@ -16,13 +16,6 @@ uintptr maxilockpc;
uintptr ilockpcs[0x100] = { [0xff] = 1 }; uintptr ilockpcs[0x100] = { [0xff] = 1 };
#endif #endif
struct
{
ulong locks;
ulong glare;
ulong inglare;
} lockstats;
void void
lockloop(Lock *l, uintptr pc) lockloop(Lock *l, uintptr pc)
{ {
@ -39,7 +32,7 @@ lockloop(Lock *l, uintptr pc)
dumpaproc(p); dumpaproc(p);
} }
int void
lock(Lock *l) lock(Lock *l)
{ {
int i; int i;
@ -47,7 +40,6 @@ lock(Lock *l)
pc = getcallerpc(&l); pc = getcallerpc(&l);
lockstats.locks++;
if(up) if(up)
up->nlocks++; /* prevent being scheded */ up->nlocks++; /* prevent being scheded */
if(tas(&l->key) == 0){ if(tas(&l->key) == 0){
@ -60,14 +52,12 @@ lock(Lock *l)
#ifdef LOCKCYCLES #ifdef LOCKCYCLES
l->lockcycles = -lcycles(); l->lockcycles = -lcycles();
#endif #endif
return 0; return;
} }
if(up) if(up)
up->nlocks--; up->nlocks--;
lockstats.glare++;
for(;;){ for(;;){
lockstats.inglare++;
i = 0; i = 0;
while(l->key){ while(l->key){
if(conf.nmach < 2 && up && up->edf && (up->edf->flags & Admitted)){ if(conf.nmach < 2 && up && up->edf && (up->edf->flags & Admitted)){
@ -96,7 +86,7 @@ lock(Lock *l)
#ifdef LOCKCYCLES #ifdef LOCKCYCLES
l->lockcycles = -lcycles(); l->lockcycles = -lcycles();
#endif #endif
return 1; return;
} }
if(up) if(up)
up->nlocks--; up->nlocks--;
@ -110,18 +100,15 @@ ilock(Lock *l)
uintptr pc; uintptr pc;
pc = getcallerpc(&l); pc = getcallerpc(&l);
lockstats.locks++;
x = splhi(); x = splhi();
if(tas(&l->key) != 0){ if(tas(&l->key) != 0){
lockstats.glare++;
/* /*
* Cannot also check l->pc, l->m, or l->isilock here * Cannot also check l->pc, l->m, or l->isilock here
* because they might just not be set yet, or * because they might just not be set yet, or
* (for pc and m) the lock might have just been unlocked. * (for pc and m) the lock might have just been unlocked.
*/ */
for(;;){ for(;;){
lockstats.inglare++;
splx(x); splx(x);
while(l->key) while(l->key)
; ;