[haiku-commits] r35602 - haiku/trunk/src/add-ons/kernel/network/stack

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 24 Feb 2010 16:08:06 +0100 (CET)

Author: axeld
Date: 2010-02-24 16:08:06 +0100 (Wed, 24 Feb 2010)
New Revision: 35602
Changeset: http://dev.haiku-os.org/changeset/35602/haiku

Modified:
   haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp
Log:
* Added a peak value (the maximum number of allocated objects) to the net_buffer
  stats.


Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2010-02-24 
14:43:20 UTC (rev 35601)
+++ haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2010-02-24 
15:08:06 UTC (rev 35602)
@@ -163,6 +163,8 @@
 static vint32 sAllocatedNetBufferCount = 0;
 static vint32 sEverAllocatedDataHeaderCount = 0;
 static vint32 sEverAllocatedNetBufferCount = 0;
+static vint32 sMaxAllocatedDataHeaderCount = 0;
+static vint32 sMaxAllocatedNetBufferCount = 0;
 #endif
 
 
@@ -611,10 +613,12 @@
 static int
 dump_net_buffer_stats(int argc, char** argv)
 {
-       kprintf("allocated data headers: %7ld / %7ld\n", 
sAllocatedDataHeaderCount,
-               sEverAllocatedDataHeaderCount);
-       kprintf("allocated net buffers:  %7ld / %7ld\n", 
sAllocatedNetBufferCount,
-               sEverAllocatedNetBufferCount);
+       kprintf("allocated data headers: %7ld / %7ld, peak %7ld\n",
+               sAllocatedDataHeaderCount, sEverAllocatedDataHeaderCount,
+               sMaxAllocatedDataHeaderCount);
+       kprintf("allocated net buffers:  %7ld / %7ld, peak %7ld\n",
+               sAllocatedNetBufferCount, sEverAllocatedNetBufferCount,
+               sMaxAllocatedNetBufferCount);
        return 0;
 }
 
@@ -706,7 +710,11 @@
 allocate_data_header()
 {
 #if ENABLE_STATS
-       atomic_add(&sAllocatedDataHeaderCount, 1);
+       int32 current = atomic_add(&sAllocatedDataHeaderCount, 1) + 1;
+       int32 max = atomic_get(&sMaxAllocatedDataHeaderCount);
+       if (current > max)
+               atomic_test_and_set(&sMaxAllocatedDataHeaderCount, current, 
max);
+
        atomic_add(&sEverAllocatedDataHeaderCount, 1);
 #endif
        return (data_header*)object_cache_alloc(sDataNodeCache, 0);
@@ -717,7 +725,11 @@
 allocate_net_buffer()
 {
 #if ENABLE_STATS
-       atomic_add(&sAllocatedNetBufferCount, 1);
+       int32 current = atomic_add(&sAllocatedNetBufferCount, 1) + 1;
+       int32 max = atomic_get(&sMaxAllocatedNetBufferCount);
+       if (current > max)
+               atomic_test_and_set(&sMaxAllocatedNetBufferCount, current, max);
+
        atomic_add(&sEverAllocatedNetBufferCount, 1);
 #endif
        return (net_buffer_private*)object_cache_alloc(sNetBufferCache, 0);


Other related posts:

  • » [haiku-commits] r35602 - haiku/trunk/src/add-ons/kernel/network/stack - axeld