Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/vm/vm_as.c
          +++ new/usr/src/uts/common/vm/vm_as.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24      - * Copyright 2016 Joyent, Inc.
       24 + * Copyright 2015, Joyent, Inc.  All rights reserved.
  25   25   * Copyright (c) 2016 by Delphix. All rights reserved.
  26   26   */
  27   27  
  28   28  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  29   29  /*        All Rights Reserved   */
  30   30  
  31   31  /*
  32   32   * University Copyright- Copyright (c) 1982, 1986, 1988
  33   33   * The Regents of the University of California
  34   34   * All Rights Reserved
↓ open down ↓ 30 lines elided ↑ open up ↑
  65   65  #include <vm/seg.h>
  66   66  #include <vm/seg_vn.h>
  67   67  #include <vm/seg_dev.h>
  68   68  #include <vm/seg_kmem.h>
  69   69  #include <vm/seg_map.h>
  70   70  #include <vm/seg_spt.h>
  71   71  #include <vm/page.h>
  72   72  
  73   73  clock_t deadlk_wait = 1; /* number of ticks to wait before retrying */
  74   74  
  75      -ulong_t as_user_seg_limit = 0xffff; /* max segments in an (non-kas) AS */
  76      -
  77   75  static struct kmem_cache *as_cache;
  78   76  
  79   77  static void as_setwatchprot(struct as *, caddr_t, size_t, uint_t);
  80   78  static void as_clearwatchprot(struct as *, caddr_t, size_t);
  81   79  int as_map_locked(struct as *, caddr_t, size_t, int ((*)()), void *);
  82   80  
  83   81  
  84   82  /*
  85   83   * Verifying the segment lists is very time-consuming; it may not be
  86   84   * desirable always to define VERIFY_SEGLIST when DEBUG is set.
↓ open down ↓ 797 lines elided ↑ open up ↑
 884  882                  break;
 885  883  
 886  884          case F_INVAL:
 887  885                  CPU_STATS_ENTER_K();
 888  886                  CPU_STATS_ADDQ(CPU, vm, as_fault, 1);
 889  887                  if (as == &kas)
 890  888                          CPU_STATS_ADDQ(CPU, vm, kernel_asflt, 1);
 891  889                  CPU_STATS_EXIT_K();
 892  890                  if (zonep->zone_pg_flt_delay != 0) {
 893  891                          /*
 894      -                         * The zone in which this process is running is
 895      -                         * currently over it's physical memory cap. Throttle
 896      -                         * page faults to help the user-land memory capper
 897      -                         * catch up. Note that drv_usectohz() rounds up.
      892 +                         * The zone in which this process is running
      893 +                         * is currently over it's physical memory cap.
      894 +                         * Throttle page faults to help the user-land
      895 +                         * memory capper catch up. Note that
      896 +                         * drv_usectohz() rounds up.
 898  897                           */
 899  898                          atomic_add_64(&zonep->zone_pf_throttle, 1);
 900  899                          atomic_add_64(&zonep->zone_pf_throttle_usec,
 901  900                              zonep->zone_pg_flt_delay);
 902      -                        if (zonep->zone_pg_flt_delay < TICK_TO_USEC(1)) {
      901 +                        if (zonep->zone_pg_flt_delay < TICK_TO_USEC(1))
 903  902                                  drv_usecwait(zonep->zone_pg_flt_delay);
 904      -                        } else {
      903 +                        else
 905  904                                  delay(drv_usectohz(zonep->zone_pg_flt_delay));
 906      -                        }
 907  905                  }
 908  906                  break;
 909  907          }
 910  908  
 911  909          /* Kernel probe */
 912  910          TNF_PROBE_3(address_fault, "vm pagefault", /* CSTYLED */,
 913  911              tnf_opaque, address,        addr,
 914  912              tnf_fault_type,     fault_type,     type,
 915  913              tnf_seg_access,     access,         rw);
 916  914  
↓ open down ↓ 787 lines elided ↑ open up ↑
1704 1702           * check for wrap around
1705 1703           */
1706 1704          if ((raddr + rsize < raddr) || (as->a_size > (ULONG_MAX - size))) {
1707 1705                  AS_LOCK_EXIT(as);
1708 1706                  return (ENOMEM);
1709 1707          }
1710 1708  
1711 1709          as->a_updatedir = 1;    /* inform /proc */
1712 1710          gethrestime(&as->a_updatetime);
1713 1711  
1714      -        if (as != &kas) {
1715      -                if (as->a_size + rsize > (size_t)p->p_vmem_ctl) {
1716      -                        AS_LOCK_EXIT(as);
     1712 +        if (as != &kas && as->a_size + rsize > (size_t)p->p_vmem_ctl) {
     1713 +                AS_LOCK_EXIT(as);
1717 1714  
1718      -                        (void) rctl_action(rctlproc_legacy[RLIMIT_VMEM],
1719      -                            p->p_rctls, p, RCA_UNSAFE_ALL);
1720      -                        return (ENOMEM);
1721      -                }
     1715 +                (void) rctl_action(rctlproc_legacy[RLIMIT_VMEM], p->p_rctls, p,
     1716 +                    RCA_UNSAFE_ALL);
1722 1717  
1723      -                /*
1724      -                 * Keep the number of segments in a userspace AS constrained to
1725      -                 * a reasonable limit.  Linux enforces a value slightly less
1726      -                 * than 64k in order to avoid ELF limits if/when a process
1727      -                 * dumps core.  While SunOS avoids that specific problem with
1728      -                 * other tricks, the limit is still valuable to keep kernel
1729      -                 * memory consumption in check.
1730      -                 */
1731      -                if (avl_numnodes(&as->a_segtree) >= as_user_seg_limit) {
1732      -                        AS_LOCK_EXIT(as);
1733      -                        atomic_inc_32(&p->p_zone->zone_mfseglim);
1734      -                        return (ENOMEM);
1735      -                }
     1718 +                return (ENOMEM);
1736 1719          }
1737 1720  
1738 1721          if (AS_MAP_CHECK_VNODE_LPOOB(crfp, argsp)) {
1739 1722                  crargs = *(struct segvn_crargs *)argsp;
1740 1723                  error = as_map_vnsegs(as, raddr, rsize, crfp, &crargs, &unmap);
1741 1724                  if (error != 0) {
1742 1725                          AS_LOCK_EXIT(as);
1743 1726                          if (unmap) {
1744 1727                                  (void) as_unmap(as, addr, size);
1745 1728                          }
↓ open down ↓ 1886 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX