nvme-cli (c で記述され、Linux で実行可能) のテスト ツールに取り組んでいます。
nvme コマンド「r」をスレッド数「t」で何回も繰り返すことに興味があります。
以下のコードは、スレッド化とともにコマンドを繰り返しますが、ここでの問題は、並列実行時間がシリアル実行に比べて非常に長いことです。
私の観察によると、その理由は inturn calls からのシステムコールioctl()
の
呼び出しです。err = nvme_identify(fd, 0, 1, data);
nvme_identify()
ioctl()
ioctl()
nvme をブロックしているかどうかを知ることができますか?
また、スレッド化によって実行時間を短縮する方法 (解決策) はありますか?
int repeat_cmd(int fd, void *data, int nsid,int cmd, int rc, int flags,
struct repeatfields *rf, int threadcount)
{
pthread_t tid[threadcount];
int err, i=0,j=0;
struct my_struct1 my_struct[threadcount];
switch(cmd){
case 1 :
for (j=0; j <threadcount; j++)
{
my_struct[j].fd = fd;
my_struct[j].data = data;
my_struct[j].flags = flags;
my_struct[j].rf = *rf;
my_struct[j].rcount = rc/threadcount;
pthread_create(&tid[j], NULL, ThreadFun_id_ctrl, (void*)&my_struct[i]);
}
for (j=0; j <threadcount; j++)
pthread_join(tid[j], NULL);
break;
}
スレッド機能は次のとおりです。
void *ThreadFun_id_ctrl(void *val)
{
int err,j;
struct my_struct1 *my_struct = (struct my_struct1 *)val;
int fd = my_struct->fd;
void *data = my_struct->data;
struct repeatfields rf = my_struct->rf;
int flags = my_struct->flags;
int rcount = my_struct->rcount;
printf("Printing count = %d\n",rcount);
for (j=0; j <rcount; j++)
{
err = nvme_identify(fd, 0, 1, data);
if (!err) {
if (rf.fmt == BINARY)
d_raw((unsigned char *)&rf.ctrl, sizeof(rf.ctrl));
else if (rf.fmt == JSON)
json_nvme_id_ctrl(data, flags, 0);
else {
printf("NVME Identify Controller:\n");
__show_nvme_id_ctrl(data, flags, 0);
}
}
else if (err > 0){
fprintf(stderr, "NVMe Status:%s(%x)\n",
nvme_status_to_string(err), err);
}
else
perror("identify controller");
printf("Printing from Thread id = %d\n",syscall(SYS_gettid));
}
return NULL;