]> Zhao Yanbai Git Server - minix.git/commitdiff
High watermark memory usage feature
authorBen Gras <ben@minix3.org>
Tue, 18 Oct 2005 17:21:11 +0000 (17:21 +0000)
committerBen Gras <ben@minix3.org>
Tue, 18 Oct 2005 17:21:11 +0000 (17:21 +0000)
include/Makefile
include/minix/type.h
servers/is/dmp_pm.c
servers/pm/alloc.c
servers/pm/misc.c
servers/pm/proto.h

index 78a5d2447defeb0ef9d4688cb1a685456f30487b..dcd8c1161ff75782a35fcd526acf8e0b81702373 100644 (file)
@@ -13,4 +13,4 @@ install::
        cpdir . $(INC)
        @chown -R bin $(INC)
        @rm -f $(INC)/Makefile
-       if [ -f $(MKHEADERS) ] ; then sh $(MKHEADERS) ; fi
+#      if [ -f $(MKHEADERS) ] ; then sh $(MKHEADERS) ; fi
index 4760de0c0a972b8ac7390d76e1cef84690191e7a..b5456ddd148813b6bf7f6b3f43838ffc1784cac4 100755 (executable)
@@ -54,6 +54,12 @@ struct hole {
   phys_clicks h_len;            /* how big is the hole? */
 };
 
+/* Memory info from PM. */
+struct pm_mem_info {
+       struct hole pmi_holes[_NR_HOLES];/* memory (un)allocations */
+       u32_t pmi_hi_watermark;          /* highest ever-used click + 1 */
+};
+
 #define phys_cp_req vir_cp_req 
 struct vir_cp_req {
   struct vir_addr src;
index 4cfe479bbd7b55d94d0aec43b9f6e7d2bf691f5c..9fd3b7f2f2393fa39e447cba3cfb2184013369b1 100644 (file)
@@ -104,33 +104,36 @@ PUBLIC void sigaction_dmp()
  *===========================================================================*/
 PUBLIC void holes_dmp(void)
 {
-       static struct hole holes[_NR_HOLES];
+       static struct pm_mem_info pmi;
        int h;
        int largest_bytes = 0, total_bytes = 0;
 
-       if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, holes) != OK) {
+       if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, &pmi) != OK) {
                printf("Obtaining memory hole list failed.\n");
                return;
        }
        printf("Available memory stats\n");
 
        for(h = 0; h < _NR_HOLES; h++) {
-               if(holes[h].h_base && holes[h].h_len) {
+               if(pmi.pmi_holes[h].h_base && pmi.pmi_holes[h].h_len) {
                        int bytes;
-                       bytes = (holes[h].h_len << CLICK_SHIFT);
+                       bytes = (pmi.pmi_holes[h].h_len << CLICK_SHIFT);
                        printf("%08lx: %6d kB\n",
-                               holes[h].h_base << CLICK_SHIFT, bytes / 1024);
+                               pmi.pmi_holes[h].h_base << CLICK_SHIFT, bytes / 1024);
                        if(bytes > largest_bytes) largest_bytes = bytes;
                        total_bytes += bytes;
                }
        }
-       printf("\nTotal memory free: %d kB\n"
-               "Largest contiguous chunk: %d kB\n"
-               "Uncontiguous rest: %d kB (%d%% of total free)\n",
+       printf("\n"
+               "Total memory free:     %7d kB\n"
+               "Largest chunk:         %7d kB\n"
+               "Uncontiguous rest:     %7d kB (%d%% of total free)\n"
+               "Memory high watermark: %7d kB\n",
                total_bytes/1024,
                largest_bytes/1024,
                (total_bytes-largest_bytes)/1024,
-               100*(total_bytes/100-largest_bytes/100)/total_bytes);
+               100*(total_bytes/100-largest_bytes/100)/total_bytes,
+               (pmi.pmi_hi_watermark/1024 << CLICK_SHIFT));
 
        return;
 }
index 0cc9e1fae7b85caed4600e805c3407b281ff53d9..a40cac2801e426ce845e8d28b42f0dcd0b896563 100644 (file)
@@ -32,6 +32,7 @@
 #define NIL_HOLE (struct hole *) 0
 
 PRIVATE struct hole hole[_NR_HOLES];
+PRIVATE u32_t high_watermark = 0;
 
 PRIVATE struct hole *hole_head;        /* pointer to first hole */
 PRIVATE struct hole *free_slots;/* ptr to list of unused table slots */
@@ -79,6 +80,10 @@ phys_clicks clicks;          /* amount of memory requested */
                        hp->h_base += clicks;   /* bite a piece off */
                        hp->h_len -= clicks;    /* ditto */
 
+                       /* Remember new high watermark of used memory. */
+                       if(hp->h_base > high_watermark)
+                               high_watermark = hp->h_base;
+
                        /* Delete the hole if used up completely. */
                        if (hp->h_len == 0) del_slot(prev_ptr, hp);
 
@@ -253,11 +258,12 @@ phys_clicks *free;                /* memory size summaries */
 /*===========================================================================*
  *                             mem_holes_copy                               *
  *===========================================================================*/
-PUBLIC int mem_holes_copy(struct hole *holecopies, size_t *bytes)
+PUBLIC int mem_holes_copy(struct hole *holecopies, size_t *bytes, u32_t *hi)
 {
        if(*bytes < sizeof(hole)) return ENOSPC;
        memcpy(holecopies, hole, sizeof(hole));
        *bytes = sizeof(hole);
+       *hi = high_watermark;
        return OK;
 }
 
index 75e509586836980843f0dda34dab4a6abedd663c..8e25dbdde48b745c35f815c0c745322b315da8e7 100644 (file)
@@ -60,7 +60,7 @@ PUBLIC int do_getsysinfo()
   vir_bytes src_addr, dst_addr;
   struct kinfo kinfo;
   size_t len;
-  static struct hole holes[_NR_HOLES];
+  static struct pm_mem_info pmi;
   int s, r;
   size_t holesize;
 
@@ -80,10 +80,12 @@ PUBLIC int do_getsysinfo()
         len = sizeof(struct mproc) * NR_PROCS;
         break;
   case SI_MEM_ALLOC:
-       holesize = sizeof(holes);
-       if((r=mem_holes_copy(holes, &holesize)) != OK) return r;
-       src_addr = (vir_bytes) holes;
-       len = holesize;
+       holesize = sizeof(pmi.pmi_holes);
+       if((r=mem_holes_copy(pmi.pmi_holes, &holesize,
+          &pmi.pmi_hi_watermark)) != OK)
+               return r;
+       src_addr = (vir_bytes) &pmi;
+       len = sizeof(pmi);
        break;
   default:
        return(EINVAL);
index bd358ea09c453ca651da6c0d561819b84a46401f..937bac846d1a6fa76eaca8a3c0420dcbd93c436e 100644 (file)
@@ -20,7 +20,7 @@ _PROTOTYPE( void swap_inqueue, (struct mproc *rmp)                    );
 #define swap_in()                      ((void)0)
 #define swap_inqueue(rmp)              ((void)0)
 #endif /* !SWAP */
-_PROTOTYPE(int mem_holes_copy, (struct hole *, size_t *)               );
+_PROTOTYPE(int mem_holes_copy, (struct hole *, size_t *, u32_t *)      );
 
 /* break.c */
 _PROTOTYPE( int adjust, (struct mproc *rmp,