Operating System - HP-UX
1846305 Members
3703 Online
110256 Solutions
New Discussion

Kernel parameter for binding user processes to processor

 
SOLVED
Go to solution
Igor I. Shulz
Frequent Advisor

Kernel parameter for binding user processes to processor

Does anybody knows Kernel parameter for binding user processes to some fixed processor (i.e. affinity bind)?
OS HP-UX 11i on multiprocess system
8 REPLIES 8
Jim Turner
HPE Pro

Re: Kernel parameter for binding user processes to processor

Hi Igor,

Same with Oracle. Processor affinity is set within the application. Nothing to set in the kernel.

Cheers,
Jim
Pete Randall
Outstanding Contributor

Re: Kernel parameter for binding user processes to processor

Igor,

I could well be wrong, but I don't think there's a related kernel parameter. Our Informix database has a "set processor affinity" option in it's startup that we were able to utilize without kernel changes.

Pete

Pete
Patrick Wallek
Honored Contributor
Solution

Re: Kernel parameter for binding user processes to processor

There is no such kernel parameter. Normally you want processes to be able to switch between processors.

There is a product called Process Resource Manager (PRM) that might allow you to do this.
Dietmar Konermann
Honored Contributor

Re: Kernel parameter for binding user processes to processor

No kernel tunable... on 11.11 you should have a look at mpsched(1) and mpctl(2).

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Volker Kiehn
Occasional Advisor

Re: Kernel parameter for binding user processes to processor

there is no kernel parameter for binding user processes to a fixed processor.

You can set the processor affinity with the system call mpctl in a program.

See man 2 mpctl
Oleg Zieaev_1
Regular Advisor

Re: Kernel parameter for binding user processes to processor

Hello Igor.

If lack of CPU resources is a problem for your process, you may consider priory manipulations using rtprio. However have to be carefull and do not overdo it :).
In case your concerns are 'global' like controling CPU resources for the group(s) of application - go with PRM.
I am not aware of any kernel parameters to manage CPU bindings.

Hope this helps.
0leg
Professionals will prevail ...
Johannes Falk
New Member

Re: Kernel parameter for binding user processes to processor

HP sent me two sources in 1999,
one to nail the process at start
the other to nail it later.
Both work fine. The sources are in the attachement.

see man 2 mpctl:

mpctl(2) mpctl(2)

NAME
mpctl - multiprocessor control

SYNOPSIS
#include

int mpctl(
mpc_request_t request,
spu_t spu,
pid_t pid
);

int mpctl(
mpc_request_t request,
spu_t spu,
lwpid_t lwpid
);

REMARKS
Much of the functionality of this capability is highly dependent on
the underlying hardware. An application that uses this system call
should not be expected to be portable across architectures or
implementations.

DESCRIPTION
mpctl provides a means of determining how many processors are
installed in the system and assigning proceses/lightweight processes
to run on specific processors.

This call is expected to be used to increase performance in certain
applications, but should not be used to ensure correctness of an
application. Specifically, cooperating processes/lightweight
processes should not rely on processor assignment in lieu of a
synchronization mechanism (such as semaphores).
...
Moin, moin!
Emil Velez_2
HPE Pro

Re: Kernel parameter for binding user processes to processor

/* This is the source code for "pbind.c" to bind/unbind/query a
given process.
This works on HP-UX 9.X,10.X and 11.X.
Don't remember who wrote the source code.
*/
/*
GETNUMSPUS();
GETFIRSTSPU();
GETNETXSPU(i);
PROCDISABLE(cpu); 0 = OK -1 = Faild
PROCENABLE(cpu); 0 = OK -1 = Faild
GETPROCSTAT(cpu); 0 = OK -1 = Faild
SETPROCESS(cpu,pid); MPC_SPUFLOAT, MPC_SPUNOCHANGE or cpu, pid
*/
#include
#include
#include
#define P_BIND 0
#define P_FLOAT 1
#define QUERY 2

extern int optind;
extern char *optarg;

