Commit c53f19ef authored by Stratos Psomadakis's avatar Stratos Psomadakis

Use XSEGLOG2 for xseg logging

parent 161bc32f
......@@ -162,7 +162,7 @@ __attribute__((always_inline)) static inline unsigned long xlock_acquire(struct
#ifdef XLOCK_CONGESTION_NOTIFY
if (!(times & ((1<<shift) -1))) {
xlock_unpack_owner(owner, &opid, &otid, &opc);
XSEGLOG("xlock %p spinned for %llu times"
XSEGLOG2(I, "xlock %p spinned for %llu times"
"\n\t who: (%d, %d, %p), "
"owner: (%d, %d, %p) (full pc: %p)",
(unsigned long) lock, times,
......
This diff is collapsed.
......@@ -43,7 +43,7 @@ static long posix_allocate(const char *name, uint64_t size)
fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0770);
if (fd < 0) {
err_no = errno;
XSEGLOG("Cannot create shared segment: %s\n",
XSEGLOG2(I, "Cannot create shared segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
ret = fd;
goto exit;
......@@ -53,7 +53,7 @@ static long posix_allocate(const char *name, uint64_t size)
if (lr == (off_t)-1) {
err_no = errno;
close(fd);
XSEGLOG("Cannot seek into segment file: %s\n",
XSEGLOG2(I, "Cannot seek into segment file: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
ret = lr;
goto exit;
......@@ -64,7 +64,7 @@ static long posix_allocate(const char *name, uint64_t size)
if (r != 1) {
err_no = errno;
close(fd);
XSEGLOG("Failed to set segment size: %s\n",
XSEGLOG2(I, "Failed to set segment size: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
ret = r;
goto exit;
......@@ -90,7 +90,7 @@ static void *posix_map(const char *name, uint64_t size, struct xseg *seg)
fd = shm_open(name, O_RDWR, 0000);
if (fd < 0) {
err_no = errno;
XSEGLOG("Failed to open '%s' for mapping: %s\n",
XSEGLOG2(I, "Failed to open '%s' for mapping: %s\n",
name, strerror_r(errno, errbuf, ERRSIZE));
errno = err_no;
return NULL;
......@@ -104,7 +104,7 @@ static void *posix_map(const char *name, uint64_t size, struct xseg *seg)
if (xseg == MAP_FAILED) {
err_no = errno;
XSEGLOG("Could not map segment: %s\n",
XSEGLOG2(I, "Could not map segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
errno = err_no;
return NULL;
......
......@@ -219,7 +219,7 @@ static int posixfd_wait_signal(struct xseg *xseg, void *sd, uint32_t usec_timeou
FD_SET(psd->fd, &fds);
r = select(psd->fd + 1, &fds, NULL, NULL, &tv);
//XSEGLOG("Tv sec: %ld, tv_usec: %ld", tv.tv_sec, tv.tv_usec);
//XSEGLOG2(I, "Tv sec: %ld, tv_usec: %ld", tv.tv_sec, tv.tv_usec);
if (r < 0) {
if (errno != EINTR) {
......
......@@ -43,7 +43,7 @@ static long pthread_allocate(const char *name, uint64_t size)
off_t lr;
fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0770);
if (fd < 0) {
XSEGLOG("Cannot create shared segment: %s\n",
XSEGLOG2(I, "Cannot create shared segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return fd;
}
......@@ -51,7 +51,7 @@ static long pthread_allocate(const char *name, uint64_t size)
lr = lseek(fd, size -1, SEEK_SET);
if (lr == (off_t)-1) {
close(fd);
XSEGLOG("Cannot seek into segment file: %s\n",
XSEGLOG2(I, "Cannot seek into segment file: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return lr;
}
......@@ -60,7 +60,7 @@ static long pthread_allocate(const char *name, uint64_t size)
r = write(fd, errbuf, 1);
if (r != 1) {
close(fd);
XSEGLOG("Failed to set segment size: %s\n",
XSEGLOG2(I, "Failed to set segment size: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return r;
}
......@@ -80,11 +80,11 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg)
int fd;
// if (seg)
// XSEGLOG("struct xseg * is not NULL. Ignoring...\n");
// XSEGLOG2(I, "struct xseg * is not NULL. Ignoring...\n");
fd = shm_open(name, O_RDWR, 0000);
if (fd < 0) {
XSEGLOG("Failed to open '%s' for mapping: %s\n",
XSEGLOG2(I, "Failed to open '%s' for mapping: %s\n",
name, strerror_r(errno, errbuf, ERRSIZE));
return NULL;
}
......@@ -96,7 +96,7 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg)
fd, 0 );
if (xseg == MAP_FAILED) {
XSEGLOG("Could not map segment: %s\n",
XSEGLOG2(I, "Could not map segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return NULL;
}
......
......@@ -67,7 +67,7 @@ void __load_plugin(const char *name)
_name[5 + namelen + 3 ] = 0;
dl = dlopen(_name, RTLD_NOW);
if (!dl) {
XSEGLOG("Cannot load plugin '%s': %s\n", _name, dlerror());
XSEGLOG2(I, "Cannot load plugin '%s': %s\n", _name, dlerror());
return;
}
......@@ -75,12 +75,12 @@ void __load_plugin(const char *name)
_name[127] = 0;
init = (void (*)(void))(long)dlsym(dl, _name);
if (!init) {
XSEGLOG("Init function '%s' not found!\n", _name);
XSEGLOG2(I, "Init function '%s' not found!\n", _name);
return;
}
init();
//XSEGLOG("Plugin '%s' loaded.\n", name);
//XSEGLOG2(I, "Plugin '%s' loaded.\n", name);
}
uint64_t __get_id(void)
......@@ -162,9 +162,9 @@ void xseg_printtrace(void)
return;
}
XSEGLOG("Backtrace of tid %d:", tid);
XSEGLOG2(I, "Backtrace of tid %d:", tid);
for (i = 0; i < size; ++i)
{
XSEGLOG("\t%s", bt[i]);
XSEGLOG2(I, "\t%s", bt[i]);
}
}
......@@ -34,12 +34,12 @@ static inline void swap_nodes(struct xbinheap *h, xbinheapidx a, xbinheapidx b)
xbinheapidx h1, h2;
h1 = h->nodes[a].h;
h2 = h->nodes[b].h;
//XSEGLOG("Swaping %llu, %llu", a, b);
//XSEGLOG2(I, "Swaping %llu, %llu", a, b);
SWAP(h->nodes[a].key, h->nodes[b].key);
SWAP(h->nodes[a].value, h->nodes[b].value);
SWAP(h->nodes[a].h, h->nodes[b].h);
SWAP(h->indexes[h1], h->indexes[h2]);
//XSEGLOG("Index[%llu]: %llu, Index[%llu]: %lli", a, h->indexes[a], b, h->indexes[b]);
//XSEGLOG2(I, "Index[%llu]: %llu, Index[%llu]: %lli", a, h->indexes[a], b, h->indexes[b]);
}
static inline int isMaxHeap(struct xbinheap *h)
......@@ -57,7 +57,7 @@ static int heapify_up(struct xbinheap *h, xbinheapidx i)
parent = (i-1)/2;
n = &h->nodes[i];
pn = &h->nodes[parent];
//XSEGLOG("i: %llu, p: %llu, count: %lu", n->key, pn->key, h->count);
//XSEGLOG2(I, "i: %llu, p: %llu, count: %lu", n->key, pn->key, h->count);
if (isMaxHeap(h)){
cmp = pn->key < n->key;
} else {
......@@ -83,7 +83,7 @@ static int heapify_down(struct xbinheap *h, xbinheapidx i)
rn = &h->nodes[right];
largest_n = &h->nodes[largest];
if (isMaxHeap(h)){
// XSEGLOG("l: %llu, r: %llu, p: %llu, count: %lu", ln->key, rn->key, largest_n->key, h->count);
// XSEGLOG2(I, "l: %llu, r: %llu, p: %llu, count: %lu", ln->key, rn->key, largest_n->key, h->count);
if (left < h->count && (ln->key > largest_n->key)){
largest = left;
largest_n = &h->nodes[largest];
......@@ -159,7 +159,7 @@ int xbinheap_increasekey(struct xbinheap *h, xbinheap_handler idx,
int r;
xbinheapidx i = h->indexes[idx];
struct xbinheap_node *hn = &h->nodes[i];
//XSEGLOG("h: %llu, index: %llu, key: %llu, newkey:%llu",
//XSEGLOG2(I, "h: %llu, index: %llu, key: %llu, newkey:%llu",
// idx, i, hn->key, newkey);
//assert newkey > hn->key
hn->key = newkey;
......@@ -217,7 +217,7 @@ int xbinheap_decreasekey(struct xbinheap *h, xbinheap_handler idx,
int r;
xbinheapidx i = h->indexes[idx];
struct xbinheap_node *hn = &h->nodes[i];
//XSEGLOG("h: %llu, index: %llu, key: %llu, newkey:%llu",
//XSEGLOG2(I, "h: %llu, index: %llu, key: %llu, newkey:%llu",
// idx, i, hn->key, newkey);
//assert newkey > hn->key
hn->key = newkey;
......
......@@ -39,7 +39,7 @@ static xqindex __alloc_cache_entry(struct xcache *cache)
static void __free_cache_entry(struct xcache *cache, xqindex idx)
{
if (__xq_append_head(&cache->free_nodes, idx) == Noneidx)
XSEGLOG("BUG: Could not free cache entry node. Queue is full");
XSEGLOG2(I, "BUG: Could not free cache entry node. Queue is full");
}
#endif
......@@ -61,10 +61,10 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler
r = xhash_insert(*table, (xhashidx)ce->name, idx);
if (r == -XHASH_ERESIZE){
XSEGLOG("Rebuilding internal hash table");
XSEGLOG2(I, "Rebuilding internal hash table");
new = xhash_resize(*table, (*table)->size_shift, (*table)->limit, NULL);
if (!new) {
XSEGLOG("Error resizing hash table");
XSEGLOG2(I, "Error resizing hash table");
return -1;
}
*table = new;
......@@ -72,7 +72,7 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler
/* We give insertion a second shot */
r = xhash_insert(*table, (xhashidx)ce->name, idx);
if (r == -XHASH_ERESIZE) {
XSEGLOG("BUG: failed to insert entry after resize");
XSEGLOG2(I, "BUG: failed to insert entry after resize");
return -1;
}
}
......@@ -87,9 +87,9 @@ static int __table_remove(xhash_t *table, char *name)
r = xhash_delete(table, (xhashidx)name);
if (UNLIKELY(r<0)){
if (r == -XHASH_ERESIZE)
XSEGLOG("BUG: hash table must be resized");
XSEGLOG2(I, "BUG: hash table must be resized");
else if (r == -XHASH_EEXIST)
XSEGLOG("BUG: Entry %s not found in hash table", name);
XSEGLOG2(I, "BUG: Entry %s not found in hash table", name);
}
return r;
}
......@@ -102,7 +102,7 @@ static xqindex alloc_cache_entry(struct xcache *cache)
static void __free_cache_entry(struct xcache *cache, xqindex idx)
{
if (UNLIKELY(xq_append_head(&cache->free_nodes, idx) == Noneidx))
XSEGLOG("BUG: Could not free cache entry node. Queue is full");
XSEGLOG2(I, "BUG: Could not free cache entry node. Queue is full");
}
static void free_cache_entry(struct xcache *cache, xqindex idx)
......@@ -110,7 +110,7 @@ static void free_cache_entry(struct xcache *cache, xqindex idx)
struct xcache_entry *ce = &cache->nodes[idx];
if (ce->ref != 0)
XSEGLOG("BUG: Free entry has ref %lu (priv: %p, h: %p)", ce->priv, idx);
XSEGLOG2(I, "BUG: Free entry has ref %lu (priv: %p, h: %p)", ce->priv, idx);
__free_cache_entry(cache, idx);
if (cache->ops.on_free)
......@@ -175,7 +175,7 @@ static void __update_access_time(struct xcache *cache, xqindex idx)
} else {
ce->h = xbinheap_insert(&cache->binheap, cache->time, idx);
if (ce->h == NoNode){
XSEGLOG("BUG: Cannot insert to lru binary heap");
XSEGLOG2(I, "BUG: Cannot insert to lru binary heap");
}
}
}
......@@ -207,7 +207,7 @@ static int __xcache_remove_entries(struct xcache *cache, xcache_handler h)
r = __table_remove(cache->entries, ce->name);
if (UNLIKELY(r < 0)){
XSEGLOG("Couldn't delete cache entry from hash table:\n"
XSEGLOG2(I, "Couldn't delete cache entry from hash table:\n"
"h: %llu, name: %s, cache->nodes[h].priv: %p, ref: %llu",
h, ce->name, cache->nodes[idx].priv, cache->nodes[idx].ref);
return r;
......@@ -218,15 +218,15 @@ static int __xcache_remove_entries(struct xcache *cache, xcache_handler h)
else if (cache->flags & XCACHE_LRU_HEAP) {
if (ce->h != NoNode) {
if (xbinheap_increasekey(&cache->binheap, ce->h, XCACHE_LRU_MAX) < 0){
XSEGLOG("BUG: cannot increase key to XCACHE_LRU_MAX");
XSEGLOG2(I, "BUG: cannot increase key to XCACHE_LRU_MAX");
}
if (xbinheap_extract(&cache->binheap) == NoNode){
XSEGLOG("BUG: cannot remove cache entry from lru");
XSEGLOG2(I, "BUG: cannot remove cache entry from lru");
}
ce->h = NoNode;
}
}
//XSEGLOG("cache->times[%llu] = %llu", idx, cache->times[idx]);
//XSEGLOG2(I, "cache->times[%llu] = %llu", idx, cache->times[idx]);
return 0;
}
......@@ -242,7 +242,7 @@ static int __xcache_remove_rm(struct xcache *cache, xcache_handler h)
r = __table_remove(cache->rm_entries, ce->name);
if (UNLIKELY(r < 0)) {
XSEGLOG("Couldn't delete cache entry from hash table:\n"
XSEGLOG2(I, "Couldn't delete cache entry from hash table:\n"
"h: %llu, name: %s, cache->nodes[h].priv: %p, ref: %llu",
h, ce->name, cache->nodes[idx].priv, cache->nodes[idx].ref);
}
......@@ -364,7 +364,7 @@ static int xcache_entry_init(struct xcache *cache, xqindex idx, char *name)
xlock_release(&ce->lock);
if (UNLIKELY(ce->ref != 0))
XSEGLOG("BUG: New entry has ref != 0 (h: %lu, ref: %lu, priv: %p)",
XSEGLOG2(I, "BUG: New entry has ref != 0 (h: %lu, ref: %lu, priv: %p)",
idx, ce->ref, ce->priv);
ce->ref = 1;
strncpy(ce->name, name, XSEG_MAX_TARGETLEN);
......@@ -387,7 +387,7 @@ static xqindex __xcache_lru(struct xcache *cache)
if (cache->flags & XCACHE_LRU_ARRAY){
for (i = 0; i < cache->nr_nodes; i++) {
//XSEGLOG("cache->times[%llu] = %llu", i, cache->times[i]);
//XSEGLOG2(I, "cache->times[%llu] = %llu", i, cache->times[i]);
if (min > cache->times[i]){
min = cache->times[i];
lru = i;
......@@ -395,7 +395,7 @@ static xqindex __xcache_lru(struct xcache *cache)
}
//FIXME if cache->times[lru] == XCACHE_LRU_MAX
// lru = NoEntry;
//XSEGLOG("Found lru cache->times[%llu] = %llu", lru, cache->times[lru]);
//XSEGLOG2(I, "Found lru cache->times[%llu] = %llu", lru, cache->times[lru]);
} else if (cache->flags & XCACHE_LRU_HEAP) {
lru = xbinheap_extract(&cache->binheap);
if (lru == NoNode)
......@@ -418,7 +418,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
r = __xcache_remove_entries(cache, h);
if (r < 0) {
XSEGLOG("Failed to evict %llu from entries", h);
XSEGLOG2(I, "Failed to evict %llu from entries", h);
return -1;
}
......@@ -429,7 +429,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
ce = &cache->nodes[h];
if (UNLIKELY(ce->state == NODE_EVICTED))
XSEGLOG("BUG: Evicting an already evicted entry (h: %lu, priv: %p)",
XSEGLOG2(I, "BUG: Evicting an already evicted entry (h: %lu, priv: %p)",
h, ce->priv);
if (!(cache->flags & XCACHE_USE_RMTABLE))
......@@ -442,7 +442,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
if (r < 0) {
ce->state = NODE_ACTIVE;
XSEGLOG("BUG: Failed insert %llu to rm_entries", h);
XSEGLOG2(I, "BUG: Failed insert %llu to rm_entries", h);
return -1;
}
......@@ -456,7 +456,7 @@ static xcache_handler __xcache_evict_lru(struct xcache *cache)
lru = __xcache_lru(cache);
if (lru == NoEntry){
XSEGLOG("BUG: No lru found");
XSEGLOG2(I, "BUG: No lru found");
return NoEntry;
}
......@@ -519,7 +519,7 @@ static xcache_handler __xcache_insert(struct xcache *cache, xcache_handler h,
/* if so then remove it from rm table */
r = __xcache_remove_rm(cache, tmp_h);
if (UNLIKELY(r < 0)) {
XSEGLOG("Could not remove found entry (%llu) for %s"
XSEGLOG2(I, "Could not remove found entry (%llu) for %s"
"from rm_entries", tmp_h, ce->name);
xlock_release(&cache->rm_lock);
return NoEntry;
......@@ -528,7 +528,7 @@ static xcache_handler __xcache_insert(struct xcache *cache, xcache_handler h,
/* and prepare it for reinsertion */
ce = &cache->nodes[tmp_h];
if (UNLIKELY(ce->state != NODE_EVICTED))
XSEGLOG("BUG: Entry (%llu) in rm table not in evicted state", tmp_h);
XSEGLOG2(I, "BUG: Entry (%llu) in rm table not in evicted state", tmp_h);
ce->state = NODE_ACTIVE;
__xcache_entry_get(cache, tmp_h);
......@@ -543,7 +543,7 @@ insert:
if (r == -XHASH_ENOSPC){
lru = __xcache_evict_lru(cache);
if (UNLIKELY(lru == NoEntry)) {
XSEGLOG("BUG: Failed to evict lru entry");
XSEGLOG2(I, "BUG: Failed to evict lru entry");
return NoEntry;
}
*lru_handler = lru;
......@@ -554,13 +554,13 @@ insert:
*/
r = __xcache_insert_entries(cache, h);
if (r < 0) {
XSEGLOG("BUG: failed to insert enries after eviction");
XSEGLOG2(I, "BUG: failed to insert enries after eviction");
return NoEntry;
}
}
if (UNLIKELY(r >= 0 && ce->ref == 0))
XSEGLOG("BUG: (Re)inserted entry has ref 0 (priv: %p, h: %lu)",
XSEGLOG2(I, "BUG: (Re)inserted entry has ref 0 (priv: %p, h: %lu)",
ce->priv, h);
if (r >= 0)
......@@ -592,7 +592,7 @@ xcache_handler xcache_insert(struct xcache *cache, xcache_handler h)
if (lru != NoEntry) {
if (UNLIKELY(ret == NoEntry))
XSEGLOG("BUG: Unsuccessful insertion lead to LRU eviction.");
XSEGLOG2(I, "BUG: Unsuccessful insertion lead to LRU eviction.");
ce = &cache->nodes[lru];
if (cache->ops.on_evict)
cache->ops.on_evict(cache->priv, ce->priv);
......@@ -601,7 +601,7 @@ xcache_handler xcache_insert(struct xcache *cache, xcache_handler h)
if (reinsert_handler != NoEntry) {
if (UNLIKELY(ret != reinsert_handler))
XSEGLOG("BUG: Re-insert handler is different from returned handler"
XSEGLOG2(I, "BUG: Re-insert handler is different from returned handler"
"(rei_h = %llu, ret_h = %llu)", reinsert_handler, ret);
ce = &cache->nodes[reinsert_handler];
if (cache->ops.on_reinsert)
......@@ -685,7 +685,7 @@ int xcache_init(struct xcache *cache, uint32_t xcache_size,
cache->size = ceil_size;
if (cache->size != xcache_size)
XSEGLOG("Cache has been resized from %lu entries to %lu entries",
XSEGLOG2(I, "Cache has been resized from %lu entries to %lu entries",
xcache_size, cache->size);
/*
......
......@@ -56,7 +56,7 @@ static inline xhashidx hash_string(xhashidx key)
if (hv == Noxhashidx)
hv = Noxhashidx -1;
// XSEGLOG("String %s (%lx). Hash value: %llu",
// XSEGLOG2(I, "String %s (%lx). Hash value: %llu",
// string, string, hv);
return hv;
}
......@@ -66,7 +66,7 @@ static inline int cmp_string(xhashidx key1, xhashidx key2)
char *string1 = (char *) key1;
char *string2 = (char *) key2;
int value = !strcmp(string1, string2);
// XSEGLOG("String1 %s (%lx), string2: %s(%lx), r: %d",
// XSEGLOG2(I, "String1 %s (%lx), string2: %s(%lx), r: %d",
// string1, (unsigned long) string1,
// string2, (unsigned long) string2,
// value);
......@@ -260,7 +260,7 @@ xhash_new__(xhashidx size_shift, xhashidx minsize_shift, xhashidx limit,
struct xhash *xhash;
xhash = xtypes_malloc(get_alloc_size(size_shift, vals));
if (!xhash) {
XSEGLOG("couldn't malloc\n");
XSEGLOG2(I, "couldn't malloc\n");
return NULL;
}
......@@ -281,7 +281,7 @@ xhash_resize__(struct xhash *xhash, xhashidx new_size_shift, xhashidx new_limit,
int
xhash_delete__(xhash_t *xhash, xhashidx key, bool vals)
{
// XSEGLOG("Deleting %lx", key);
// XSEGLOG2(I, "Deleting %lx", key);
xhash_cmp_fun_t cmp_fun = types_fun[xhash->type].cmp_fun;
xhash_hash_fun_t hash_fun = types_fun[xhash->type].hash_fun;
xhashidx perturb = hash_fun(key);
......@@ -445,7 +445,7 @@ set_val(xhash_t *p, xhashidx idx, xhashidx key, xhashidx val)
xhashidx *vals = xhash_vals(p);
kvs[idx] = key;
vals[idx] = val;
//XSEGLOG("Seting idx %llu to key: %lx, val: %lx", idx, key, val);
//XSEGLOG2(I, "Seting idx %llu to key: %lx, val: %lx", idx, key, val);
}
void static inline xhash_upd_set(xhash_t *p, xhashidx idx, xhashidx key, xhashidx val)
......@@ -457,7 +457,7 @@ void static inline xhash_upd_set(xhash_t *p, xhashidx idx, xhashidx key, xhashid
p->used++;
kvs[idx] = key;
vals[idx] = val;
//XSEGLOG("Seting idx %llu to key: %lx, val: %lx", idx, key, val);
//XSEGLOG2(I, "Seting idx %llu to key: %lx, val: %lx", idx, key, val);
}
static inline void
......@@ -469,7 +469,7 @@ inc_val(xhash_t *p, xhashidx idx, xhashidx val)
void xhash_insert__(struct xhash *xhash, xhashidx key, xhashidx val)
{
//XSEGLOG("inserting %lx", key);
//XSEGLOG2(I, "inserting %lx", key);
//fprintf(stderr, "insert: (%lu,%lu)\n", key, val);
#define PHUPD_UPDATE__(_p, _i, _k, _v) set_val(_p, _i, _k, _v)
#define PHUPD_SET__(_p, _i, _k, _v) xhash_upd_set(_p, _i, _k, _v)
......@@ -510,7 +510,7 @@ xhash_t *
xhash_resize(xhash_t *xhash, xhashidx new_size_shift, xhashidx new_limit,
xhash_t *new)
{
//XSEGLOG("Resizing xhash from %llu to %llu", xhash->size_shift, new_size_shift);
//XSEGLOG2(I, "Resizing xhash from %llu to %llu", xhash->size_shift, new_size_shift);
xhashidx i;
int f = !!new;
if (!f)
......@@ -562,7 +562,7 @@ int xhash_delete(struct xhash *xhash, xhashidx key)
int xhash_lookup__(xhash_t *xhash, xhashidx key, xhashidx *idx_ret, bool vals)
{
//XSEGLOG("looking up %lx", key);
//XSEGLOG2(I, "looking up %lx", key);
xhash_cmp_fun_t cmp_fun = types_fun[xhash->type].cmp_fun;
xhash_hash_fun_t hash_fun = types_fun[xhash->type].hash_fun;
xhashidx size_shift = xhash->size_shift;
......@@ -574,7 +574,7 @@ int xhash_lookup__(xhash_t *xhash, xhashidx key, xhashidx *idx_ret, bool vals)
INCSTAT(xhash->lookups);
for (;;) {
//XSEGLOG("size %llu, perturb %llu idx %llu mask %llu",
//XSEGLOG2(I, "size %llu, perturb %llu idx %llu mask %llu",
// size, perturb, idx, mask);
if ( item_unused(xhash, idx, vals) )
return -XHASH_EEXIST;
......@@ -650,15 +650,15 @@ void xhash_print(xhash_t *xhash)
int ret;
xhash_iter_init(xhash, &pi);
XSEGLOG("PHASH(%p):\n", xhash);
XSEGLOG2(I, "PHASH(%p):\n", xhash);
for (;;){
ret = xhash_iterate(xhash, &pi, &key, &val);
if (!ret){
break;
}
XSEGLOG(" 0x%017lx : 0x%017lx\n", key, val);
XSEGLOG2(I, " 0x%017lx : 0x%017lx\n", key, val);
}
XSEGLOG("\n");
XSEGLOG2(I, "\n");
}
#ifdef PHASH_MAIN
......
......@@ -66,7 +66,7 @@ static inline int __get_index(struct xheap *heap, uint64_t bytes)
r = (1 << SMALL_LIMIT);
//r -= (1 << (alignment_unit+SMALL_LIMIT)) / (1 << (alignment_unit + MEDIUM_AL_UNIT));
r -= (1 << (SMALL_LIMIT - MEDIUM_AL_UNIT));
//XSEGLOG("%u, %u, r %d\n",((1<<alignment_unit) * 32), (1 << (alignment_unit +2)), r);
//XSEGLOG2(I, "%u, %u, r %d\n",((1<<alignment_unit) * 32), (1 << (alignment_unit +2)), r);
r += (bytes >> (alignment_unit + MEDIUM_AL_UNIT));
}
else {
......@@ -100,12 +100,12 @@ void* xheap_allocate(struct xheap *heap, uint64_t bytes)
if (!head)
goto alloc;
if (head > heap->cur) {
XSEGLOG("invalid xptr %llu found in chunk lists\n", head);
XSEGLOG2(I, "invalid xptr %llu found in chunk lists\n", head);
goto out;
}
next = *(xptr *)(((unsigned long) mem) + head);
free_list[r] = next;
// XSEGLOG("alloced %llu bytes from list %d\n", bytes, r);
// XSEGLOG2(I, "alloced %llu bytes from list %d\n", bytes, r);
// printf("popped %llu out of list. list is now %llu\n", head, next);
addr = (void *) (((unsigned long)mem) + head);
goto out;
......@@ -129,13 +129,13 @@ out:
// printf("alloced: %lx (size: %llu) (xptr: %llu)\n", addr, __get_header(addr)->size,
// addr-mem);
if (addr && xheap_get_chunk_size(addr) < req_bytes){
XSEGLOG("requested %llu bytes but heap returned %llu",
XSEGLOG2(I, "requested %llu bytes but heap returned %llu",
req_bytes, xheap_get_chunk_size(addr));
addr = NULL;
}
if (addr && xheap_get_chunk_size(addr) != (__get_alloc_bytes(heap, req_bytes) -
sizeof(struct xheap_header))) {
XSEGLOG("allocated chunk size %llu, but it should be %llu (req_bytes %llu)",
XSEGLOG2(I, "allocated chunk size %llu, but it should be %llu (req_bytes %llu)",
xheap_get_chunk_size(addr), __get_alloc_bytes(heap, req_bytes), req_bytes);
addr = NULL;
}
......@@ -168,7 +168,7 @@ void xheap_free(void *ptr)
int r;
xptr *free_list;
if (h->magic != 0xdeadbeaf) {
XSEGLOG("for ptr: %lx, magic %lx != 0xdeadbeaf", ptr, h->magic);
XSEGLOG2(I, "for ptr: %lx, magic %lx != 0xdeadbeaf", ptr, h->magic);
}
mem = XPTR(&heap->mem);
size = xheap_get_chunk_size(ptr);
......@@ -177,7 +177,7 @@ void xheap_free(void *ptr)
//printf("size: %llu, r: %d\n", size, r);
__add_in_free_list(heap, &free_list[r], ptr);
// printf("freed %lx (size: %llu)\n", ptr, __get_header(ptr)->size);
// XSEGLOG("freed %llu bytes to list %d\n", size, r);
// XSEGLOG2(I, "freed %llu bytes to list %d\n", size, r);
return;
}
......
......@@ -121,7 +121,7 @@ void xq_print(struct xq *xq)
{
xqindex i;
XSEGLOG("xq head: %lu, tail: %lu, size: %lu\n",
XSEGLOG2(I, "xq head: %lu, tail: %lu, size: %lu\n",
(unsigned long)xq->head,
(unsigned long)xq->tail,
(unsigned long)xq->size);
......@@ -130,7 +130,7 @@ void xq_print(struct xq *xq)
for (;;) {
if (i == xq->head)
break;
XSEGLOG( "%lu %lu\n",
XSEGLOG2(I, "%lu %lu\n",
(unsigned long)i,
(unsigned long)xq_element(xq, i) );
i += 1;
......
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