summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-20 17:12:18 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2016-11-20 17:12:18 (GMT)
commit5ce3b934571906c012567d898d83c652fad30567 (patch)
treeda4cbf3fceb38f3ba17f8d40caf396df92557081
parent17128fd0ad119c801a17e06da1fd8b351fb17f21 (diff)
downloadnetsurf-5ce3b934571906c012567d898d83c652fad30567.tar.gz
netsurf-5ce3b934571906c012567d898d83c652fad30567.tar.bz2
Get clib2 slab usage
Calling ARexx function "SLABSTATS" will dump the current stats to the ns log
-rw-r--r--frontends/amiga/arexx.c16
-rw-r--r--frontends/amiga/bitmap.c8
-rwxr-xr-xfrontends/amiga/memory.c35
-rw-r--r--frontends/amiga/memory.h5
4 files changed, 56 insertions, 8 deletions
diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c
index cdb12c2..18dae24 100644
--- a/frontends/amiga/arexx.c
+++ b/frontends/amiga/arexx.c
@@ -45,6 +45,10 @@
#include "amiga/misc.h"
#include "amiga/theme.h"
+#ifndef __amigaos4__
+#include "amiga/memory.h"
+#endif
+
extern const char * const verarexx;
extern const char * const wt_revid;
@@ -65,7 +69,8 @@ enum
RX_WINDOWS,
RX_ACTIVE,
RX_CLOSE,
- RX_HOTLIST
+ RX_HOTLIST,
+ RX_SLABSTATS
};
static Object *arexx_obj = NULL;
@@ -93,6 +98,7 @@ RXHOOKF(rx_windows);
RXHOOKF(rx_active);
RXHOOKF(rx_close);
RXHOOKF(rx_hotlist);
+RXHOOKF(rx_slabstats);
STATIC struct ARexxCmd Commands[] =
{
@@ -112,6 +118,7 @@ STATIC struct ARexxCmd Commands[] =
{"ACTIVE", RX_ACTIVE, rx_active, "T=TAB/S", 0, NULL, 0, 0, NULL },
{"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
{"HOTLIST", RX_HOTLIST, rx_hotlist, "A=ACTION/A", 0, NULL, 0, 0, NULL },
+ {"SLABSTATS", RX_SLABSTATS, rx_slabstats, NULL, 0, NULL, 0, 0, NULL },
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
};
@@ -664,3 +671,10 @@ RXHOOKF(rx_hotlist)
}
}
+RXHOOKF(rx_slabstats)
+{
+#ifndef __amigaos4__
+ ami_memory_slab_dump();
+#endif
+}
+
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 27ffee4..c6e23b2 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -108,9 +108,9 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
- if(pool_bitmap == NULL) pool_bitmap = ami_misc_itempool_create(sizeof(struct bitmap));
+ if(pool_bitmap == NULL) pool_bitmap = ami_memory_itempool_create(sizeof(struct bitmap));
- bitmap = ami_misc_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
+ bitmap = ami_memory_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
if(bitmap == NULL) return NULL;
bitmap->pixdata = ami_memory_clear_alloc(width*height*4, 0xff);
@@ -182,7 +182,7 @@ void amiga_bitmap_destroy(void *bitmap)
bm->url = NULL;
bm->title = NULL;
- ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
+ ami_memory_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
bm = NULL;
}
}
@@ -655,7 +655,7 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
void ami_bitmap_fini(void)
{
- if(pool_bitmap) ami_misc_itempool_delete(pool_bitmap);
+ if(pool_bitmap) ami_memory_itempool_delete(pool_bitmap);
pool_bitmap = NULL;
}
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
index 901d616..cf42c1e 100755
--- a/frontends/amiga/memory.c
+++ b/frontends/amiga/memory.c
@@ -16,12 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef __amigaos4__
#include <stdlib.h>
-#include <proto/exec.h>
-
#include "amiga/memory.h"
+#include "utils/log.h"
-#ifndef __amigaos4__
ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */
/* Special clear (ie. non-zero) */
@@ -31,5 +30,35 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value)
if (mem) memset(mem, value, size);
return mem;
}
+
+/* clib2 slab allocator stats */
+static int ami_memory_slab_callback(const struct __slab_usage_information * sui)
+{
+ if(sui->sui_slab_index <= 1) {
+ LOG("clib2 slab usage:");
+ LOG(" The size of all slabs, in bytes: %ld", sui->sui_slab_size);
+ LOG(" Number of allocations which are not managed by slabs: %ld",
+ sui->sui_num_single_allocations);
+ LOG(" Total number of bytes allocated for memory not managed by slabs: %ld",
+ sui->sui_total_single_allocation_size);
+ LOG(" Number of slabs currently in play: %ld", sui->sui_num_slabs);
+ LOG(" Number of currently unused slabs: %ld", sui->sui_num_empty_slabs);
+ LOG(" Number of slabs in use which are completely filled with data: %ld",
+ sui->sui_num_full_slabs);
+ LOG(" Total number of bytes allocated for all slabs: %ld",
+ sui->sui_total_slab_allocation_size);
+ }
+ LOG("Slab %d", sui->sui_slab_index);
+ LOG(" Memory chunk size managed by this slab: %ld", sui->sui_chunk_size);
+ LOG(" Number of memory chunks that fit in this slab: %ld", sui->sui_num_chunks);
+ LOG(" Number of memory chunks used in this slab: %ld", sui->sui_num_chunks_used);
+
+ return 0;
+}
+
+void ami_memory_slab_dump(void)
+{
+ __get_slab_usage(ami_memory_slab_callback);
+}
#endif
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index a3b6b5e..3d92350 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -57,5 +57,10 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
#endif
+/* clib2 slab allocator stats */
+#ifndef __amigaos4__
+void ami_memory_slab_dump(void);
+#endif
+
#endif //AMIGA_MEMORY_H