@@ -297,7 +297,7 @@ void tracecmd_disable_tracing(void);
void tracecmd_enable_tracing(void);
/* for clients */
-int tracecmd_msg_send_init_data(int fd);
+int tracecmd_msg_send_init_data(int fd, int total_cpus);
int tracecmd_msg_metadata_send(int fd, const char *buf, int size);
int tracecmd_msg_finish_sending_metadata(int fd);
void tracecmd_msg_send_close_msg(void);
@@ -64,7 +64,6 @@ typedef __be32 be32;
/* for both client and server */
bool use_tcp;
-int cpu_count;
/* for client */
static int psfd;
@@ -162,7 +161,7 @@ enum msg_opt_command {
MSGOPT_USETCP = 1,
};
-static int make_tinit(struct tracecmd_msg *msg)
+static int make_tinit(struct tracecmd_msg *msg, int total_cpus)
{
struct tracecmd_msg_opt *opt;
int opt_num = 0;
@@ -179,7 +178,7 @@ static int make_tinit(struct tracecmd_msg *msg)
size += sizeof(*opt);
}
- msg->tinit.cpus = htonl(cpu_count);
+ msg->tinit.cpus = htonl(total_cpus);
msg->tinit.page_size = htonl(page_size);
msg->tinit.opt_num = htonl(opt_num);
@@ -368,7 +367,7 @@ static int tracecmd_msg_wait_for_msg(int fd, struct tracecmd_msg *msg)
return 0;
}
-int tracecmd_msg_send_init_data(int fd)
+int tracecmd_msg_send_init_data(int fd, int total_cpus)
{
struct tracecmd_msg send_msg;
struct tracecmd_msg recv_msg;
@@ -376,7 +375,7 @@ int tracecmd_msg_send_init_data(int fd)
int ret;
tracecmd_msg_init(MSG_TINIT, &send_msg);
- ret = make_tinit(&send_msg);
+ ret = make_tinit(&send_msg, total_cpus);
if (ret < 0)
return ret;
@@ -12,7 +12,6 @@
/* for both client and server */
extern bool use_tcp;
-extern int cpu_count;
/* for client */
extern unsigned int page_size;
@@ -79,6 +79,7 @@ static const char *output_file = "trace.dat";
static int latency;
static int sleep_time = 1000;
+static int cpu_count;
static int recorder_threads;
static struct pid_record_data *pids;
static int buffers;
@@ -2755,7 +2756,7 @@ static void communicate_with_listener_v1(int fd)
static void communicate_with_listener_v2(int fd)
{
- if (tracecmd_msg_send_init_data(fd) < 0)
+ if (tracecmd_msg_send_init_data(fd, cpu_count) < 0)
die("Cannot communicate with server");
}