patch #6483: stats module improvement: Added defines to display each module's statistic individually, added stats defines for MEM, MEMP and SYS modules, removed (unused) rexmit counter.

This commit is contained in:
goldsimon
2008-06-27 18:37:53 +00:00
parent 139944a3ac
commit 779938ea68
5 changed files with 136 additions and 82 deletions

View File

@@ -277,9 +277,7 @@ mem_init(void)
/* initialize the lowest-free pointer to the start of the heap */
lfree = (struct mem *)ram;
#if MEM_STATS
lwip_stats.mem.avail = MEM_SIZE_ALIGNED;
#endif /* MEM_STATS */
MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED);
}
/**
@@ -308,9 +306,7 @@ mem_free(void *rmem)
if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) {
LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n"));
#if MEM_STATS
++lwip_stats.mem.err;
#endif /* MEM_STATS */
MEM_STATS_INC(err);
LWIP_MEM_UNPROTECT();
return;
}
@@ -326,9 +322,7 @@ mem_free(void *rmem)
lfree = mem;
}
#if MEM_STATS
lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram);
#endif /* MEM_STATS */
MEM_STATS_DEC_USED(used, mem->next - ((u8_t *)mem - ram));
/* finally, see if prev or next are free also */
plug_holes(mem);
@@ -392,9 +386,7 @@ mem_realloc(void *rmem, mem_size_t newsize)
/* protect the heap from concurrent access */
LWIP_MEM_PROTECT();
#if MEM_STATS
lwip_stats.mem.used -= (size - newsize);
#endif /* MEM_STATS */
MEM_STATS_DEC_USED(used, (size - newsize));
mem2 = (struct mem *)&ram[mem->next];
if(mem2->used == 0) {
@@ -526,12 +518,7 @@ mem_malloc(mem_size_t size)
if (mem2->next != MEM_SIZE_ALIGNED) {
((struct mem *)&ram[mem2->next])->prev = ptr2;
}
#if MEM_STATS
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
if (lwip_stats.mem.max < lwip_stats.mem.used) {
lwip_stats.mem.max = lwip_stats.mem.used;
}
#endif /* MEM_STATS */
MEM_STATS_INC_USED(used, (size + SIZEOF_STRUCT_MEM));
} else {
/* (a mem2 struct does no fit into the user data space of mem and mem->next will always
* be used at this point: if not we have 2 unused structs in a row, plug_holes should have
@@ -541,12 +528,7 @@ mem_malloc(mem_size_t size)
* will always be used at this point!
*/
mem->used = 1;
#if MEM_STATS
lwip_stats.mem.used += mem->next - ((u8_t *)mem - ram);
if (lwip_stats.mem.max < lwip_stats.mem.used) {
lwip_stats.mem.max = lwip_stats.mem.used;
}
#endif /* MEM_STATS */
MEM_STATS_INC_USED(used, mem->next - ((u8_t *)mem - ram));
}
if (mem == lfree) {
@@ -568,9 +550,7 @@ mem_malloc(mem_size_t size)
}
}
LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size));
#if MEM_STATS
++lwip_stats.mem.err;
#endif /* MEM_STATS */
MEM_STATS_INC(err);
LWIP_MEM_UNPROTECT();
return NULL;
}

View File

