Print this page
9936 atomic ops in syscall_mstate() induce significant overhead
9942 zone secflags are not initialized correctly

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/zone.h
          +++ new/usr/src/uts/common/sys/zone.h
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2015 Joyent, Inc. All rights reserved.
       23 + * Copyright 2018 Joyent, Inc.
  24   24   * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  25   25   * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
  26   26   */
  27   27  
  28   28  #ifndef _SYS_ZONE_H
  29   29  #define _SYS_ZONE_H
  30   30  
  31   31  #include <sys/types.h>
  32   32  #include <sys/mutex.h>
  33   33  #include <sys/param.h>
↓ open down ↓ 1 lines elided ↑ open up ↑
  35   35  #include <sys/ipc_rctl.h>
  36   36  #include <sys/pset.h>
  37   37  #include <sys/tsol/label.h>
  38   38  #include <sys/cred.h>
  39   39  #include <sys/netstack.h>
  40   40  #include <sys/uadmin.h>
  41   41  #include <sys/ksynch.h>
  42   42  #include <sys/socket_impl.h>
  43   43  #include <sys/secflags.h>
  44   44  #include <netinet/in.h>
       45 +#include <sys/cpu_uarray.h>
  45   46  
  46   47  #ifdef  __cplusplus
  47   48  extern "C" {
  48   49  #endif
  49   50  
  50   51  /*
  51   52   * NOTE
  52   53   *
  53   54   * The contents of this file are private to the implementation of
  54   55   * Solaris and are subject to change at any time without notice.
↓ open down ↓ 268 lines elided ↑ open up ↑
 323  324  
 324  325  /*
 325  326   * We need to protect the definition of 'list_t' from userland applications and
 326  327   * libraries which may be defining ther own versions.
 327  328   */
 328  329  #include <sys/list.h>
 329  330  #include <sys/loadavg.h>
 330  331  
 331  332  #define GLOBAL_ZONEUNIQID       0       /* uniqid of the global zone */
 332  333  
      334 +/*
      335 + * Indexes into ->zone_ustate array, summing the micro state of all threads in a
      336 + * particular zone.
      337 + */
      338 +#define ZONE_USTATE_STIME (0)
      339 +#define ZONE_USTATE_UTIME (1)
      340 +#define ZONE_USTATE_WTIME (2)
      341 +#define ZONE_USTATE_MAX (3)
      342 +
 333  343  struct pool;
 334  344  struct brand;
 335  345  
 336  346  /*
 337  347   * Each of these constants identifies a kernel subsystem that acquires and
 338  348   * releases zone references.  Each subsystem that invokes
 339  349   * zone_hold_ref() and zone_rele_ref() should specify the
 340  350   * zone_ref_subsys_t constant associated with the subsystem.  Tracked holds
 341  351   * help users and developers quickly identify subsystems that stall zone
 342  352   * shutdowns indefinitely.
↓ open down ↓ 83 lines elided ↑ open up ↑
 426  436           * accesses), but that might have to change when we allow
 427  437           * administrators to change running zones' properties.
 428  438           *
 429  439           * The global zone's zone_hostid must always be HW_INVALID_HOSTID so
 430  440           * that zone_get_hostid() will function correctly.
 431  441           */
 432  442          uint32_t        zone_hostid;    /* zone's hostid, HW_INVALID_HOSTID */
 433  443                                          /* if not emulated */
 434  444          /*
 435  445           * zone_lock protects the following fields of a zone_t:
 436      -         *      zone_ref
 437      -         *      zone_cred_ref
 438      -         *      zone_subsys_ref
 439      -         *      zone_ref_list
 440      -         *      zone_ntasks
 441      -         *      zone_flags
 442      -         *      zone_zsd
      446 +         *      zone_ref
      447 +         *      zone_cred_ref
      448 +         *      zone_subsys_ref
      449 +         *      zone_ref_list
      450 +         *      zone_ntasks
      451 +         *      zone_flags
      452 +         *      zone_zsd
 443  453           *      zone_pfexecd
 444  454           */
 445  455          kmutex_t        zone_lock;
 446  456          /*
 447  457           * zone_linkage is the zone's linkage into the active or
 448  458           * death-row list.  The field is protected by zonehash_lock.
 449  459           */
 450  460          list_node_t     zone_linkage;
 451  461          zoneid_t        zone_id;        /* ID of zone */
 452  462          uint_t          zone_ref;       /* count of zone_hold()s on zone */
↓ open down ↓ 83 lines elided ↑ open up ↑
 536  546           * List of ZFS datasets exported to this zone.
 537  547           */
 538  548          list_t          zone_datasets;  /* list of datasets */
 539  549  
 540  550          ts_label_t      *zone_slabel;   /* zone sensitivity label */
 541  551          int             zone_match;     /* require label match for packets */
 542  552          tsol_mlp_list_t zone_mlps;      /* MLPs on zone-private addresses */
 543  553  
 544  554          boolean_t       zone_restart_init;      /* Restart init if it dies? */
 545  555          struct brand    *zone_brand;            /* zone's brand */
 546      -        void            *zone_brand_data;       /* store brand specific data */
      556 +        void            *zone_brand_data;       /* store brand specific data */
 547  557          id_t            zone_defaultcid;        /* dflt scheduling class id */
 548  558          kstat_t         *zone_swapresv_kstat;
 549  559          kstat_t         *zone_lockedmem_kstat;
 550  560          /*
 551  561           * zone_dl_list is protected by zone_lock
 552  562           */
 553  563          list_t          zone_dl_list;
 554  564          netstack_t      *zone_netstack;
 555  565          struct cpucap   *zone_cpucap;   /* CPU caps data */
 556  566          /*
↓ open down ↓ 20 lines elided ↑ open up ↑
 577  587          uint64_t        zone_pgpgin;            /* pages paged in */
 578  588          uint64_t        zone_anonpgin;          /* anon pages paged in */
 579  589          uint64_t        zone_execpgin;          /* exec pages paged in */
 580  590          uint64_t        zone_fspgin;            /* fs pages paged in */
 581  591          uint64_t        zone_anon_alloc_fail;   /* cnt of anon alloc fails */
 582  592  
 583  593          psecflags_t     zone_secflags; /* default zone security-flags */
 584  594  
 585  595          /*
 586  596           * Misc. kstats and counters for zone cpu-usage aggregation.
 587      -         * The zone_Xtime values are the sum of the micro-state accounting
 588      -         * values for all threads that are running or have run in the zone.
 589      -         * This is tracked in msacct.c as threads change state.
 590      -         * The zone_stime is the sum of the LMS_SYSTEM times.
 591      -         * The zone_utime is the sum of the LMS_USER times.
 592      -         * The zone_wtime is the sum of the LMS_WAIT_CPU times.
 593      -         * As with per-thread micro-state accounting values, these values are
 594      -         * not scaled to nanosecs.  The scaling is done by the
 595      -         * zone_misc_kstat_update function when kstats are requested.
 596  597           */
 597  598          kmutex_t        zone_misc_lock;         /* protects misc statistics */
 598  599          kstat_t         *zone_misc_ksp;
 599  600          zone_misc_kstat_t *zone_misc_stats;
 600      -        uint64_t        zone_stime;             /* total system time */
 601      -        uint64_t        zone_utime;             /* total user time */
 602      -        uint64_t        zone_wtime;             /* total time waiting in runq */
      601 +        /* Accumulated microstate for all threads in this zone. */
      602 +        cpu_uarray_t    *zone_ustate;
 603  603          /* fork-fail kstat tracking */
 604  604          uint32_t        zone_ffcap;             /* hit an rctl cap */
 605  605          uint32_t        zone_ffnoproc;          /* get proc/lwp error */
 606  606          uint32_t        zone_ffnomem;           /* as_dup/memory error */
 607  607          uint32_t        zone_ffmisc;            /* misc. other error */
 608  608  
 609  609          uint32_t        zone_nested_intp;       /* nested interp. kstat */
 610  610  
 611  611          struct loadavg_s zone_loadavg;          /* loadavg for this zone */
 612  612          uint64_t        zone_hp_avenrun[3];     /* high-precision avenrun */
↓ open down ↓ 61 lines elided ↑ open up ↑
 674  674   * The following is what code should be initializing its zone_key_t to if it
 675  675   * calls zone_getspecific() without necessarily knowing that zone_key_create()
 676  676   * has been called on the key.
 677  677   */
 678  678  #define ZONE_KEY_UNINITIALIZED  0
 679  679  
 680  680  typedef uint_t zone_key_t;
 681  681  
 682  682  extern void     zone_key_create(zone_key_t *, void *(*)(zoneid_t),
 683  683      void (*)(zoneid_t, void *), void (*)(zoneid_t, void *));
 684      -extern int      zone_key_delete(zone_key_t);
      684 +extern int      zone_key_delete(zone_key_t);
 685  685  extern void     *zone_getspecific(zone_key_t, zone_t *);
 686  686  extern int      zone_setspecific(zone_key_t, zone_t *, const void *);
 687  687  
 688  688  /*
 689  689   * The definition of a zsd_entry is truly private to zone.c and is only
 690  690   * placed here so it can be shared with mdb.
 691  691   *
 692  692   * State maintained for each zone times each registered key, which tracks
 693  693   * the state of the create, shutdown and destroy callbacks.
 694  694   *
↓ open down ↓ 5 lines elided ↑ open up ↑
 700  700          zone_key_t              zsd_key;        /* Key used to lookup value */
 701  701          void                    *zsd_data;      /* Caller-managed value */
 702  702          /*
 703  703           * Callbacks to be executed when a zone is created, shutdown, and
 704  704           * destroyed, respectively.
 705  705           */
 706  706          void                    *(*zsd_create)(zoneid_t);
 707  707          void                    (*zsd_shutdown)(zoneid_t, void *);
 708  708          void                    (*zsd_destroy)(zoneid_t, void *);
 709  709          list_node_t             zsd_linkage;
 710      -        uint16_t                zsd_flags;      /* See below */
      710 +        uint16_t                zsd_flags;      /* See below */
 711  711          kcondvar_t              zsd_cv;
 712  712  };
 713  713  
 714  714  /*
 715  715   * zsd_flags
 716  716   */
 717  717  #define ZSD_CREATE_NEEDED       0x0001
 718  718  #define ZSD_CREATE_INPROGRESS   0x0002
 719  719  #define ZSD_CREATE_COMPLETED    0x0004
 720  720  #define ZSD_SHUTDOWN_NEEDED     0x0010
↓ open down ↓ 147 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX