From: Remi Gacogne Date: Wed, 12 Jul 2017 22:05:50 +0000 (+0200) Subject: dnsdist: Add support for pinning backend threads to specific CPUs X-Git-Tag: rec-4.1.0-rc1~22^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a8ee8bf109a1b5f225ccd4a88b581a0913c0146;p=thirdparty%2Fpdns.git dnsdist: Add support for pinning backend threads to specific CPUs --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index cd22d401e2..bb706b8cb5 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -275,6 +275,7 @@ vector> setupLua(bool client, const std::string& confi } ComboAddress sourceAddr; unsigned int sourceItf = 0; + std::set cpus; if(auto addressStr = boost::get(&pvars)) { std::shared_ptr ret; try { @@ -404,8 +405,8 @@ vector> setupLua(bool client, const std::string& confi if(auto* pool = boost::get(&vars["pool"])) ret->pools.insert(*pool); else { - auto* pools = boost::get > >(&vars["pool"]); - for(auto& p : *pools) + auto pools = boost::get > >(vars["pool"]); + for(auto& p : pools) ret->pools.insert(p.second); } for(const auto& poolName: ret->pools) { @@ -480,14 +481,26 @@ vector> setupLua(bool client, const std::string& confi ret->maxCheckFailures=std::stoi(boost::get(vars["maxCheckFailures"])); } + if(vars.count("cpus")) { + for (const auto cpu : boost::get>>(vars["cpus"])) { + cpus.insert(std::stoi(cpu.second)); + } + } + if (ret->connected) { if(g_launchWork) { - g_launchWork->push_back([ret]() { + g_launchWork->push_back([ret,cpus]() { ret->tid = thread(responderThread, ret); + if (!cpus.empty()) { + mapThreadToCPUList(ret->tid.native_handle(), cpus); + } }); } else { ret->tid = thread(responderThread, ret); + if (!cpus.empty()) { + mapThreadToCPUList(ret->tid.native_handle(), cpus); + } } }