@@ -252,13 +252,12 @@ memp_init(void)
struct memp *memp;
u16_t i, j;
#if MEMP_STATS
for (i = 0; i < MEMP_MAX; ++i) {
lwip_stats.memp[i].used = lwip_stats.memp[i].max =
lwip_stats.memp[i].err = 0;
lwip_stats.memp[i].avail = memp_num[i];
MEMP_STATS_AVAIL(used, i, 0);
MEMP_STATS_AVAIL(max, i, 0);
MEMP_STATS_AVAIL(err, i, 0);
MEMP_STATS_AVAIL(avail, i, memp_num[i]);
}
#endif /* MEMP_STATS */
memp = LWIP_MEM_ALIGN(memp_memory);
/* for every pool: */
@@ -315,20 +314,13 @@ memp_malloc_fn(memp_t type, const char* file, const int line)
memp->file = file;
memp->line = line;
#endif /* MEMP_OVERFLOW_CHECK */
#if MEMP_STATS
++lwip_stats.memp[type].used;
if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) {
lwip_stats.memp[type].max = lwip_stats.memp[type].used;
}
#endif /* MEMP_STATS */
MEMP_STATS_INC_USED(used, type);
LWIP_ASSERT("memp_malloc: memp properly aligned",
((mem_ptr_t)memp % MEM_ALIGNMENT) == 0);
memp = (struct memp*)((u8_t*)memp + MEMP_SIZE);
} else {
LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %s\n", memp_desc[type]));
#if MEMP_STATS
++lwip_stats.memp[type].err;
#endif /* MEMP_STATS */
MEMP_STATS_INC(err, type);
}
SYS_ARCH_UNPROTECT(old_level);
@@ -365,9 +357,7 @@ memp_free(memp_t type, void *mem)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
#endif /* MEMP_OVERFLOW_CHECK */
#if MEMP_STATS
lwip_stats.memp[type].used--;
#endif /* MEMP_STATS */
MEMP_STATS_DEC(used, type);
memp->next = memp_tab[type];
memp_tab[type] = memp;

View File

@@ -54,7 +54,6 @@ stats_display_proto(struct stats_proto *proto, char *name)
{
LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
LWIP_PLATFORM_DIAG(("rexmit: %"STAT_COUNTER_F"\n\t", proto->rexmit));
LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
@@ -68,6 +67,7 @@ stats_display_proto(struct stats_proto *proto, char *name)
LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
}
#if IGMP_STATS
void
stats_display_igmp(struct stats_igmp *igmp)
{
@@ -82,7 +82,9 @@ stats_display_igmp(struct stats_igmp *igmp)
LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed));
LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed));
}
#endif /* IGMP_STATS */
#if MEM_STATS || MEMP_STATS
void
stats_display_mem(struct stats_mem *mem, char *name)
{
@@ -93,48 +95,53 @@ stats_display_mem(struct stats_mem *mem, char *name)
LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
}
void
stats_display(void)
{
#if MEMP_STATS
s16_t i;
void
stats_display_memp(struct stats_mem *mem, int index)
{
char * memp_names[] = {
#define LWIP_MEMPOOL(name,num,size,desc) desc,
#include "lwip/memp_std.h"
};
#endif
#if LINK_STATS
stats_display_proto(&lwip_stats.link, "LINK");
#endif
#if ETHARP_STATS
stats_display_proto(&lwip_stats.etharp, "ETHARP");
#endif
#if IPFRAG_STATS
stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG");
#endif
#if IP_STATS
stats_display_proto(&lwip_stats.ip, "IP");
#endif
#if ICMP_STATS
stats_display_proto(&lwip_stats.icmp, "ICMP");
#endif
#if IGMP_STATS
stats_display_igmp(&lwip_stats.igmp);
#endif
#if UDP_STATS
stats_display_proto(&lwip_stats.udp, "UDP");
#endif
#if TCP_STATS
stats_display_proto(&lwip_stats.tcp, "TCP");
#endif
#if MEM_STATS
stats_display_mem(&lwip_stats.mem, "HEAP");
#endif
#if MEMP_STATS
for (i = 0; i < MEMP_MAX; i++) {
stats_display_mem(&lwip_stats.memp[i], memp_names[i]);
if(index < MEMP_MAX) {
stats_display_mem(mem, memp_names[index]);
}
#endif
}
#endif /* MEMP_STATS */
#endif /* MEM_STATS || MEMP_STATS */
#if SYS_STATS
void
stats_display_sys(struct stats_sys *sys)
{
LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err));
}
#endif /* SYS_STATS */
void
stats_display(void)
{
s16_t i;
LINK_STATS_DISPLAY();
ETHARP_STATS_DISPLAY();
IPFRAG_STATS_DISPLAY();
IP_STATS_DISPLAY();
IGMP_STATS_DISPLAY();
ICMP_STATS_DISPLAY();
UDP_STATS_DISPLAY();
TCP_STATS_DISPLAY();
MEM_STATS_DISPLAY();
for (i = 0; i < MEMP_MAX; i++) {
MEMP_STATS_DISPLAY(i);
}
SYS_STATS_DISPLAY();
}
#endif /* LWIP_STATS_DISPLAY */