2017-01-17 4 views
1

次のコマンドを検討してください。/sys/devices/system/cpu/cpu0/topology/thread_siblings_listの標準形式はありますか?

cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list 

Ubuntu 16.04を実行しているラップトップでこのコマンドを実行すると、次の出力が表示されます。

0,1 

しかし、Debian 8を実行しているサーバーで実行すると、次のような出力が表示されます。

0-1 

どこかに文書化され、この擬似ファイルの標準形式または標準形式の設定されていますか?

Documentationディレクトリのカーネルソースの下で検索し、説明が見つかりませんでした。

答えて

1

linux-toolsの内部プログラムと一部文書化の方法が、turbostatがあるようには思えない、フォーマットがあることを期待:区切り文字として任意の文字が続く

数、、...、最後の番号。

現在のバージョンはhereです。

/* 
* get_cpu_position_in_core(cpu) 
* return the position of the CPU among its HT siblings in the core 
* return -1 if the sibling is not in list 
*/ 
int get_cpu_position_in_core(int cpu) 
{ 
    char path[64]; 
    FILE *filep; 
    int this_cpu; 
    char character; 
    int i; 

    sprintf(path, 
     "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", 
     cpu); 
    filep = fopen(path, "r"); 
    if (filep == NULL) { 
     perror(path); 
     exit(1); 
    } 

    for (i = 0; i < topo.num_threads_per_core; i++) { 
     fscanf(filep, "%d", &this_cpu); 
     if (this_cpu == cpu) { 
      fclose(filep); 
      return i; 
     } 

     /* Account for no separator after last thread*/ 
     if (i != (topo.num_threads_per_core - 1)) 
      fscanf(filep, "%c", &character); 
    } 

    fclose(filep); 
    return -1; 
} 
関連する問題