diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/daemon.cc | 5 | ||||
-rw-r--r-- | src/libstore/remote-store.cc | 8 | ||||
-rw-r--r-- | src/libutil/affinity.cc | 70 | ||||
-rw-r--r-- | src/libutil/affinity.hh | 9 | ||||
-rw-r--r-- | src/libutil/thread-pool.cc | 3 | ||||
-rw-r--r-- | src/libutil/util.cc | 4 | ||||
-rw-r--r-- | src/libutil/util.hh | 2 | ||||
-rwxr-xr-x | src/nix-build/nix-build.cc | 1 | ||||
-rw-r--r-- | src/nix/develop.cc | 1 | ||||
-rw-r--r-- | src/nix/repl.cc | 1 | ||||
-rw-r--r-- | src/nix/run.cc | 1 |
11 files changed, 5 insertions, 100 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index bafab6fd5..59325da79 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -4,7 +4,6 @@ #include "store-api.hh" #include "path-with-outputs.hh" #include "finally.hh" -#include "affinity.hh" #include "archive.hh" #include "derivations.hh" #include "args.hh" @@ -960,8 +959,8 @@ void processConnection( }); if (GET_PROTOCOL_MINOR(clientVersion) >= 14 && readInt(from)) { - auto affinity = readInt(from); - setAffinityTo(affinity); + // Obsolete CPU affinity. + readInt(from); } readInt(from); // obsolete reserveSpace diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 7f7e973e9..57cc260b0 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -5,7 +5,6 @@ #include "remote-store.hh" #include "worker-protocol.hh" #include "archive.hh" -#include "affinity.hh" #include "globals.hh" #include "derivations.hh" #include "pool.hh" @@ -184,11 +183,8 @@ void RemoteStore::initConnection(Connection & conn) conn.to << PROTOCOL_VERSION; if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 14) { - int cpu = sameMachine() && settings.lockCPU ? lockToCurrentCPU() : -1; - if (cpu != -1) - conn.to << 1 << cpu; - else - conn.to << 0; + // Obsolete CPU affinity. + conn.to << 0; } if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 11) diff --git a/src/libutil/affinity.cc b/src/libutil/affinity.cc deleted file mode 100644 index ac2295e4a..000000000 --- a/src/libutil/affinity.cc +++ /dev/null @@ -1,70 +0,0 @@ -#include "types.hh" -#include "util.hh" -#include "affinity.hh" - -#if __linux__ -#include <sched.h> -#endif - -namespace nix { - - -#if __linux__ -static bool didSaveAffinity = false; -static cpu_set_t savedAffinity; - -std::ostream& operator<<(std::ostream &os, const cpu_set_t &cset) -{ - auto count = CPU_COUNT(&cset); - for (int i=0; i < count; ++i) - { - os << (CPU_ISSET(i,&cset) ? "1" : "0"); - } - - return os; -} -#endif - - -void setAffinityTo(int cpu) -{ -#if __linux__ - if (sched_getaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1) return; - didSaveAffinity = true; - debug(format("locking this thread to CPU %1%") % cpu); - cpu_set_t newAffinity; - CPU_ZERO(&newAffinity); - CPU_SET(cpu, &newAffinity); - if (sched_setaffinity(0, sizeof(cpu_set_t), &newAffinity) == -1) - printError("failed to lock thread to CPU %1%", cpu); -#endif -} - - -int lockToCurrentCPU() -{ -#if __linux__ - int cpu = sched_getcpu(); - if (cpu != -1) setAffinityTo(cpu); - return cpu; -#else - return -1; -#endif -} - - -void restoreAffinity() -{ -#if __linux__ - if (!didSaveAffinity) return; - if (sched_setaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1) - { - std::ostringstream oss; - oss << savedAffinity; - printError("failed to restore CPU affinity %1%", oss.str()); - } -#endif -} - - -} diff --git a/src/libutil/affinity.hh b/src/libutil/affinity.hh deleted file mode 100644 index c1bd28e13..000000000 --- a/src/libutil/affinity.hh +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -namespace nix { - -void setAffinityTo(int cpu); -int lockToCurrentCPU(); -void restoreAffinity(); - -} diff --git a/src/libutil/thread-pool.cc b/src/libutil/thread-pool.cc index 857ee91f8..dc4067f1b 100644 --- a/src/libutil/thread-pool.cc +++ b/src/libutil/thread-pool.cc @@ -1,13 +1,10 @@ #include "thread-pool.hh" -#include "affinity.hh" namespace nix { ThreadPool::ThreadPool(size_t _maxThreads) : maxThreads(_maxThreads) { - restoreAffinity(); // FIXME - if (!maxThreads) { maxThreads = std::thread::hardware_concurrency(); if (!maxThreads) maxThreads = 1; diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 43fea1b1e..e18648557 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1,5 +1,4 @@ #include "util.hh" -#include "affinity.hh" #include "sync.hh" #include "finally.hh" #include "serialise.hh" @@ -1004,7 +1003,6 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options) if (options.dieWithParent && prctl(PR_SET_PDEATHSIG, SIGKILL) == -1) throw SysError("setting death signal"); #endif - restoreAffinity(); fun(); } catch (std::exception & e) { try { @@ -1675,8 +1673,6 @@ void restoreProcessContext(bool restoreMounts) restoreMountNamespace(); } - restoreAffinity(); - #if __linux__ if (savedStackSize) { struct rlimit limit; diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 4cc043a84..d08f42826 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -300,7 +300,7 @@ void setStackSize(size_t stackSize); /* Restore the original inherited Unix process context (such as signal - masks, stack size, CPU affinity). */ + masks, stack size). */ void restoreProcessContext(bool restoreMounts = true); /* Save the current mount namespace. Ignored if called more than diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index e2325c91f..d3d6ce1ce 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -14,7 +14,6 @@ #include "local-fs-store.hh" #include "globals.hh" #include "derivations.hh" -#include "affinity.hh" #include "util.hh" #include "shared.hh" #include "path-with-outputs.hh" diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 5aad53919..a8ca1cac2 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -5,7 +5,6 @@ #include "store-api.hh" #include "path-with-outputs.hh" #include "derivations.hh" -#include "affinity.hh" #include "progress-bar.hh" #include "run.hh" diff --git a/src/nix/repl.cc b/src/nix/repl.cc index f453343f3..63ccbfda3 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -28,7 +28,6 @@ extern "C" { #include "common-eval-args.hh" #include "get-drvs.hh" #include "derivations.hh" -#include "affinity.hh" #include "globals.hh" #include "command.hh" #include "finally.hh" diff --git a/src/nix/run.cc b/src/nix/run.cc index b01fdebaa..bae64ed39 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -8,7 +8,6 @@ #include "finally.hh" #include "fs-accessor.hh" #include "progress-bar.hh" -#include "affinity.hh" #include "eval.hh" #if __linux__ |