Print this page
OS-3088 need a lighterweight page invalidation mechanism for zone memcap


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.

  24  */
  25 
  26 /*
  27  * Implement fast getrusage call
  28  */
  29 
  30 #include <sys/types.h>
  31 #include <sys/systm.h>
  32 #include <sys/time.h>
  33 #include <sys/errno.h>
  34 #include <sys/resource.h>
  35 #include <sys/vm_usage.h>
  36 
  37 static int
  38 getrusage(void *user_rusage)
  39 {
  40         struct rusage r;
  41         kthread_t *t = curthread;
  42         proc_t *p = ttoproc(t);
  43         hrtime_t snsecs, unsecs;


 240                 if (copyout(&r, user_rusage, sizeof (r)) != 0)
 241                         return (set_errno(EFAULT));
 242 
 243         return (0);
 244 }
 245 
 246 int
 247 rusagesys(int code, void *arg1, void *arg2, void *arg3, void *arg4)
 248 {
 249         switch (code) {
 250 
 251         case _RUSAGESYS_GETRUSAGE:
 252                 return (getrusage(arg1));
 253         case _RUSAGESYS_GETRUSAGE_CHLD:
 254                 return (getrusage_chld(arg1));
 255         case _RUSAGESYS_GETRUSAGE_LWP:
 256                 return (getrusage_lwp(arg1));
 257         case _RUSAGESYS_GETVMUSAGE:
 258                 return (vm_getusage((uint_t)(uintptr_t)arg1, (time_t)arg2,
 259                     (vmusage_t *)arg3, (size_t *)arg4, 0));













 260         default:
 261                 return (set_errno(EINVAL));
 262         }
 263 }


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2014 Joyent, Inc.  All rights reserved.
  25  */
  26 
  27 /*
  28  * Implement fast getrusage call
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/systm.h>
  33 #include <sys/time.h>
  34 #include <sys/errno.h>
  35 #include <sys/resource.h>
  36 #include <sys/vm_usage.h>
  37 
  38 static int
  39 getrusage(void *user_rusage)
  40 {
  41         struct rusage r;
  42         kthread_t *t = curthread;
  43         proc_t *p = ttoproc(t);
  44         hrtime_t snsecs, unsecs;


 241                 if (copyout(&r, user_rusage, sizeof (r)) != 0)
 242                         return (set_errno(EFAULT));
 243 
 244         return (0);
 245 }
 246 
 247 int
 248 rusagesys(int code, void *arg1, void *arg2, void *arg3, void *arg4)
 249 {
 250         switch (code) {
 251 
 252         case _RUSAGESYS_GETRUSAGE:
 253                 return (getrusage(arg1));
 254         case _RUSAGESYS_GETRUSAGE_CHLD:
 255                 return (getrusage_chld(arg1));
 256         case _RUSAGESYS_GETRUSAGE_LWP:
 257                 return (getrusage_lwp(arg1));
 258         case _RUSAGESYS_GETVMUSAGE:
 259                 return (vm_getusage((uint_t)(uintptr_t)arg1, (time_t)arg2,
 260                     (vmusage_t *)arg3, (size_t *)arg4, 0));
 261         case _RUSAGESYS_INVALMAP:
 262                 /*
 263                  * SPARC sfmmu hat does not support HAT_CURPROC_PGUNLOAD
 264                  * handling so callers on SPARC should get simple sync
 265                  * handling with invalidation to all processes.
 266                  */
 267 #if defined(__sparc)
 268                 return (memcntl((caddr_t)arg2, (size_t)arg3, MC_SYNC,
 269                     (caddr_t)(MS_ASYNC | MS_INVALIDATE), 0, 0));
 270 #else
 271                 return (vm_map_inval((pid_t)(uintptr_t)arg1, (caddr_t)arg2,
 272                     (size_t)arg3));
 273 #endif
 274         default:
 275                 return (set_errno(EINVAL));
 276         }
 277 }