新石器Wiki

近年はシリコン(石)から進化した便利なもので溢れる時代。そんな気になった事や試した事など記す。

ユーザ用ツール

サイト用ツール


programing:linux-programing:linux-cpu-core-shield


差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
programing:linux-programing:linux-cpu-core-shield [2022/10/21 15:52] – [CPUに負荷をかける] yokoprograming:linux-programing:linux-cpu-core-shield [2026/07/28 13:16] (現在) – 外部編集 127.0.0.1
行 1: 行 1:
-【Ubuntu/Linux】CPUコアのシールド分離 +====== 【Ubuntu/Linux】CPUコアのシールド分離 ======
-==============================+
 リアルタイム性が要求されるネットワーク通信を含むプログラムなど、さまざまなイベントに応答する際にレイテンシーを最小限に抑える必要がある。 リアルタイム性が要求されるネットワーク通信を含むプログラムなど、さまざまなイベントに応答する際にレイテンシーを最小限に抑える必要がある。
 これを行う為に、割り込み (IRQ) とさまざまな CPU 上のユーザープロセスを相互に分離する手法について備忘録を残す。 これを行う為に、割り込み (IRQ) とさまざまな CPU 上のユーザープロセスを相互に分離する手法について備忘録を残す。
行 9: 行 8:
  
  
-プロセスのCPUコア分離 +===== プロセスのCPUコア分離 =====
------------------+
 リアルタイム性が必要なユーザプログラム(プロセス)を実行するCPUコアを分離する。 リアルタイム性が必要なユーザプログラム(プロセス)を実行するCPUコアを分離する。
 ### コア除外の設定 ### コア除外の設定
行 54: 行 52:
 </code> </code>
  
-割り込みのCPUコア固定 +===== 割り込みのCPUコア固定 =====
------------------+
 上記でコア分離したプロセスが使用するNICカードの割り込みを、分離したコア側に割り当てる。 上記でコア分離したプロセスが使用するNICカードの割り込みを、分離したコア側に割り当てる。
  
行 73: 行 70:
 <code bash> <code bash>
 $ cat /proc/interrupts $ cat /proc/interrupts
 +            CPU0       CPU1       CPU2       CPU3
 +   0:         17          0          0          0  IR-IO-APIC    2-edge      timer
 +   6:          0          0          0          1  IR-IO-APIC    6-edge      ttyS2
 +   8:          0          0          1          0  IR-IO-APIC    8-edge      rtc0
 +   9:          0          5          0          0  IR-IO-APIC    9-fasteoi   acpi
 + ...
 </code> </code>
  
行 145: 行 148:
  
  
-その他 +===== その他 ===== 
------+ 
 +### CPUに負荷をかける 
 +stressコマンドで、CPUのコア#2に演算負荷をかける。 
 + 
 +<code bash> 
 +$ taskset -c 2 stress -c 1 
 +</code>
  
 ### CPU負荷状況の確認 ### CPU負荷状況の確認
行 167: 行 176:
  10    83     0:  4    96     0:100         0:  0   0 100     0  10    83     0:  4    96     0:100         0:  0   0 100     0
 </code> </code>
 +### CPU Affinityの一覧表示
 +全プロセスのCPU Affinityを一覧表示するPerlスクリプト。
  
-### CPUに負荷をかける +<code perl cpu_pslist.pl> 
-stressコマンドで、CPUコア#2に演算負荷かける。+#!/usr/bin/perl 
 +# 
 +# CPU affinity一覧表示する。 
 +#
  
