Advanced Processor Affinity practice?

Am investigating processor affinity theory and practice, am somewhat surprised at the paucity of information on something that has been a part of many Windows Enterprise type applications for more than a decade and although I haven’t investigated would assume is supported by big iron UNIX.

What it is
Processor Affinity is the *NIX terminology for “soft” assigning a process and its threads to a specific processor core. On multi-tasking machines and particularly those which run heavy loads it can be useful to “advise” the Scheduler to isolate/assign heavy loads to a core separate from other processes. I also have a specific situation where I would like to run more than one instance of a specific app, but cannot when sharing the same processing environment.

What I’ve found so far
By default, any and all processes are assigned an affinity that permits running on any and all available processors…

The taskset utility can be used to modify the affinity for any process, which means that once an application/service/process has been launched, only then can the affinity be modified.

It seems that the RH platform may also have a utility called tuna which might provide some tuning capabilities in addition to setting affinity but does not seem to be in the SuSE repositories and I cannot find source.

Question:
Is there a reference or utility that can launch an application with a specified processor affinity?

TIA,
Tony

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

taskset can do this too, per its manpage.

<quote>
SYNOPSIS
taskset [options] mask command [arg]…
taskset [options] -p [mask] pid

DESCRIPTION
taskset is used to set or retrieve the CPU affinity of a
running process given its PID or to launch a new COMMAND with a given CPU
affinity. CPU affinity is a scheduler property that
“bonds” a process to a given set of CPUs on the system. The Linux
scheduler will honor the given CPU affinity and the process will not run
on any other CPUs. Note that the Linux scheduler
also supports natural CPU affinity: the scheduler attempts to keep
processes on the same CPU as long as practical for performance reasons.
Therefore, forcing a specific CPU affinity is use-
ful only in certain applications.

</quote>

Good luck.

On 10/27/2010 08:36 AM, tsu2 wrote:
>
> Am investigating processor affinity theory and practice, am somewhat
> surprised at the paucity of information on something that has been a
> part of many Windows Enterprise type applications for more than a decade
> and although I haven’t investigated would assume is supported by big
> iron UNIX.
>
> WHAT IT IS
> Processor Affinity is the *NIX terminology for “soft” assigning a
> process and its threads to a specific processor core. On multi-tasking
> machines and particularly those which run heavy loads it can be useful
> to “advise” the Scheduler to isolate/assign heavy loads to a core
> separate from other processes. I also have a specific situation where I
> would like to run more than one instance of a specific app, but cannot
> when sharing the same processing environment.
>
> WHAT I’VE FOUND SO FAR
> By default, any and all processes are assigned an affinity that permits
> running on any and all available processors…
>
> The taskset utility can be used to modify the affinity for any
> process, which means that once an application/service/process has been
> launched, only then can the affinity be modified.
>
> It seems that the RH platform may also have a utility called tuna which
> might provide some tuning capabilities in addition to setting affinity
> but does not seem to be in the SuSE repositories and I cannot find
> source.
>
> QUESTION:
> Is there a reference or utility that can launch an application with a
> specified processor affinity?
>
> TIA,
> Tony
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMyD0vAAoJEF+XTK08PnB5nGMP/2os72WOMuRM7T0/6+zgeZR2
2818pBRNDOXjHMuSADziTqoSIjCBnLq9zw/7SNYQgLelURhvze9440mNIQZk59zw
0y7iFeP4xxoQGQWNnVcnCHZaa+XKztfRbNuHiHvxPDUtuII3p7oAJUTU6ZsnNobp
Ub7t6P+qXjJ9wFvEPlX5Pg/QCxWyHE/m0ZWtiC/EnJivjzicQwm6jkxhFYSJFdmW
kpZiOIIQyB5exZVw+6LZPmACY75INcSG3wKeHtO9z+SKi0RllDpH3DfnPupb7GgN
AFG+a5BoV/mtIBeQomt9aiAeVTlC4jNclUAlZJ//VVy1pvg79EycXXAUZsrVcdYA
0DHxOLJTR726w0atTKfoYV95RWFnfnC3E5D4LzGDwsIMmwhyYSjYjP9CCjX0LWgS
OGz9JYXvT59pF96A425TNFScpbS+dgk5I0lwByb6mbnsh18qjczEFU8hVdHT64MM
m0hBHWC1vVdL5+XMSFlK9zk7zqwCGcDWZGlXZq5oIpTpLM+QujVOUVSQk+bgnbki
3jWhkLrhEitmRs2pIStOZ/L3hCXDS7jVNn9nkCEo5X0osA/Oej/4FEOUIUkWZjSp
A0JlEyqsQm0N2mSoyQVzdZ7GC3wlRcsSiCCCvTAZkvRx+YA00k0NZB3m0tA2Ffq6
eI3JyOgkKG0c4kQyezW4
=L0p2
-----END PGP SIGNATURE-----

tsu2 wrote:

>
> The taskset utility can be used to modify the affinity for any
> process, which means that once an application/service/process has been
> launched, only then can the affinity be modified.
>
I understand the manpage slightly different, you can start a process with
the affinity given at startup like

taskset 0x00000001 kwrite

to start on CPU 0.


openSUSE 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.5 | GeForce
9600 GT | 4GB Ram
openSUSE 11.3 64 bit | Intel Core2 Duo T9300@2.50GHz | KDE 4.5 | Quadro FX
3600M | 4GB Ram

Howdy,
Actually, all the examples I dug up support the likelihood that by default you can’t use taskset with an application name, only with a PID, and since a PID isn’t assigned until an application has already been launched…

Of course, that did lead me earlier to speculate on the possibility (although I cannot find an example) of scripting an application launch followed by modifying affinity. To date I haven’t researched fully hoping for a “better” current solution but I did locate some posted utilities from 2 years ago that likely do just that.

And, all that of course is aside from the problems associated with launching KDE applications from the CLI with modified parameters (always causes a crash which requires various modifications to suppress and address).

Tony

How 'bout that…

I played around with this a bit more and it seems that the COMMAND (as quoted in
ab@novell.com’s post) is supported only in the very specialized use of TASKSET when launching an application (Of course I used a CLI command and not a KDE app).

Thereafter, it seems that viewing and modifying requires the PID and the COMMAND is not supported.

Thx,
Tony

Most likely because you could have multiple instances of a give program name but PID is unique to one process.

Possibly :),
Over this next week or so I’ll likely be testing a few different scenarios to more precisely pin down what might be possible or not in different situations, but at least initially it’s very trouble-saving to be able to launch at least the first instance of an application by name.

Tony