AbstractProcessor sets are an interesting feature of the Solaris operating environment that allow the binding of processes to groups of CPUs in a multiprocessor system. There are numerous reasons why processor sets can be useful:
This article describes the support Solaris offers for processor set creation and process binding. In addition, a modular set of Perl scripts is described that facilitate the handling of even very complex processor sets and process binding requirements. The application of these scripts in a real-life example scenario (based on two important ISV applications: the SAP R/3 ERP system and the Oracle RDBMS) is demonstrated. Note that the
scripts described below are available as a compressed
Identifying CPUs and Their StateWhen process binding and processor set creation is considered, the first step is to identify the available CPUs in the system and their state. The basic
tools that Solaris makes available to accomplish these
tasks are A CPU is in
one of several possible states, which are reported by
Only CPUs in
states 1 and 3 can be used for process binding and
assigned to processor sets. At the same time, CPUs can
already be assigned to processor sets. These can be
identified using Traditional Process BindingThe
capability of binding a process to a specific CPU has been
available in Solaris for a long time. On the OS level,
this binding is accomplished using the Using this
approach, all LWPs of a
given process are bound to the specified CPU, and the
binding is not exclusive, that is, other LWPs in the
system may get scheduled to the same CPU. Thus, it is not
possible to exclusively reserve a CPU for a given process.
It is also not easy to allocate more than one CPU to a
multithreaded application since this would have to be done
programmatically using Solaris Processor SetsWith release 2.6, Solaris added support for processor sets, a logical partitioning of the CPUs in a multiprocessor system. Processor
sets are maintained using the psrset -c 3 4 5 would create a processor set using the CPUs 3, 4, and 5 (provided they are available for assignment to such a set). Each processor set in a system has a unique ID (=> 1), which is returned by the OS after set creation. Note that processor sets are not persistent, that is, they're gone after a reboot of the system. Only
processes and LWPs that have been explicitly bound to a
processor set via Note that it
is not possible to bind any other processes or LWPs to
CPUs assigned to a user-created processor set using It is also not possible to bind every CPU in a multiprocessor system to a user processor set. At least one CPU needs to remain unbound since otherwise the kernel itself would not have any CPU left for its own processing. Note that Another
Solaris tool offering support for processor sets is Creating a Processor Set - A More Convenient ApproachThere are four basic steps involved in binding one or more processes to a processor set:
The basic Solaris tools described so far offer the complete functionality required to handle these tasks. However, there are some shortcomings:
The Solaris commands are too generic to handle these use cases, and thus a modular set of Perl scripts to easily handle more complex tasks was developed as an abstraction layer between the user and the Solaris commands. These scripts can then be reused by even higher-level scripts to automatically generate very complex processor sets and process binding patterns on distributed host configurations. Before
creating a processor set, a snapshot of the CPUs and their
state in the system is required. The script An example output could look like this: 10 CPU total in system 0 1 2 3 4 5 6 7 10 11 8 CPU on-line 0 1 2 4 5 6 10 11 3 CPU no-intr 2 4 10 2 CPU off-line 3 7 4 CPU assigned to set(s) 0 1 2 10 4 CPU available for assignment 4 5 6 11 Now a
complete picture of the CPUs in the system is available,
which will be used by the next script in the stack to
create new processor sets. Note that After it has
been determined which CPUs can be used for assignment to a
new processor set, this set needs to be created. Rather
than explicitly specifying the CPU numbers determined
above as arguments to make_psrset 4 would create
a set using the first 4 available CPUs as determined by Some Convenience ScriptsThis section describes some more scripts that can be useful when dealing with processor sets. These scripts are utility scripts facilitating common tasks related to processor set and process management. This script
is a convenience wrapper for the Solaris This script
gives a complete picture of all processor sets in the
system and the processes bound to each of them. Lists of
processes are also written to files for each processor set
for other postprocessing purposes. This is a
first example application built on top of the other
scripts described in this article. In scenarios where servers have to handle heavy network traffic, isolating CPUs handling interrupts into a separate processor set can be a useful performance tuning approach. Since these CPUs can be consumed by this task to a significant percentage, application processes being scheduled to the same CPU will experience a high rate of context switches, especially given the high priorities of the interrupts. This can significantly impact the performance of such application processes. Note,
however, that enabling and disabling interrupt handling
for a CPU affects both network and I/O interrupts, so it is crucial to
monitor application, network, and I/O performance when
modifying the interrupt handling state of CPUs. Experience
has shown that under heavy network and I/O load, I/O performance suffers when
the interrupts are just constrained to a small set of
CPUs. In these cases, it is best to identify the CPUs
handling network interrupts (for example, using Identifying ProcessesNow that a processor set can be created, the processes to be bound to it need to be identified. Ideally, this should be possible at an abstract level rather than by specifying lists of PIDs. So the task is to map an abstract description of a process (or set of processes) to a PID (or a list of PIDs). Unfortunately,
there is no general solution to this. The natural first
approach is to use Thus, in more complicated scenarios, it is necessary to employ a different strategy to identify processes. In the example scenario, scripts will be described satisfying the sole purpose of identifying PIDs of a specific process type in an application. They can then -- following the modular approach -- be re-used by higher-level scripts. Sometimes all
processes of an application need to be bound to a
processor set, but it is difficult to know which processes
actually are started by the application. If all
application processes are spawned by one parent process,
one approach is to use the Solaris ptree <PID> prints the
process tree, that is, all parents and children for this
process. The top-level parent process PID can then be used
in a second call to Another
approach is to look for application-specific tools that
could be used to retrieve the required information. One
example is ( Sometimes it
can also be useful to use the BSD variant of /usr/ucb/ps axw correctly
displays the different process types and thus allows you
to distinguish them, while the standard variant prints the
same process name in the So, to summarize, there is not one single strategy to satisfy abstract process identification requirements. Built on the approaches described in this section, the recommendation is to build scripts to manage this task for specific applications and then re-use them as modules in higher-level scripts as outlined in the next section. Example ScenarioScenario Description This last section is devoted to an example application of the concepts described and the scripts developed so far. The idea is to demonstrate that even complex process binding requirements can easily be handled by adding some script support in between the user requirements and the basic Solaris tools. The individual scripts are not described on a detailed code basis since some of them are quite lengthy, but the basic ideas and the integration of the concepts and scripts of the previous sections are outlined. Since the source code of these scripts is available, their modification and extension to meet different requirements should be straightforward. The scenario described here is based on two important ISV applications: the SAP R/3 ERP system and the Oracle RDBMS. The first layer of scripts described below covers these applications individually, while the second layer then deals with them in a joint scenario (SAP R/3 application servers connecting to an Oracle database). Identifying Processes The task of
this script is to identify the PIDs of all processes of an
R/3 instance. The problem to be solved here is that
several of the main R/3 processes (like dispatcher,
dialog, update, batch, spool and enqueue) show up with the
same value in the
The details of how these various strategies are combined can be seen by inspecting the script source code. Example: identify_procs_psrsets C46 D14 could produce the following output (process type - PID): DIA 26730 DIA 26731 DIA 26732 DIA 26733 DIA 26734 DIA 19704 DIA 26735 DIA 26736 DIS 19673 GWR 19696 OTH 19666 SEP 19674 UPD 19709 UPD 19710 UPD 19711 The process types are identified using three-letter acronyms. The complete list of these acronyms is: DIA - Dialog process BTC - Batch process SPO - Spool process ENQ - Enqueue process UPD - Update 1 process UP2 - Update 2 process DIS - Dispatcher MSG - Message server COP - Systemlog-collector SEP - Systemlog-sender GWR - Gateway-process OTH - All other processes (e. g. sapstart) These output
lists can be processed by other scripts. An example of
this is The task of
this script is to identify the PIDs of all processes of an
Oracle instance. This task is much simpler than for an R/3
instance since the processes can readily be identified by
the value in the DBW - DB writer LGW - Log writer LSR - Listener SHA - Shadow process CKP - Checkpoint process PMO - PMON process SMO - SMON process SNP - SNP process REC - RECO process These output
lists can also be processed by other scripts like Note that full support for the IBM DB2 database is planned for a future release. Putting it all together Now that
processor sets can be created and processes can be
identified, both tasks need to be brought together. This
is where
-f=<file> : PIDs specified in the input file <file> -u=<user> : Processes owned by user <user> -c=<command> : Processes whose CMD field in the ps output matches <command> -r=<SID>:<instance>:<procs> : Processes of an SAP R/3 instance -o=<SID>:<procs> : Processes of an Oracle instance The processes
thus identified are then bound to a newly created
processor set. The cool feature here is that any number of such
specifiers can be combined in one call of SAP R/3
instances are specified by the ternary identifier Some examples: Bind all
processes of user manage_psrsets -u=orac46 -f=pidlist.txt 5 Bind the
dispatchers of instances manage_psrsets -r=C46:D10:DIS -r=C46:D11:DIS -r=C46:D12:DIS -r=BIN:DVEBMGS00:ALL 10 Note that the
latter example could be simplified using a shortcut for
the manage_psrsets -r=C46:D.10.12:DIS -r=BIN:DVEBMGS00:ALL 10
This is an
example application built on top of some of the other
scripts described in this article. First, all
Oracle process IDs and their matching counterparts (SAP
R/3 processes) are obtained from the This output
can be used in SummaryThe scripts
described in this article can significantly simplify the
task of creating processor sets with complex process
binding requirements. They form an additional abstraction
layer on top of the Solaris tools ResourcesMauro, Jim,
and Richard McDougall Solaris
Internals: Core Kernel Architecture: Prentice Hall
PTR/Sun Microsystems Press, 2000. Appendix Solaris Support for Process Binding and Processor Sets
About the AuthorDr. Matthias Laux is a system engineer working in the Global SAP-Sun Competence Center in Walldorf, Germany. His main interests are Java/J2EE/XML infrastructure and programming, databases and SAP benchmarking. Although he also has a background in aerospace engineering and HPC / parallel programming, today his languages of choice are Java and Perl. June 2001 |