TFE 支持 accept/worker 线程绑定 cpu

This commit is contained in:
luwenpeng
2020-07-28 16:43:37 +08:00
parent 4d7957e0cc
commit c82429c9d9
6 changed files with 87 additions and 4 deletions

View File

@@ -17,7 +17,7 @@
#include <acceptor_kni_v2.h>
#include <proxy.h>
#include <platform.h>
#
#include <sys/prctl.h>
#ifndef TFE_CONFIG_SCM_SOCKET_FILE
#define TFE_CONFIG_SCM_SOCKET_FILE "/var/run/.tfe_kmod_scm_socket"
@@ -143,8 +143,18 @@ void * acceptor_kni_v2_event_thread_entry(void * args)
{
struct acceptor_kni_v2 * __ctx = (struct acceptor_kni_v2 *) args;
assert(__ctx != NULL && __ctx->thread == pthread_self());
char thread_name[16];
snprintf(thread_name, sizeof(thread_name), "tfe:acceptor-v2");
prctl(PR_SET_NAME, (unsigned long long) thread_name, NULL, NULL, NULL);
TFE_LOG_INFO(__ctx->logger, "scm acceptor thread is running.");
char affinity[32] = {0};
if (__ctx->proxy->enable_cpu_affinity)
{
tfe_thread_set_affinity(__ctx->proxy->cpu_affinity_mask[0]);
snprintf(affinity, sizeof(affinity), "affinity cpu%d", __ctx->proxy->cpu_affinity_mask[0]);
}
TFE_LOG_INFO(__ctx->logger, "scm acceptor thread %s is running.", __ctx->proxy->enable_cpu_affinity ? affinity : "");
event_base_dispatch(__ctx->ev_base);
DIE("scm acceptor thread is exited, abort.");
}