-<code bash+use strict; 
-$ taskset -stress -c 1+use warnings; 
 + 
 +my @result; 
 +my $mode = 0; 
 + 
 +if (@ARGV >= 1) { 
 +    if ($ARGV[0] eq "tree") { 
 + $mode = 1; 
 +    } 
 +
 + 
 +if ($mode == 0) { 
 +    @result = `ps aux`; 
 +
 +else { 
 +    @result = `ps auxf`; 
 +
 + 
 +foreach my $line(@result) 
 +
 +    my @a = split(/\s+/, $line); # 複数の空白や改行でで分割 
 + 
 +    if ($a[1] eq "PID") { 
 + print "AFFIN " . $line; 
 +    } 
 +    else { 
 + my $affi = `taskset -pc $a[1] 2>&1`; # エラー出力は標準へ 
 + if ($? == 0) { # コマンド実行のリターンコード 
 +     my @b = split(/\s+/, $affi); # 複数の空白や改行で分割 
 +     my $str = sprintf("%-6s", $b[$#b]); # CPU affinity 
 +     print $str . $line; 
 +
 +    } 
 +}
 </code> </code>
  
-参考 
----- 
  
-1. [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux_for_real_time/8/html/optimizing_rhel_8_for_real_time_for_low_latency_operation/assembly_binding-interrupts-and-processes_optimizing-rhel8-for-real-time-for-low-latency-operation#doc-wrapper|第12章 割り込みとユーザープロセスを分離してシステムレイテンシーを最小限に抑える]] +===== 参考 ===== 
-2. [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/interrupt_and_process_binding|2.4. 割り込みおよびプロセスバインディング]] + 
-3. [[https://docs.oracle.com/cd/E26853_01/coh.371/b71688/tune_perftune.htm|6 パフォーマンス・チューニング]] +  - [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux_for_real_time/8/html/optimizing_rhel_8_for_real_time_for_low_latency_operation/assembly_binding-interrupts-and-processes_optimizing-rhel8-for-real-time-for-low-latency-operation#doc-wrapper|第12章 割り込みとユーザープロセスを分離してシステムレイテンシーを最小限に抑える]] 
-4. [[https://www.slideshare.net/syuu1228/interrupt-affinity|Interrupt Affinityについて]] +  [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/interrupt_and_process_binding|2.4. 割り込みおよびプロセスバインディング]] 
-5. [[https://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-ja-4/s1-proc-directories.html|5.3. /proc/配下のディレクトリ]] +  [[https://docs.oracle.com/cd/E26853_01/coh.371/b71688/tune_perftune.htm|6 パフォーマンス・チューニング]] 
-6. [[https://qiita.com/knakahara/items/825d2f052b07c0a2599e|irqbalance を NetBSD に移植してみる]] +  [[https://www.slideshare.net/syuu1228/interrupt-affinity|Interrupt Affinityについて]] 
-7. [[https://rheb.hatenablog.com/entry/nfv_tuning|レッドハットが考えるNFV環境向けのチューニング]] +  [[https://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-ja-4/s1-proc-directories.html|5.3. /proc/配下のディレクトリ]] 
-8. [[https://www.web-dev-qa-db-ja.com/ja/linux/isolcpusがアクティブ化されているかどうかを検出する方法/962607069/|isolcpusがアクティブ化されているかどうかを検出する方法]] +  [[https://qiita.com/knakahara/items/825d2f052b07c0a2599e|irqbalance を NetBSD に移植してみる]] 
-9. [[https://qiita.com/nakat-t/items/4542e84c4b72b78740e8|プロセス・スレッドを特定のCPUコアでのみ動作させる方法]] +  [[https://rheb.hatenablog.com/entry/nfv_tuning|レッドハットが考えるNFV環境向けのチューニング]] 
-10. [[https://www.rcannings.com/systemd-core-isolation/|SYSTEMD CORE ISOLATION]] +  [[https://www.web-dev-qa-db-ja.com/ja/linux/isolcpusがアクティブ化されているかどうかを検出する方法/962607069/|isolcpusがアクティブ化されているかどうかを検出する方法]] 
-11. [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/6/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-tool_reference-irqbalance|3.4. irqbalance]] +  [[https://qiita.com/nakat-t/items/4542e84c4b72b78740e8|プロセス・スレッドを特定のCPUコアでのみ動作させる方法]] 
-12. [[https://qiita.com/gyaneman/items/f77c2633a5ac92f05302|プロセス・スレッドにCPUアフィニティを設定する方法]] +  [[https://www.rcannings.com/systemd-core-isolation/|SYSTEMD CORE ISOLATION]] 
-13. [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/assembly_configuring-cpu-affinity-and-numa-policies-using-systemd_managing-monitoring-and-updating-the-kernel|第28章 systemd を使用した CPU のアフィニティーおよび NUMA ポリシーの設定]] +  [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/6/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-tool_reference-irqbalance|3.4. irqbalance]] 
-14. [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-tuning_scheduling_policy-isolating_cpus|6.3.6.2. CPU の分離]] +  [[https://qiita.com/gyaneman/items/f77c2633a5ac92f05302|プロセス・スレッドにCPUアフィニティを設定する方法]] 
-15. [[https://blog.amedama.jp/entry/stress-command|stress コマンドを使ってマシンに負荷をかける]] +  [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/assembly_configuring-cpu-affinity-and-numa-policies-using-systemd_managing-monitoring-and-updating-the-kernel|第28章 systemd を使用した CPU のアフィニティーおよび NUMA ポリシーの設定]] 
-16. {{https://www.concurrent-rt.co.jp/external/TechSup/PDF/RedHawkLinux_UsersGuide8.2_Jpn.pdf}}+  [[https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-tuning_scheduling_policy-isolating_cpus|6.3.6.2. CPU の分離]] 
 +  [[https://blog.amedama.jp/entry/stress-command|stress コマンドを使ってマシンに負荷をかける]] 
 +  {{https://www.concurrent-rt.co.jp/external/TechSup/PDF/RedHawkLinux_UsersGuide8.2_Jpn.pdf}}
  
  
  
programing/linux-programing/linux-cpu-core-shield.1666335137.txt.gz · 最終更新: by yoko