1 .\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
   2 .\" Copyright 2019 Joyent, Inc.
   3 .\"
   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 .Dd December 17, 2019
  20 .Dt FSS 7
  21 .Os
  22 .Sh NAME
  23 .Nm FSS
  24 .Nd Fair share scheduler
  25 .Sh DESCRIPTION
  26 The fair share scheduler (FSS) guarantees application performance by explicitly
  27 allocating shares of CPU resources to projects.
  28 A share indicates a project's
  29 entitlement to available CPU resources.
  30 Because shares are meaningful only in
  31 comparison with other project's shares, the absolute quantity of shares is not
  32 important.
  33 Any number that is in proportion with the desired CPU entitlement
  34 can be used.
  35 .Pp
  36 The goals of the FSS scheduler differ from the traditional time-sharing
  37 scheduling class (TS).
  38 In addition to scheduling individual LWPs, the FSS
  39 scheduler schedules projects against each other, making it impossible for any
  40 project to acquire more CPU cycles simply by running more processes
  41 concurrently.
  42 .Pp
  43 A project's entitlement is individually calculated by FSS independently for
  44 each processor set if the project contains processes bound to them.
  45 If a
  46 project is running on more than one processor set, it can have different
  47 entitlements on every set.
  48 A project's entitlement is defined as a ratio
  49 between the number of shares given to a project and the sum of shares of all
  50 active projects running on the same processor set.
  51 An active project is one
  52 that has at least one running or runnable process.
  53 Entitlements are recomputed
  54 whenever any project becomes active or inactive, or whenever the number of
  55 shares is changed.
  56 .Pp
  57 Processor sets represent virtual machines in the FSS scheduling class and
  58 processes are scheduled independently in each processor set.
  59 That is, processes
  60 compete with each other only if they are running on the same processor set.
  61 When a processor set is destroyed, all processes that were bound to it are
  62 moved to the default processor set, which always exists.
  63 Empty processor sets
  64 (that is, sets without processors in them) have no impact on the FSS scheduler
  65 behavior.
  66 .Pp
  67 If a processor set contains a mix of TS/IA and FSS processes, the fairness of
  68 the FSS scheduling class can be compromised because these classes use the same
  69 range of priorities.
  70 Fairness is most significantly affected if processes
  71 running in the TS scheduling class are CPU-intensive and are bound to
  72 processors within the processor set.
  73 As a result, you should avoid having
  74 processes from TS/IA and FSS classes share the same processor set.
  75 RT and FSS
  76 processes use disjoint priority ranges and therefore can share processor sets.
  77 .Pp
  78 As projects execute, their CPU usage is accumulated over time.
  79 The FSS
  80 scheduler periodically decays CPU usages of every project by multiplying it
  81 with a decay factor, ensuring that more recent CPU usage has greater weight
  82 when taken into account for scheduling.
  83 The FSS scheduler continually adjusts
  84 priorities of all processes to make each project's relative CPU usage converge
  85 with its entitlement.
  86 .Pp
  87 While FSS is designed to fairly allocate cycles over a long-term time period,
  88 it is possible that projects will not receive their allocated shares worth of
  89 CPU cycles due to uneven demand.
  90 This makes one-shot, instantaneous analysis of
  91 FSS performance data unreliable.
  92 .Pp
  93 Note that share is not the same as utilization.
  94 A project may be allocated 50%
  95 of the system, although on the average, it uses just 20%.
  96 Shares serve to cap a
  97 project's CPU usage only when there is competition from other projects running
  98 on the same processor set.
  99 When there is no competition, utilization may be
 100 larger than entitlement based on shares.
 101 Allocating a small share to a busy
 102 project slows it down but does not prevent it from completing its work if the
 103 system is not saturated.
 104 .Pp
 105 The configuration of CPU shares is managed by the name server as a property of
 106 the
 107 .Xr project 4
 108 database.
 109 In the following example, an entry in the
 110 .Pa /etc/project
 111 file sets the number of shares for project
 112 .Sy x-files
 113 to 10:
 114 .Bd -literal -offset 2n
 115 x-files:100::::project.cpu-shares=(privileged,10,none)
 116 .Ed
 117 .Pp
 118 Projects with undefined number of shares are given one share each.
 119 This means
 120 that such projects are treated with equal importance.
 121 Projects with 0 shares
 122 only run when there are no projects with non-zero shares competing for the same
 123 processor set.
 124 The maximum number of shares that can be assigned to one project
 125 is 65535.
 126 .Pp
 127 You can use the
 128 .Xr prctl 1
 129 command to determine the current share
 130 assignment for a given project:
 131 .Bd -literal -offset 2n
 132 $ prctl -n project.cpu-shares -i project x-files
 133 .Ed
 134 .Pp
 135 or to change the amount of shares if you have root privileges:
 136 .Bd -literal -offset 2n
 137 # prctl -r -n project.cpu-shares -v 5 -i project x-files
 138 .Ed
 139 .Pp
 140 See the
 141 .Xr prctl 1
 142 man page for additional information on how to modify and
 143 examine resource controls associated with active processes, tasks, or projects
 144 on the system.
 145 See
 146 .Xr resource_controls 5
 147 for a description of the resource
 148 controls supported in the current release of the Solaris operating system.
 149 .Pp
 150 By default, project
 151 .Sy system
 152 (project ID 0) includes all system daemons
 153 started by initialization scripts and has an
 154 .Dq unlimited
 155 amount of shares.
 156 That
 157 is, it is always scheduled first no matter how many shares are given to other
 158 projects.
 159 .Pp
 160 The following command sets FSS as the default scheduler for the system:
 161 .Bd -literal -offset 2n
 162 # dispadmin -d FSS
 163 .Ed
 164 .Pp
 165 This change will take effect on the next reboot.
 166 Alternatively, you can move
 167 processes from the time-share scheduling class (as well as the special case of
 168 init) into the FSS class without changing your default scheduling class and
 169 rebooting by becoming
 170 .Sy root ,
 171 and then using the
 172 .Xr priocntl 1
 173 command, as shown in the following example:
 174 .Bd -literal -offset 2n
 175 # priocntl -s -c FSS -i class TS
 176 # priocntl -s -c FSS -i pid 1
 177 .Ed
 178 .Sh CONFIGURING SCHEDULER WITH DISPADMIN
 179 You can use the
 180 .Xr dispadmin 1M
 181 command to examine and tune the FSS
 182 scheduler's time quantum value.
 183 Time quantum is the amount of time that a
 184 thread is allowed to run before it must relinquish the processor.
 185 The following
 186 example dumps the current time quantum for the fair share scheduler:
 187 .Bd -literal -offset 2n
 188 $ dispadmin -g -c FSS
 189         #
 190         # Fair Share Scheduler Configuration
 191         #
 192         RES=1000
 193         #
 194         # Time Quantum
 195         #
 196         QUANTUM=110
 197 .Ed
 198 .Pp
 199 The value of the QUANTUM represents some fraction of a second with the
 200 fractional value determined by the reciprocal value of RES.
 201 With the default
 202 value of RES = 1000, the reciprocal of 1000 is \&.001, or milliseconds.
 203 Thus, by
 204 default, the QUANTUM value represents the time quantum in milliseconds.
 205 .Pp
 206 If you change the RES value using
 207 .Xr dispadmin 1M
 208 with the
 209 .Fl r
 210 option, you also change the QUANTUM value.
 211 For example, instead of quantum of 110 with RES
 212 of 1000, a quantum of 11 with a RES of 100 results.
 213 The fractional unit is different while the amount of time is the same.
 214 .Pp
 215 You can use the
 216 .Fl s
 217 option to change the time quantum value.
 218 Note that such changes are not preserved across reboot.
 219 Please refer to the
 220 .Xr dispadmin 1M
 221 man page for additional information.
 222 .Sh SEE ALSO
 223 .Xr prctl 1 ,
 224 .Xr priocntl 1 ,
 225 .Xr dispadmin 1M ,
 226 .Xr psrset 1M ,
 227 .Xr priocntl 2 ,
 228 .Xr project 4 ,
 229 .Xr resource_controls 5
 230 .Pp
 231 .%T System Administration Guide: Virtualization Using the Solaris Operating System