libc: improve alignment of QLp structure on amd64, cosmetics

the QLp structure used to occupy 24 bytes on amd64.
with some rearranging the fields we can get it to 16 bytes,
saving 8K in the data section for the 1024 preallocated
structs in the ql arena.

the rest of the changes are of cosmetic nature:

- getqlp() zeros the next pointer, so there is no need to set
  it when queueing the entry.

- always explicitely compare pointers to nil.

- delete unused code from ape's qlock.c
This commit is contained in:
cinap_lenrek 2017-10-28 18:53:27 +02:00
parent 4fc4b0dda7
commit 3794b1c14f
4 changed files with 9 additions and 267 deletions

View file

@ -39,10 +39,10 @@ getqlp(void)
abort();
if(_tas(&(p->inuse)) == 0){
ql.p = p;
p->next = nil;
break;
}
}
p->next = nil;
return p;
}
@ -128,12 +128,11 @@ rlock(RWLock *q)
mp = getqlp();
p = q->tail;
if(p == 0)
if(p == nil)
q->head = mp;
else
p->next = mp;
q->tail = mp;
mp->next = nil;
mp->state = QueuingR;
unlock(&q->lock);
@ -199,14 +198,13 @@ wlock(RWLock *q)
}
/* wait */
p = q->tail;
mp = getqlp();
p = q->tail;
if(p == nil)
q->head = mp;
else
p->next = mp;
q->tail = mp;
mp->next = nil;
mp->state = QueuingW;
unlock(&q->lock);
@ -286,7 +284,7 @@ rsleep(Rendez *r)
{
QLp *t, *me;
if(!r->l)
if(r->l == nil)
abort();
lock(&r->l->lock);
/* we should hold the qlock */
@ -300,12 +298,11 @@ rsleep(Rendez *r)
r->head = me;
else
r->tail->next = me;
me->next = nil;
r->tail = me;
/* pass the qlock to the next guy */
t = r->l->head;
if(t){
if(t != nil){
r->l->head = t->next;
if(r->l->head == nil)
r->l->tail = nil;
@ -333,7 +330,7 @@ rwakeup(Rendez *r)
* put on front so guys that have been waiting will not get starved
*/
if(!r->l)
if(r->l == nil)
abort();
lock(&r->l->lock);
if(!r->l->locked)