Commit 88fd78df authored by Stratos Psomadakis's avatar Stratos Psomadakis

Adjust xseg logging levels

parent eef48993
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;
XSEGLOG2(I, "Cannot create shared segment: %s\n",
XSEGLOG2(W, "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);
XSEGLOG2(I, "Cannot seek into segment file: %s\n",
XSEGLOG2(W, "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);
XSEGLOG2(I, "Failed to set segment size: %s\n",
XSEGLOG2(w, "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;
XSEGLOG2(I, "Failed to open '%s' for mapping: %s\n",
XSEGLOG2(W, "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;
XSEGLOG2(I, "Could not map segment: %s\n",
XSEGLOG2(W, "Could not map segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
errno = err_no;
return NULL;
......
......@@ -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) {
XSEGLOG2(I, "Cannot create shared segment: %s\n",
XSEGLOG2(W, "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);
XSEGLOG2(I, "Cannot seek into segment file: %s\n",
XSEGLOG2(W, "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);
XSEGLOG2(I, "Failed to set segment size: %s\n",
XSEGLOG2(W, "Failed to set segment size: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return r;
}
......@@ -84,7 +84,7 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg)
fd = shm_open(name, O_RDWR, 0000);
if (fd < 0) {
XSEGLOG2(I, "Failed to open '%s' for mapping: %s\n",
XSEGLOG2(W, "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) {
XSEGLOG2(I, "Could not map segment: %s\n",
XSEGLOG2(W, "Could not map segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
return NULL;
}
......
......@@ -65,7 +65,7 @@ void __load_plugin(const char *name)
_name[5 + namelen + 3 ] = 0;
dl = dlopen(_name, RTLD_NOW);
if (!dl) {
XSEGLOG2(I, "Cannot load plugin '%s': %s\n", _name, dlerror());
XSEGLOG2(W, "Cannot load plugin '%s': %s\n", _name, dlerror());
return;
}
......@@ -73,7 +73,7 @@ void __load_plugin(const char *name)
_name[127] = 0;
init = (void (*)(void))(long)dlsym(dl, _name);
if (!init) {
XSEGLOG2(I, "Init function '%s' not found!\n", _name);
XSEGLOG2(W, "Init function '%s' not found!\n", _name);
return;
}
......
......@@ -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)
XSEGLOG2(I, "BUG: Could not free cache entry node. Queue is full");
XSEGLOG2(W, "BUG: Could not free cache entry node. Queue is full");
}
#endif
......@@ -64,7 +64,7 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler
XSEGLOG2(I, "Rebuilding internal hash table");
new = xhash_resize(*table, (*table)->size_shift, (*table)->limit, NULL);
if (!new) {
XSEGLOG2(I, "Error resizing hash table");
XSEGLOG2(W, "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) {
XSEGLOG2(I, "BUG: failed to insert entry after resize");
XSEGLOG2(W, "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)
XSEGLOG2(I, "BUG: hash table must be resized");
XSEGLOG2(W, "BUG: hash table must be resized");
else if (r == -XHASH_EEXIST)
XSEGLOG2(I, "BUG: Entry %s not found in hash table", name);
XSEGLOG2(W, "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))
XSEGLOG2(I, "BUG: Could not free cache entry node. Queue is full");
XSEGLOG2(W, "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)
XSEGLOG2(I, "BUG: Free entry has ref %lu (priv: %p, h: %p)", ce->priv, idx);
XSEGLOG2(W, "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){
XSEGLOG2(I, "BUG: Cannot insert to lru binary heap");
XSEGLOG2(W, "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)){
XSEGLOG2(I, "Couldn't delete cache entry from hash table:\n"
XSEGLOG2(W, "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,10 +218,10 @@ 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){
XSEGLOG2(I, "BUG: cannot increase key to XCACHE_LRU_MAX");
XSEGLOG2(W, "BUG: cannot increase key to XCACHE_LRU_MAX");
}
if (xbinheap_extract(&cache->binheap) == NoNode){
XSEGLOG2(I, "BUG: cannot remove cache entry from lru");
XSEGLOG2(W, "BUG: cannot remove cache entry from lru");
}
ce->h = NoNode;
}
......@@ -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)) {
XSEGLOG2(I, "Couldn't delete cache entry from hash table:\n"
XSEGLOG2(W, "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))
XSEGLOG2(I, "BUG: New entry has ref != 0 (h: %lu, ref: %lu, priv: %p)",
XSEGLOG2(W, "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);
......@@ -418,7 +418,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
r = __xcache_remove_entries(cache, h);
if (r < 0) {
XSEGLOG2(I, "Failed to evict %llu from entries", h);
XSEGLOG2(W, "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))
XSEGLOG2(I, "BUG: Evicting an already evicted entry (h: %lu, priv: %p)",
XSEGLOG2(W, "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;
XSEGLOG2(I, "BUG: Failed insert %llu to rm_entries", h);
XSEGLOG2(W, "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){
XSEGLOG2(I, "BUG: No lru found");
XSEGLOG2(W, "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)) {
XSEGLOG2(I, "Could not remove found entry (%llu) for %s"
XSEGLOG2(W, "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))
XSEGLOG2(I, "BUG: Entry (%llu) in rm table not in evicted state", tmp_h);
XSEGLOG2(W, "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)) {
XSEGLOG2(I, "BUG: Failed to evict lru entry");
XSEGLOG2(W, "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) {
XSEGLOG2(I, "BUG: failed to insert enries after eviction");
XSEGLOG2(W, "BUG: failed to insert enries after eviction");
return NoEntry;
}
}
if (UNLIKELY(r >= 0 && ce->ref == 0))
XSEGLOG2(I, "BUG: (Re)inserted entry has ref 0 (priv: %p, h: %lu)",
XSEGLOG2(W, "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))
XSEGLOG2(I, "BUG: Unsuccessful insertion lead to LRU eviction.");
XSEGLOG2(W, "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))
XSEGLOG2(I, "BUG: Re-insert handler is different from returned handler"
XSEGLOG2(W, "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)
......
......@@ -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) {
XSEGLOG2(I, "couldn't malloc\n");
XSEGLOG2(W, "couldn't malloc\n");
return NULL;
}
......
......@@ -100,7 +100,7 @@ void* xheap_allocate(struct xheap *heap, uint64_t bytes)
if (!head)
goto alloc;
if (head > heap->cur) {
XSEGLOG2(I, "invalid xptr %llu found in chunk lists\n", head);
XSEGLOG2(W, "invalid xptr %llu found in chunk lists\n", head);
goto out;
}
next = *(xptr *)(((unsigned long) mem) + head);
......@@ -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){
XSEGLOG2(I, "requested %llu bytes but heap returned %llu",
XSEGLOG2(W, "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))) {
XSEGLOG2(I, "allocated chunk size %llu, but it should be %llu (req_bytes %llu)",
XSEGLOG2(W, "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) {
XSEGLOG2(I, "for ptr: %lx, magic %lx != 0xdeadbeaf", ptr, h->magic);
XSEGLOG2(W, "for ptr: %lx, magic %lx != 0xdeadbeaf", ptr, h->magic);
}
mem = XPTR(&heap->mem);
size = xheap_get_chunk_size(ptr);
......
......@@ -130,7 +130,7 @@ void xq_print(struct xq *xq)
for (;;) {
if (i == xq->head)
break;
XSEGLOG2(I, "%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