From 50b8c8f0316440aa90a04f1830380658d5492777 Mon Sep 17 00:00:00 2001 From: qilianghong Date: Mon, 18 Nov 2019 15:40:10 +0800 Subject: [PATCH] fs/ceph_mds: set ceph_mds cpu affinity fs/ceph_mds: set ceph_mds cpu affinity according to mds_numa_node config option Signed-off-by: qilianghong --- src/ceph_mds.cc | 20 ++++++++++++++++++++ src/common/options.cc | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc index 38e673755a9..41adf75f131 100644 --- a/src/ceph_mds.cc +++ b/src/ceph_mds.cc @@ -26,6 +26,7 @@ #include "common/config.h" #include "common/strtol.h" +#include "common/numa.h" #include "mon/MonMap.h" #include "mds/MDSDaemon.h" @@ -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("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::iterator i = args.begin(); i != args.end(); ) { if (ceph_argparse_double_dash(args, i)) { diff --git a/src/common/options.cc b/src/common/options.cc index f20568501cf..19deaca500f 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -7413,6 +7413,11 @@ static std::vector