Skip to content

Commit 90d211b

Browse files
committed
introduce parameter to set affinity CPU list
1 parent 76a51bb commit 90d211b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ipfixprobe.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ int run(int argc, char *argv[])
698698
conf.pkt_bufsize = parser.m_pkt_bufsize;
699699
conf.max_pkts = parser.m_max_pkts;
700700

701+
set_thread_details(pthread_self(), "", parser.m_cpu_mask);
701702

702703
try {
703704
if (process_plugin_args(conf, parser)) {

ipfixprobe.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class IpfixprobeOptParser : public OptionsParser {
9090
bool m_help;
9191
std::string m_help_str;
9292
bool m_version;
93+
std::vector<int> m_cpu_mask;
9394

9495
IpfixprobeOptParser() : OptionsParser("ipfixprobe", "flow exporter supporting various custom IPFIX elements"),
9596
m_pid(""), m_appfs_mount_point(""), m_daemon(false),
@@ -170,6 +171,18 @@ class IpfixprobeOptParser : public OptionsParser {
170171
m_version = true;
171172
return true;
172173
}, OptionFlags::NoArgument);
174+
register_option("-C", "--cpus", "CPU_LIST", "Set global CPU mask for main thread and subthreads", [this](const char *arg) {
175+
try {
176+
std::stringstream ss(arg);
177+
std::string tmp;
178+
while (std::getline(ss, tmp, ',')) {
179+
m_cpu_mask.emplace_back(str2num<uint16_t>(tmp));
180+
}
181+
return true;
182+
} catch (std::invalid_argument &e) {
183+
return false;
184+
}
185+
});
173186
}
174187
};
175188

0 commit comments

Comments
 (0)