Skip to content

Commit

Permalink
fs/ceph_mds: set ceph_mds cpu affinity
Browse files Browse the repository at this point in the history
fs/ceph_mds: set ceph_mds cpu affinity according to mds_numa_node config option

Signed-off-by: qilianghong <qilianghong@huawei.com>
  • Loading branch information
lianghongq authored and rosinL committed Nov 18, 2019
1 parent 8819c3c commit 50b8c8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/ceph_mds.cc
Expand Up @@ -26,6 +26,7 @@

#include "common/config.h"
#include "common/strtol.h"
#include "common/numa.h"

#include "mon/MonMap.h"
#include "mds/MDSDaemon.h"
Expand Down Expand Up @@ -93,6 +94,25 @@ int main(int argc, const char **argv)
0, "mds_data");
ceph_heap_profiler_init();

int numa_node = g_conf().get_val<int64_t>("mds_numa_node");
size_t numa_cpu_set_size = 0;
cpu_set_t numa_cpu_set;
if (numa_node >= 0) {
int r = get_numa_node_cpu_set(numa_node, &numa_cpu_set_size, &numa_cpu_set);
if (r < 0) {
dout(1) << __func__ << " unable to determine mds numa node " << numa_node
<< " CPUs" << dendl;
numa_node = -1;
} else {
r = set_cpu_affinity_all_threads(numa_cpu_set_size, &numa_cpu_set);
if (r < 0) {
derr << __func__ << " failed to set numa affinity: " << cpp_strerror(r)
<< dendl;
}
}
} else {
dout(1) << __func__ << " not setting numa affinity" << dendl;
}
std::string val, action;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
Expand Down
5 changes: 5 additions & 0 deletions src/common/options.cc
Expand Up @@ -7413,6 +7413,11 @@ static std::vector<Option> get_immutable_object_cache_options() {

std::vector<Option> get_mds_options() {
return std::vector<Option>({
Option("mds_numa_node", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(-1)
.set_flag(Option::FLAG_STARTUP)
.set_description("set mds's cpu affinity to a numa node (-1 for none)"),

Option("mds_data", Option::TYPE_STR, Option::LEVEL_ADVANCED)
.set_default("/var/lib/ceph/mds/$cluster-$id")
.set_flag(Option::FLAG_NO_MON_UPDATE)
Expand Down

0 comments on commit 50b8c8f

Please sign in to comment.