Commit e5ce5d7a authored by Filippos Giannakos's avatar Filippos Giannakos

xlock: Add 'xlock_' prefix to {pack, unpack}_owner

parent 875faedf
......@@ -93,7 +93,7 @@ _Static_assert(PC_BITS < sizeof(void *) * 8,
"PC_BITS must be lower than the bits of a (void *)")
*/
static inline xlock_owner_t pack_owner(pid_t pid, pid_t tid, void *ip)
static inline xlock_owner_t xlock_pack_owner(pid_t pid, pid_t tid, void *ip)
{
xlock_owner_t owner = 0;
unsigned long pc = (unsigned long)ip;
......@@ -111,15 +111,22 @@ static inline xlock_owner_t pack_owner(pid_t pid, pid_t tid, void *ip)
return owner;
}
static inline void unpack_owner(uint64_t owner, pid_t *pid, pid_t *tid, void **ip)
static inline void xlock_unpack_owner(uint64_t owner, pid_t *pid, pid_t *tid, void **ip)
{
unsigned long pc;
pc = owner & (((xlock_owner_t)1 << PC_BITS) -1);
*ip = (void *)pc;
if (ip) {
pc = owner & (((xlock_owner_t)1 << PC_BITS) -1);
*ip = (void *)pc;
}
owner >>= PC_BITS;
*tid = owner & (((xlock_owner_t)1 << TID_BITS) -1);
if (tid) {
*tid = owner & (((xlock_owner_t)1 << TID_BITS) -1);
}
owner >>= TID_BITS;
*pid = owner & (((xlock_owner_t)1 << PID_BITS) -1);
if (pid) {
*pid = owner & (((xlock_owner_t)1 << PID_BITS) -1);
}
}
__attribute__((always_inline)) static inline unsigned long xlock_acquire(struct xlock *lock)
......@@ -137,13 +144,13 @@ xlock_acquire_label:
tid = gettid();
pc = &&xlock_acquire_label;
who = pack_owner(pid, tid, pc);
who = xlock_pack_owner(pid, tid, pc);
for (;;) {
for (; (owner = *(volatile xlock_owner_t*)(&lock->owner)) != XLOCK_NOONE;) {
#ifdef XLOCK_CONGESTION_NOTIFY
if (!(times & ((1<<shift) -1))) {
unpack_owner(owner, &opid, &otid, &opc);
xlock_unpack_owner(owner, &opid, &otid, &opc);
XSEGLOG("xlock %p spinned for %llu times"
"\n\t who: (%d, %d, %p), "
"owner: (%d, %d, %p) (full pc: %p)",
......@@ -183,7 +190,7 @@ xlock_try_lock_label:
tid = gettid();
pc = &&xlock_try_lock_label;
who = pack_owner(pid, tid, pc);
who = xlock_pack_owner(pid, tid, pc);
owner = *(volatile xlock_owner_t*)(&lock->owner);
if (owner == XLOCK_NOONE &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment