Skip to content
Snippets Groups Projects
Commit 45bb22b1 authored by Moe Jette's avatar Moe Jette
Browse files

Determine sched_setaffinity() argument count at configure time. remove check of

libc version which is not always reliable for this.
parent 16aca119
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ EXTRA_DIST = \ ...@@ -9,6 +9,7 @@ EXTRA_DIST = \
slurm.m4 \ slurm.m4 \
type_socklen_t.m4 \ type_socklen_t.m4 \
x_ac__system_configuration.m4 \ x_ac__system_configuration.m4 \
x_ac_affinity.m4 \
x_ac_aix.m4 \ x_ac_aix.m4 \
x_ac_bluegene.m4 \ x_ac_bluegene.m4 \
x_ac_debug.m4 \ x_ac_debug.m4 \
......
##*****************************************************************************
# $Id$
##*****************************************************************************
# AUTHOR:
# Morris Jette <jette1@llnl.gov>
#
# SYNOPSIS:
# X_AC_AFFINITY
#
# DESCRIPTION:
# Test argument count of sched_getaffinity function.
#
# WARNINGS:
# This macro must be placed after AC_PROG_CC or equivalent.
##*****************************************************************************
AC_DEFUN([X_AC_AFFINITY], [
AC_TRY_COMPILE(
[#define _GNU_SOURCE
#include <sched.h>],
[cpu_set_t mask;
sched_getaffinity(0, sizeof(cpu_set_t), &mask);],
[AC_DEFINE(SCHED_GETAFFINITY_THREE_ARGS, 1,
[Define to 1 if sched_getaffinity takes three arguments.])])
AC_CHECK_FUNCS(sched_setaffinity, [have_sched_setaffinity=yes])
AM_CONDITIONAL(HAVE_SCHED_SETAFFINITY, test "x$have_sched_setaffinity" = "xyes")
])
...@@ -63,6 +63,10 @@ dnl Check if ptrace takes four or five arguments ...@@ -63,6 +63,10 @@ dnl Check if ptrace takes four or five arguments
dnl dnl
X_AC_PTRACE X_AC_PTRACE
dnl Check of sched_getaffinity exists and it's argument count
dnl
X_AC_AFFINITY
dnl Checks for types. dnl Checks for types.
dnl dnl
X_AC_SLURM_BIGENDIAN X_AC_SLURM_BIGENDIAN
...@@ -92,9 +96,6 @@ AC_CHECK_DECLS([hstrerror, strsignal, sys_siglist]) ...@@ -92,9 +96,6 @@ AC_CHECK_DECLS([hstrerror, strsignal, sys_siglist])
AC_CHECK_FUNCS(unsetenv, [have_unsetenv=yes]) AC_CHECK_FUNCS(unsetenv, [have_unsetenv=yes])
AM_CONDITIONAL(HAVE_UNSETENV, test "x$have_unsetenv" = "xyes") AM_CONDITIONAL(HAVE_UNSETENV, test "x$have_unsetenv" = "xyes")
AC_CHECK_FUNCS(sched_setaffinity, [have_sched_setaffinity=yes])
AM_CONDITIONAL(HAVE_SCHED_SETAFFINITY, test "x$have_sched_setaffinity" = "xyes")
ACX_PTHREAD([], AC_MSG_ERROR([Error: Cannot figure out how to use pthreads!])) ACX_PTHREAD([], AC_MSG_ERROR([Error: Cannot figure out how to use pthreads!]))
# Always define WITH_PTHREADS if we make it this far # Always define WITH_PTHREADS if we make it this far
......
...@@ -160,57 +160,16 @@ int get_cpuset(cpu_set_t *mask, slurmd_job_t *job) ...@@ -160,57 +160,16 @@ int get_cpuset(cpu_set_t *mask, slurmd_job_t *job)
return false; return false;
} }
/* user_older_affinity
*
* NOTE: some confusion in this.
* At first it seems:
* if glibc 2.3.2 then
* call sched_setaffinity(pid,mask)
* else
* call sched_setaffinity(pid,len,mask)
* but then some 2.4 kernels also have the
* 3 arg version - so its a mess.
*/
#if defined __GLIBC__
#include <gnu/libc-version.h> /* for gnu_get_libc_version */
#endif
bool use_3arg_affinity()
{
static bool has_3arg_affinity = true;
static bool already_checked = false;
if (already_checked) {
return has_3arg_affinity;
}
#if defined __GLIBC__
const char *glibc_vers = gnu_get_libc_version();
if (glibc_vers != NULL) {
int scnt = 0, major = 0, minor = 0, point = 0;
scnt = sscanf (glibc_vers, "%d.%d.%d", &major,
&minor, &point);
if (scnt == 3) {
if ((major <= 2) && (minor <= 3) && (point <= 2)) {
has_3arg_affinity = false;
}
}
debug3("glibc version: %d.%d.%d (%d)\n",
major, minor, point, has_3arg_affinity);
}
#endif
already_checked = true;
return has_3arg_affinity;
}
int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask) int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask)
{ {
int (*fptr_sched_setaffinity)() = sched_setaffinity; int rval;
int rval = 0;
if (use_3arg_affinity()) {
rval = (*fptr_sched_setaffinity)(pid, size, mask);
} else {
rval = (*fptr_sched_setaffinity)(pid, mask);
}
char mstr[1 + CPU_SETSIZE / 4]; char mstr[1 + CPU_SETSIZE / 4];
#ifdef HAVE_SCHED_SETAFFINITY
rval = sched_setaffinity(pid, size, mask);
#else
rval = sched_setaffinity(pid, mask);
#endif
if (rval) if (rval)
verbose("sched_setaffinity(%d,%d,0x%s) failed with status %d", verbose("sched_setaffinity(%d,%d,0x%s) failed with status %d",
pid, size, cpuset_to_str(mask, mstr), rval); pid, size, cpuset_to_str(mask, mstr), rval);
...@@ -219,16 +178,15 @@ int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask) ...@@ -219,16 +178,15 @@ int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask)
int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask) int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask)
{ {
int (*fptr_sched_getaffinity)() = sched_getaffinity; int rval;
int rval = 0;
CPU_ZERO(mask);
if (use_3arg_affinity()) {
rval = (*fptr_sched_getaffinity)(pid, size, mask);
} else {
rval = (*fptr_sched_getaffinity)(pid, mask);
}
char mstr[1 + CPU_SETSIZE / 4]; char mstr[1 + CPU_SETSIZE / 4];
CPU_ZERO(mask);
#ifdef SCHED_GETAFFINITY_THREE_ARGS
rval = sched_getaffinity(pid, size, mask);
#else
rval = sched_getaffinity(pid, mask);
#endif
if (rval) if (rval)
verbose("sched_getaffinity(%d,%d,0x%s) failed with status %d", verbose("sched_getaffinity(%d,%d,0x%s) failed with status %d",
pid, size, cpuset_to_str(mask, mstr), rval); pid, size, cpuset_to_str(mask, mstr), rval);
......
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
/*** from affinity.c ***/ /*** from affinity.c ***/
void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval); void slurm_chkaffinity(cpu_set_t *mask, slurmd_job_t *job, int statval);
int get_cpuset(cpu_set_t *mask, slurmd_job_t *job); int get_cpuset(cpu_set_t *mask, slurmd_job_t *job);
bool use_3arg_affinity();
int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask); int slurm_setaffinity(pid_t pid, size_t size, const cpu_set_t *mask);
int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask); int slurm_getaffinity(pid_t pid, size_t size, cpu_set_t *mask);
......
...@@ -74,7 +74,6 @@ const uint32_t plugin_version = 100; ...@@ -74,7 +74,6 @@ const uint32_t plugin_version = 100;
int init ( void ) int init ( void )
{ {
verbose("%s loaded", plugin_name); verbose("%s loaded", plugin_name);
use_3arg_affinity(); /* initialize check for older affinity */
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
......
...@@ -70,8 +70,6 @@ exec $bin_chmod 700 $file_prog ...@@ -70,8 +70,6 @@ exec $bin_chmod 700 $file_prog
# Create an allocation # Create an allocation
# #
spawn $srun --allocate -N1 --verbose -t2 spawn $srun --allocate -N1 --verbose -t2
expect -re "jobid ($number).*"
set job_id $expect_out(1,string)
# #
# Run a job step to get allocated processor count and affinity # Run a job step to get allocated processor count and affinity
...@@ -94,7 +92,6 @@ expect { ...@@ -94,7 +92,6 @@ expect {
timeout { timeout {
send_user "\nFAILURE: srun (from --allocate) not responding\n" send_user "\nFAILURE: srun (from --allocate) not responding\n"
set exit_code 1 set exit_code 1
exp_continue
} }
-re $prompt -re $prompt
} }
...@@ -117,7 +114,6 @@ expect { ...@@ -117,7 +114,6 @@ expect {
timeout { timeout {
send_user "\nFAILURE: srun (from --allocate) not responding\n" send_user "\nFAILURE: srun (from --allocate) not responding\n"
set exit_code 1 set exit_code 1
exp_continue
} }
-re $prompt -re $prompt
} }
...@@ -149,7 +145,6 @@ expect { ...@@ -149,7 +145,6 @@ expect {
timeout { timeout {
send_user "\nFAILURE: srun (from --allocate) not responding\n" send_user "\nFAILURE: srun (from --allocate) not responding\n"
set exit_code 1 set exit_code 1
exp_continue
} }
-re $prompt -re $prompt
} }
...@@ -180,7 +175,6 @@ expect { ...@@ -180,7 +175,6 @@ expect {
timeout { timeout {
send_user "\nFAILURE: srun (from --allocate) not responding\n" send_user "\nFAILURE: srun (from --allocate) not responding\n"
set exit_code 1 set exit_code 1
exp_continue
} }
-re $prompt -re $prompt
} }
...@@ -202,7 +196,6 @@ expect { ...@@ -202,7 +196,6 @@ expect {
send_user "\nFAILURE: srun (from --allocate) not responding\n" send_user "\nFAILURE: srun (from --allocate) not responding\n"
kill_srun kill_srun
set exit_code 1 set exit_code 1
exp_continue
} }
eof { eof {
wait wait
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment