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) ...@@ -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); fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0770);
if (fd < 0) { if (fd < 0) {
err_no = errno; err_no = errno;
XSEGLOG2(I, "Cannot create shared segment: %s\n", XSEGLOG2(W, "Cannot create shared segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE)); strerror_r(errno, errbuf, ERRSIZE));
ret = fd; ret = fd;
goto exit; goto exit;
...@@ -53,7 +53,7 @@ static long posix_allocate(const char *name, uint64_t size) ...@@ -53,7 +53,7 @@ static long posix_allocate(const char *name, uint64_t size)
if (lr == (off_t)-1) { if (lr == (off_t)-1) {
err_no = errno; err_no = errno;
close(fd); 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)); strerror_r(errno, errbuf, ERRSIZE));
ret = lr; ret = lr;
goto exit; goto exit;
...@@ -64,7 +64,7 @@ static long posix_allocate(const char *name, uint64_t size) ...@@ -64,7 +64,7 @@ static long posix_allocate(const char *name, uint64_t size)
if (r != 1) { if (r != 1) {
err_no = errno; err_no = errno;
close(fd); 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)); strerror_r(errno, errbuf, ERRSIZE));
ret = r; ret = r;
goto exit; goto exit;
...@@ -90,7 +90,7 @@ static void *posix_map(const char *name, uint64_t size, struct xseg *seg) ...@@ -90,7 +90,7 @@ static void *posix_map(const char *name, uint64_t size, struct xseg *seg)
fd = shm_open(name, O_RDWR, 0000); fd = shm_open(name, O_RDWR, 0000);
if (fd < 0) { if (fd < 0) {
err_no = errno; 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)); name, strerror_r(errno, errbuf, ERRSIZE));
errno = err_no; errno = err_no;
return NULL; return NULL;
...@@ -104,7 +104,7 @@ static void *posix_map(const char *name, uint64_t size, struct xseg *seg) ...@@ -104,7 +104,7 @@ static void *posix_map(const char *name, uint64_t size, struct xseg *seg)
if (xseg == MAP_FAILED) { if (xseg == MAP_FAILED) {
err_no = errno; err_no = errno;
XSEGLOG2(I, "Could not map segment: %s\n", XSEGLOG2(W, "Could not map segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE)); strerror_r(errno, errbuf, ERRSIZE));
errno = err_no; errno = err_no;
return NULL; return NULL;
......
...@@ -43,7 +43,7 @@ static long pthread_allocate(const char *name, uint64_t size) ...@@ -43,7 +43,7 @@ static long pthread_allocate(const char *name, uint64_t size)
off_t lr; off_t lr;
fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0770); fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0770);
if (fd < 0) { if (fd < 0) {
XSEGLOG2(I, "Cannot create shared segment: %s\n", XSEGLOG2(W, "Cannot create shared segment: %s\n",
strerror_r(errno, errbuf, ERRSIZE)); strerror_r(errno, errbuf, ERRSIZE));
return fd; return fd;
} }
...@@ -51,7 +51,7 @@ static long pthread_allocate(const char *name, uint64_t size) ...@@ -51,7 +51,7 @@ static long pthread_allocate(const char *name, uint64_t size)
lr = lseek(fd, size -1, SEEK_SET); lr = lseek(fd, size -1, SEEK_SET);
if (lr == (off_t)-1) { if (lr == (off_t)-1) {
close(fd); 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)); strerror_r(errno, errbuf, ERRSIZE));
return lr; return lr;
} }
...@@ -60,7 +60,7 @@ static long pthread_allocate(const char *name, uint64_t size) ...@@ -60,7 +60,7 @@ static long pthread_allocate(const char *name, uint64_t size)
r = write(fd, errbuf, 1); r = write(fd, errbuf, 1);
if (r != 1) { if (r != 1) {
close(fd); 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)); strerror_r(errno, errbuf, ERRSIZE));
return r; return r;
} }
...@@ -84,7 +84,7 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg) ...@@ -84,7 +84,7 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg)
fd = shm_open(name, O_RDWR, 0000); fd = shm_open(name, O_RDWR, 0000);
if (fd < 0) { 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)); name, strerror_r(errno, errbuf, ERRSIZE));
return NULL; return NULL;
} }
...@@ -96,7 +96,7 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg) ...@@ -96,7 +96,7 @@ static void *pthread_map(const char *name, uint64_t size, struct xseg *seg)
fd, 0 ); fd, 0 );
if (xseg == MAP_FAILED) { 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)); strerror_r(errno, errbuf, ERRSIZE));
return NULL; return NULL;
} }
......
...@@ -65,7 +65,7 @@ void __load_plugin(const char *name) ...@@ -65,7 +65,7 @@ void __load_plugin(const char *name)
_name[5 + namelen + 3 ] = 0; _name[5 + namelen + 3 ] = 0;
dl = dlopen(_name, RTLD_NOW); dl = dlopen(_name, RTLD_NOW);
if (!dl) { if (!dl) {
XSEGLOG2(I, "Cannot load plugin '%s': %s\n", _name, dlerror()); XSEGLOG2(W, "Cannot load plugin '%s': %s\n", _name, dlerror());
return; return;
} }
...@@ -73,7 +73,7 @@ void __load_plugin(const char *name) ...@@ -73,7 +73,7 @@ void __load_plugin(const char *name)
_name[127] = 0; _name[127] = 0;
init = (void (*)(void))(long)dlsym(dl, _name); init = (void (*)(void))(long)dlsym(dl, _name);
if (!init) { if (!init) {
XSEGLOG2(I, "Init function '%s' not found!\n", _name); XSEGLOG2(W, "Init function '%s' not found!\n", _name);
return; return;
} }
......
...@@ -39,7 +39,7 @@ static xqindex __alloc_cache_entry(struct xcache *cache) ...@@ -39,7 +39,7 @@ static xqindex __alloc_cache_entry(struct xcache *cache)
static void __free_cache_entry(struct xcache *cache, xqindex idx) static void __free_cache_entry(struct xcache *cache, xqindex idx)
{ {
if (__xq_append_head(&cache->free_nodes, idx) == Noneidx) 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 #endif
...@@ -64,7 +64,7 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler ...@@ -64,7 +64,7 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler
XSEGLOG2(I, "Rebuilding internal hash table"); XSEGLOG2(I, "Rebuilding internal hash table");
new = xhash_resize(*table, (*table)->size_shift, (*table)->limit, NULL); new = xhash_resize(*table, (*table)->size_shift, (*table)->limit, NULL);
if (!new) { if (!new) {
XSEGLOG2(I, "Error resizing hash table"); XSEGLOG2(W, "Error resizing hash table");
return -1; return -1;
} }
*table = new; *table = new;
...@@ -72,7 +72,7 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler ...@@ -72,7 +72,7 @@ static int __table_insert(xhash_t **table, struct xcache * cache, xcache_handler
/* We give insertion a second shot */ /* We give insertion a second shot */
r = xhash_insert(*table, (xhashidx)ce->name, idx); r = xhash_insert(*table, (xhashidx)ce->name, idx);
if (r == -XHASH_ERESIZE) { if (r == -XHASH_ERESIZE) {
XSEGLOG2(I, "BUG: failed to insert entry after resize"); XSEGLOG2(W, "BUG: failed to insert entry after resize");
return -1; return -1;
} }
} }
...@@ -87,9 +87,9 @@ static int __table_remove(xhash_t *table, char *name) ...@@ -87,9 +87,9 @@ static int __table_remove(xhash_t *table, char *name)
r = xhash_delete(table, (xhashidx)name); r = xhash_delete(table, (xhashidx)name);
if (UNLIKELY(r<0)){ if (UNLIKELY(r<0)){
if (r == -XHASH_ERESIZE) 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) 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; return r;
} }
...@@ -102,7 +102,7 @@ static xqindex alloc_cache_entry(struct xcache *cache) ...@@ -102,7 +102,7 @@ static xqindex alloc_cache_entry(struct xcache *cache)
static void __free_cache_entry(struct xcache *cache, xqindex idx) static void __free_cache_entry(struct xcache *cache, xqindex idx)
{ {
if (UNLIKELY(xq_append_head(&cache->free_nodes, idx) == Noneidx)) 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) static void free_cache_entry(struct xcache *cache, xqindex idx)
...@@ -110,7 +110,7 @@ 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]; struct xcache_entry *ce = &cache->nodes[idx];
if (ce->ref != 0) 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); __free_cache_entry(cache, idx);
if (cache->ops.on_free) if (cache->ops.on_free)
...@@ -175,7 +175,7 @@ static void __update_access_time(struct xcache *cache, xqindex idx) ...@@ -175,7 +175,7 @@ static void __update_access_time(struct xcache *cache, xqindex idx)
} else { } else {
ce->h = xbinheap_insert(&cache->binheap, cache->time, idx); ce->h = xbinheap_insert(&cache->binheap, cache->time, idx);
if (ce->h == NoNode){ 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) ...@@ -207,7 +207,7 @@ static int __xcache_remove_entries(struct xcache *cache, xcache_handler h)
r = __table_remove(cache->entries, ce->name); r = __table_remove(cache->entries, ce->name);
if (UNLIKELY(r < 0)){ 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: %llu, name: %s, cache->nodes[h].priv: %p, ref: %llu",
h, ce->name, cache->nodes[idx].priv, cache->nodes[idx].ref); h, ce->name, cache->nodes[idx].priv, cache->nodes[idx].ref);
return r; return r;
...@@ -218,10 +218,10 @@ static int __xcache_remove_entries(struct xcache *cache, xcache_handler h) ...@@ -218,10 +218,10 @@ static int __xcache_remove_entries(struct xcache *cache, xcache_handler h)
else if (cache->flags & XCACHE_LRU_HEAP) { else if (cache->flags & XCACHE_LRU_HEAP) {
if (ce->h != NoNode) { if (ce->h != NoNode) {
if (xbinheap_increasekey(&cache->binheap, ce->h, XCACHE_LRU_MAX) < 0){ 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){ 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; ce->h = NoNode;
} }
...@@ -242,7 +242,7 @@ static int __xcache_remove_rm(struct xcache *cache, xcache_handler h) ...@@ -242,7 +242,7 @@ static int __xcache_remove_rm(struct xcache *cache, xcache_handler h)
r = __table_remove(cache->rm_entries, ce->name); r = __table_remove(cache->rm_entries, ce->name);
if (UNLIKELY(r < 0)) { 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: %llu, name: %s, cache->nodes[h].priv: %p, ref: %llu",
h, ce->name, cache->nodes[idx].priv, cache->nodes[idx].ref); 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) ...@@ -364,7 +364,7 @@ static int xcache_entry_init(struct xcache *cache, xqindex idx, char *name)
xlock_release(&ce->lock); xlock_release(&ce->lock);
if (UNLIKELY(ce->ref != 0)) 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); idx, ce->ref, ce->priv);
ce->ref = 1; ce->ref = 1;
strncpy(ce->name, name, XSEG_MAX_TARGETLEN); strncpy(ce->name, name, XSEG_MAX_TARGETLEN);
...@@ -418,7 +418,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h) ...@@ -418,7 +418,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
r = __xcache_remove_entries(cache, h); r = __xcache_remove_entries(cache, h);
if (r < 0) { if (r < 0) {
XSEGLOG2(I, "Failed to evict %llu from entries", h); XSEGLOG2(W, "Failed to evict %llu from entries", h);
return -1; return -1;
} }
...@@ -429,7 +429,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h) ...@@ -429,7 +429,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
ce = &cache->nodes[h]; ce = &cache->nodes[h];
if (UNLIKELY(ce->state == NODE_EVICTED)) 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); h, ce->priv);
if (!(cache->flags & XCACHE_USE_RMTABLE)) if (!(cache->flags & XCACHE_USE_RMTABLE))
...@@ -442,7 +442,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h) ...@@ -442,7 +442,7 @@ static int __xcache_evict(struct xcache *cache, xcache_handler h)
if (r < 0) { if (r < 0) {
ce->state = NODE_ACTIVE; 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; return -1;
} }
...@@ -456,7 +456,7 @@ static xcache_handler __xcache_evict_lru(struct xcache *cache) ...@@ -456,7 +456,7 @@ static xcache_handler __xcache_evict_lru(struct xcache *cache)
lru = __xcache_lru(cache); lru = __xcache_lru(cache);
if (lru == NoEntry){ if (lru == NoEntry){
XSEGLOG2(I, "BUG: No lru found"); XSEGLOG2(W, "BUG: No lru found");
return NoEntry; return NoEntry;
} }
...@@ -519,7 +519,7 @@ static xcache_handler __xcache_insert(struct xcache *cache, xcache_handler h, ...@@ -519,7 +519,7 @@ static xcache_handler __xcache_insert(struct xcache *cache, xcache_handler h,
/* if so then remove it from rm table */ /* if so then remove it from rm table */
r = __xcache_remove_rm(cache, tmp_h); r = __xcache_remove_rm(cache, tmp_h);
if (UNLIKELY(r < 0)) { 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); "from rm_entries", tmp_h, ce->name);
xlock_release(&cache->rm_lock); xlock_release(&cache->rm_lock);
return NoEntry; return NoEntry;
...@@ -528,7 +528,7 @@ static xcache_handler __xcache_insert(struct xcache *cache, xcache_handler h, ...@@ -528,7 +528,7 @@ static xcache_handler __xcache_insert(struct xcache *cache, xcache_handler h,
/* and prepare it for reinsertion */ /* and prepare it for reinsertion */
ce = &cache->nodes[tmp_h]; ce = &cache->nodes[tmp_h];
if (UNLIKELY(ce->state != NODE_EVICTED)) 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; ce->state = NODE_ACTIVE;
__xcache_entry_get(cache, tmp_h); __xcache_entry_get(cache, tmp_h);
...@@ -543,7 +543,7 @@ insert: ...@@ -543,7 +543,7 @@ insert:
if (r == -XHASH_ENOSPC){ if (r == -XHASH_ENOSPC){
lru = __xcache_evict_lru(cache); lru = __xcache_evict_lru(cache);
if (UNLIKELY(lru == NoEntry)) { if (UNLIKELY(lru == NoEntry)) {
XSEGLOG2(I, "BUG: Failed to evict lru entry"); XSEGLOG2(W, "BUG: Failed to evict lru entry");
return NoEntry; return NoEntry;
} }
*lru_handler = lru; *lru_handler = lru;
...@@ -554,13 +554,13 @@ insert: ...@@ -554,13 +554,13 @@ insert:
*/ */
r = __xcache_insert_entries(cache, h); r = __xcache_insert_entries(cache, h);
if (r < 0) { if (r < 0) {
XSEGLOG2(I, "BUG: failed to insert enries after eviction"); XSEGLOG2(W, "BUG: failed to insert enries after eviction");
return NoEntry; return NoEntry;
} }
} }
if (UNLIKELY(r >= 0 && ce->ref == 0)) 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); ce->priv, h);
if (r >= 0) if (r >= 0)
...@@ -592,7 +592,7 @@ xcache_handler xcache_insert(struct xcache *cache, xcache_handler h) ...@@ -592,7 +592,7 @@ xcache_handler xcache_insert(struct xcache *cache, xcache_handler h)
if (lru != NoEntry) { if (lru != NoEntry) {
if (UNLIKELY(ret == 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]; ce = &cache->nodes[lru];
if (cache->ops.on_evict) if (cache->ops.on_evict)
cache->ops.on_evict(cache->priv, ce->priv); cache->ops.on_evict(cache->priv, ce->priv);
...@@ -601,7 +601,7 @@ xcache_handler xcache_insert(struct xcache *cache, xcache_handler h) ...@@ -601,7 +601,7 @@ xcache_handler xcache_insert(struct xcache *cache, xcache_handler h)
if (reinsert_handler != NoEntry) { if (reinsert_handler != NoEntry) {
if (UNLIKELY(ret != reinsert_handler)) 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); "(rei_h = %llu, ret_h = %llu)", reinsert_handler, ret);
ce = &cache->nodes[reinsert_handler]; ce = &cache->nodes[reinsert_handler];
if (cache->ops.on_reinsert) if (cache->ops.on_reinsert)
......
...@@ -260,7 +260,7 @@ xhash_new__(xhashidx size_shift, xhashidx minsize_shift, xhashidx limit, ...@@ -260,7 +260,7 @@ xhash_new__(xhashidx size_shift, xhashidx minsize_shift, xhashidx limit,
struct xhash *xhash; struct xhash *xhash;
xhash = xtypes_malloc(get_alloc_size(size_shift, vals)); xhash = xtypes_malloc(get_alloc_size(size_shift, vals));
if (!xhash) { if (!xhash) {
XSEGLOG2(I, "couldn't malloc\n"); XSEGLOG2(W, "couldn't malloc\n");
return NULL; return NULL;
} }
......
...@@ -100,7 +100,7 @@ void* xheap_allocate(struct xheap *heap, uint64_t bytes) ...@@ -100,7 +100,7 @@ void* xheap_allocate(struct xheap *heap, uint64_t bytes)
if (!head) if (!head)
goto alloc; goto alloc;
if (head > heap->cur) { 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; goto out;
} }
next = *(xptr *)(((unsigned long) mem) + head); next = *(xptr *)(((unsigned long) mem) + head);
...@@ -129,13 +129,13 @@ out: ...@@ -129,13 +129,13 @@ out:
// printf("alloced: %lx (size: %llu) (xptr: %llu)\n", addr, __get_header(addr)->size, // printf("alloced: %lx (size: %llu) (xptr: %llu)\n", addr, __get_header(addr)->size,
// addr-mem); // addr-mem);
if (addr && xheap_get_chunk_size(addr) < req_bytes){ 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)); req_bytes, xheap_get_chunk_size(addr));
addr = NULL; addr = NULL;
} }
if (addr && xheap_get_chunk_size(addr) != (__get_alloc_bytes(heap, req_bytes) - if (addr && xheap_get_chunk_size(addr) != (__get_alloc_bytes(heap, req_bytes) -
sizeof(struct xheap_header))) { 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); xheap_get_chunk_size(addr), __get_alloc_bytes(heap, req_bytes), req_bytes);
addr = NULL; addr = NULL;
} }
...@@ -168,7 +168,7 @@ void xheap_free(void *ptr) ...@@ -168,7 +168,7 @@ void xheap_free(void *ptr)
int r; int r;
xptr *free_list; xptr *free_list;
if (h->magic != 0xdeadbeaf) { 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); mem = XPTR(&heap->mem);
size = xheap_get_chunk_size(ptr); size = xheap_get_chunk_size(ptr);
......
...@@ -130,7 +130,7 @@ void xq_print(struct xq *xq) ...@@ -130,7 +130,7 @@ void xq_print(struct xq *xq)
for (;;) { for (;;) {
if (i == xq->head) if (i == xq->head)
break; break;
XSEGLOG2(I, "%lu %lu\n", XSEGLOG2(I, "%lu %lu\n",
(unsigned long)i, (unsigned long)i,
(unsigned long)xq_element(xq, i) ); (unsigned long)xq_element(xq, i) );
i += 1; 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