main(argc,argv)
int argc;
char *argv[];
{
int num_cpu,first_cpu,next_cpu;
int i;
int pid = 0;
int cpu = 0;
int ret = 0;
int opt;
int b_u = 9;
char u[2];
char buf[60];

if( argc < 2) usage();
while((opt = getopt(argc,argv,"u:b:q:")) != -1)
{
switch(opt){
case 'b' : b_u = P_BIND;
if( argc < 4) usage();
cpu = atoi(optarg);
pid = atoi(argv[3]);
break;
case 'u' : b_u = P_FLOAT;
if( argc < 3) usage();
pid = atoi(optarg);
break;
case 'q' : b_u = QUERY;
pid = atoi(optarg);
break;
default :
usage();
break;
}
}
num_cpu = GETNUMSPUS();
if(cpu > num_cpu -1 ){
printf("%d processor(s) aviable in this system\n",num_cpu);
usage();
exit(1);
}
first_cpu = GETFIRSTSPU();
if(b_u == P_BIND){
ret = SETPROCESS(cpu,pid);
u[0] = ('0' + ret);
printf("Process id %d is bound to processor %s\n",pid,
(ret == MPC_SPUNOCHANGE) ? "unknown" :
(ret == MPC_SPUFLOAT) ? "FLOATING" :
(ret == -1) ? "ERROR IN BINDING" :
(ret >= 0) ? u : "ILLEGAL VALUE" );
}
else if(b_u == P_FLOAT){
cpu = MPC_SPUFLOAT;
ret = SETPROCESS(cpu,pid);
u[0] = ('0' + ret);
printf("Process id %d is set to %s\n",pid,
(ret == MPC_SPUNOCHANGE) ? "NO CHANGE" :
(ret == MPC_SPUFLOAT) ? "FLOATING" :
(ret == -1) ? "ERROR IN RELEASING" :
(ret >= 0) ? u : "ILLEGAL VALUE" );
}
else if(b_u == QUERY){
cpu = MPC_SPUNOCHANGE;
ret = SETPROCESS(cpu,pid);
u[0] = ('0' + ret);
strcpy(buf,"is bound to processor ");
strcat(buf,u);
printf("Process id %d %s\n",pid,
(ret == MPC_SPUNOCHANGE) ? "NO CHANGE" :
(ret == MPC_SPUFLOAT) ? "is set to FLOATING" :
(ret == -1) ? "QUERING ERROR" :
(ret >= 0) ? buf : "ILLEGAL VALUE" );

}
}
/*
if(ret != -1){
cpu = MPC_SPUNOCHANGE;
ret = SETPROCESS(cpu,pid);
printf("Process id %d not to CPU # %d ret = %d\n",pid,cpu,ret);
printf("Process id %d is set to %s\n",pid,
(ret == MPC_SPUNOCHANGE) ? "NO CHANGE" :
(ret == MPC_SPUFLOAT) ? "FLOATING" :
(ret == -1) ? "ERROR IN BINDING" : "OK" );
}
*/

usage()
{
fprintf(stderr,"Usage: pbind -b processor_id pid\n");
fprintf(stderr,"Usage: pbind -u pid\n");
fprintf(stderr,"Usage: pbind -q pid\n");
exit(1);
}
Emil Velez
Instructor Storage, Servers, HP-UX and Partner Courses
Hewlett Packard Enterprise Education Services
Ask me about training on StoreServ (3PAR) StoreOnce, StoreEasy, StoreAll, StoreVirtual, HP-UX, ServiceGuard and HPE Partner Ready Certification Training

internet: Linkedin: http://www.linkedin.com/in/emilvelez

HPE Master ASE Server Solutions Architect V3
HPE Master ASE Storage Solutions Architect V2
HP UNIX Certified (ASE HPUX 11iv3 Administration V1)
Certified HPE Instructor
HPE Product Certified - OneView [2016]
HP Sales Certified -Servers, Converged Systems and Services [2015]
HPE Product Certified - Converged Solutions [2017]