From 0838fd63e7cb71d1bddc5cc7d2136a6118da4230 Mon Sep 17 00:00:00 2001 From: Filippos Giannakos Date: Tue, 6 Nov 2012 19:46:26 +0200 Subject: [PATCH] fix handlers print formating. add show port requests functionality --- xseg/peers/user/Makefile | 2 +- xseg/peers/user/xseg-tool.c | 87 +++++++++++++++++++++++++++++++------------ xseg/xtypes/xhash_exports.h | 2 + 3 files changed, 67 insertions(+), 24 deletions(-) diff --git a/xseg/peers/user/Makefile b/xseg/peers/user/Makefile index dc8db75..d849b1c 100644 --- a/xseg/peers/user/Makefile +++ b/xseg/peers/user/Makefile @@ -22,7 +22,7 @@ sosd: sosd.c $(BASE)/xseg/xseg.h $(BASE)/util_libs/user/sos/sos.h $(CC) $(CFLAGS) -o $@ $< $(INC) -L$(LIB) -lxseg -lsos xseg: xseg-tool.c $(BASE)/xseg/xseg.h - $(CC) $(CFLAGS) -o $@ $< $(INC) -L$(LIB) -lxseg + $(CC) $(CFLAGS) -o $@ $< $(BASE)/xtypes/xheap.c $(INC) -L$(LIB) -lxseg mt-sosd: mt-sosd.c peer.c peer.h $(CC) $(CFLAGS) -o $@ $< peer.c $(INC) -L$(LIB) -lxseg -lrados -lpthread -DMT diff --git a/xseg/peers/user/xseg-tool.c b/xseg/peers/user/xseg-tool.c index a18d1d3..4b7bb88 100644 --- a/xseg/peers/user/xseg-tool.c +++ b/xseg/peers/user/xseg-tool.c @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include int help(void) @@ -194,7 +196,7 @@ void report_request(struct xseg_request *req) //if (max > 128) // max = 128; //data[max-1] = 0; - fprintf(stderr, "request %llu state %u\n", (unsigned long long)req->serial, req->state); + fprintf(stderr, "request %lx state %u\n", (unsigned long )req, req->state); } int cmd_info(char *target) @@ -242,7 +244,6 @@ int cmd_read(char *target, uint64_t offset, uint64_t size) xport p; char *req_target; struct xseg_request *req = xseg_get_request(xseg, srcport, dstport, X_ALLOC); - printf("%x\n", req); if (!req) { fprintf(stderr, "No request\n"); return -1; @@ -963,14 +964,16 @@ int cmd_report(uint32_t portno) pq = xseg_get_queue(xseg, port, reply_queue); fprintf(stderr, "port %u:\n" " requests: %llu/%llu src gw: %u dst gw: %u\n" - " free_queue [%p] count : %u\n" - " request_queue [%p] count : %u\n" - " reply_queue [%p] count : %u\n", - portno, port->alloc_reqs, port->max_alloc_reqs, - xseg->src_gw[portno], xseg->dst_gw[portno], - (void *)fq, xq_count(fq), - (void *)rq, xq_count(rq), - (void *)pq, xq_count(pq)); + " free_queue [%p] count : %llu\n" + " request_queue [%p] count : %llu\n" + " reply_queue [%p] count : %llu\n", + portno, (unsigned long long)port->alloc_reqs, + (unsigned long long)port->max_alloc_reqs, + xseg->src_gw[portno], + xseg->dst_gw[portno], + (void *)fq, (unsigned long long)xq_count(fq), + (void *)rq, (unsigned long long)xq_count(rq), + (void *)pq, (unsigned long long)xq_count(pq)); return 0; } @@ -986,6 +989,15 @@ int cmd_join(void) } return 0; } +static void print_hanlder(char *name, struct xobject_h *obj_h) +{ + fprintf(stderr, "%20s: free: %4llu, allocated: %4llu, allocated space: %7llu (object size: %llu)\n", + name, + (unsigned long long) obj_h->nr_free, + (unsigned long long) obj_h->nr_allocated, + (unsigned long long) obj_h->allocated_space, + (unsigned long long) obj_h->obj_size); +} int cmd_reportall(void) { @@ -995,26 +1007,49 @@ int cmd_reportall(void) return -1; - fprintf(stderr, "Heap usage: %llu / %llu\n", xseg->heap->cur, xseg->config.heap_size); - fprintf(stderr, "Requests handler: free: %llu, allocated: %llu, allocated space %llu\n", - (unsigned long long) xseg->request_h->nr_free, - (unsigned long long) xseg->request_h->nr_allocated, - (unsigned long long) xseg->request_h->allocated_space); - fprintf(stderr, "Ports handler: free: %llu, allocated: %llu, allocated space %llu\n", - (unsigned long long) xseg->port_h->nr_free, - (unsigned long long) xseg->port_h->nr_allocated, - (unsigned long long) xseg->port_h->allocated_space); - fprintf(stderr, "objects handler: free: %llu, allocated: %llu, allocated space %llu\n", - (unsigned long long) xseg->object_handlers->nr_free, - (unsigned long long) xseg->object_handlers->nr_allocated, - (unsigned long long) xseg->object_handlers->allocated_space); + fprintf(stderr, "Heap usage: %llu / %llu\n", + (unsigned long long)xseg->heap->cur, + (unsigned long long)xseg->config.heap_size); + fprintf(stderr, "Handlers: \n"); + print_hanlder("Requests handler", xseg->request_h); + print_hanlder("Ports handler", xseg->port_h); + print_hanlder("Objects handler", xseg->object_handlers); fprintf(stderr, "\n"); + for (t = 0; t < xseg->config.nr_ports; t++) cmd_report(t); return 0; } +int cmd_showrequests(xport portno) +{ + if (cmd_join()) + return -1; + + struct xobject_h *obj_h = xseg->request_h; + void *container = XPTR(&obj_h->container); + xhash_t *allocated = XPTR_TAKE(obj_h->allocated, container); + xhash_iter_t it; + xhash_iter_init(allocated, &it); + xhashidx key, val; + int i; + while (xhash_iterate(allocated, &it, &key, &val)){ + void *mem = XPTR_TAKE(val, container); + struct xseg_request *req = mem, *t; + for (i = 0; i < xheap_get_chunk_size(mem)/obj_h->obj_size; i++) { + t = req + i; + if (t->src_portno == portno){ + fprintf(stderr, "%d ,req: %lx ", i, t); + report_request(t); + } + } + } + + fprintf(stderr, "\n"); + return 0; +} + int cmd_create(void) { int r = xseg_create(&cfg); @@ -1308,6 +1343,12 @@ int main(int argc, char **argv) continue; } + if (!strcmp(argv[i], "showreqs") && (i + 1 < argc)) { + ret = cmd_showrequests(atol(argv[i+1])); + i += 1; + continue; + } + if (!strcmp(argv[i], "signal") && (i + 1 < argc)) { ret = cmd_signal(atol(argv[i+1])); i += 1; diff --git a/xseg/xtypes/xhash_exports.h b/xseg/xtypes/xhash_exports.h index 7b9561e..3660dab 100644 --- a/xseg/xtypes/xhash_exports.h +++ b/xseg/xtypes/xhash_exports.h @@ -11,3 +11,5 @@ EXPORT_SYMBOL(xhash_freql_update); EXPORT_SYMBOL(xhash_delete); EXPORT_SYMBOL(xhash_lookup); EXPORT_SYMBOL(xhash_print); +EXPORT_SYMBOL(xhash_iter_init); +EXPORT_SYMBOL(xhash_iterate); -- 1.7.10.4