Print this page
OS-803 make phys mem cap a bit harder
OS-1043 minimize vm_getusage impact
        
*** 56,65 ****
--- 56,66 ----
  #include <sys/vmsystm.h>
  #include <sys/cmn_err.h>
  #include <sys/debug.h>
  #include <sys/tnf_probe.h>
  #include <sys/vtrace.h>
+ #include <sys/ddi.h>
  
  #include <vm/hat.h>
  #include <vm/as.h>
  #include <vm/seg.h>
  #include <vm/seg_vn.h>
*** 848,860 ****
          faultcode_t res = 0;
          caddr_t addrsav;
          struct seg *segsav;
          int as_lock_held;
          klwp_t *lwp = ttolwp(curthread);
  
- 
- 
  retry:
          /*
           * Indicate that the lwp is not to be stopped while waiting for a
           * pagefault.  This is to avoid deadlock while debugging a process
           * via /proc over NFS (in particular).
--- 849,860 ----
          faultcode_t res = 0;
          caddr_t addrsav;
          struct seg *segsav;
          int as_lock_held;
          klwp_t *lwp = ttolwp(curthread);
+         zone_t *zonep = curzone;
  
  retry:
          /*
           * Indicate that the lwp is not to be stopped while waiting for a
           * pagefault.  This is to avoid deadlock while debugging a process
           * via /proc over NFS (in particular).
*** 885,894 ****
--- 885,910 ----
                  CPU_STATS_ENTER_K();
                  CPU_STATS_ADDQ(CPU, vm, as_fault, 1);
                  if (as == &kas)
                          CPU_STATS_ADDQ(CPU, vm, kernel_asflt, 1);
                  CPU_STATS_EXIT_K();
+                 if (zonep->zone_pg_flt_delay != 0) {
+                         /*
+                          * The zone in which this process is running
+                          * is currently over it's physical memory cap.
+                          * Throttle page faults to help the user-land
+                          * memory capper catch up. Note that
+                          * drv_usectohz() rounds up.
+                          */
+                         atomic_add_64(&zonep->zone_pf_throttle, 1);
+                         atomic_add_64(&zonep->zone_pf_throttle_usec,
+                             zonep->zone_pg_flt_delay);
+                         if (zonep->zone_pg_flt_delay < TICK_TO_USEC(1))
+                                 drv_usecwait(zonep->zone_pg_flt_delay);
+                         else
+                                 delay(drv_usectohz(zonep->zone_pg_flt_delay));
+                 }
                  break;
          }
  
          /* Kernel probe */
          TNF_PROBE_3(address_fault, "vm pagefault", /* CSTYLED */,