tech:gerer_le_cpu_sous_gnu_linux
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:gerer_le_cpu_sous_gnu_linux [2025/11/11 16:18] – Jean-Baptiste | tech:gerer_le_cpu_sous_gnu_linux [2026/06/29 16:12] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Gérer les CPUs sous GNU/Linux | ||
| + | |||
| + | Voir | ||
| + | * [[temperature_materiel_cpu_carte_mere_debian_lm-sensors|Température CPU]] | ||
| + | * < | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | ## Notes | ||
| + | |||
| + | Outils : | ||
| + | * lscpu | ||
| + | * chcpu | ||
| + | * cpufreq-info | ||
| + | * CoreCtrl | ||
| + | * turbostat | ||
| + | * cpupower | ||
| + | * powertop | ||
| + | * rdmsr / wrmsr (msr-tools) | ||
| + | * kvm-ok / check-bios-nx (cpu-checker) | ||
| + | |||
| + | Notions : | ||
| + | * Systèmes multi-processeurs (NUMA SMP) | ||
| + | * Systèmes multi-cœurs (SMP) | ||
| + | * Systèmes multi-threads (SMT) | ||
| + | |||
| + | |||
| + | Params Kernel : | ||
| + | * nr_cpus | ||
| + | |||
| + | |||
| + | |||
| + | ## Infos nombre de cores threads CPU | ||
| + | |||
| + | Nombre de threads | ||
| + | ~~~bash | ||
| + | grep ^processor / | ||
| + | ~~~ | ||
| + | |||
| + | Nous avons une valeurs par thread. | ||
| + | C'est donc la derniere valeur +1 qui donne le nombre de threads (si un seul CPU physique) | ||
| + | |||
| + | Nombre de cores | ||
| + | ~~~bash | ||
| + | grep '^cpu cores' / | ||
| + | ~~~ | ||
| + | |||
| + | Toutes les valeurs sont identiques si un seul CPU physique | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## CPUFrequtils | ||
| + | |||
| + | Voir aussi : [intel_p-state](https:// | ||
| + | |||
| + | Gérer la fréquence cpu | ||
| + | |||
| + | ~~~bash | ||
| + | service cpufrequtils stop | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | #!/bin/sh -e | ||
| + | # | ||
| + | # rc.local | ||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | #echo " | ||
| + | # echo " | ||
| + | exit 0 | ||
| + | ~~~ | ||
| + | |||
| + | Fichier à exécuter en root pour changer le gouverneur. Choix possible selon la configuration du noyau : conservative, | ||
| + | |||
| + | Avec cpufrequtils : (en root) | ||
| + | |||
| + | ~~~bash | ||
| + | cp / | ||
| + | |||
| + | cpufreq-set -c 0 -d 2100000 -u 3300000 | ||
| + | |||
| + | service cpufrequtils reload | ||
| + | ~~~ | ||
| + | -c : numéro processeur | ||
| + | -d : freq min | ||
| + | -u : freq max | ||
| + | -f : freq exact voulu | ||
| + | |||
| + | |||
| + | ## Notes cpufreq | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | grep MHz / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | apt-get install linux-cpupower | ||
| + | cpupower | ||
| + | ~~~ | ||
| + | |||
| + | ~~~ | ||
| + | $ cpupower frequency-info -g | ||
| + | analyzing CPU 0: | ||
| + | available cpufreq governors: Not Available | ||
| + | |||
| + | $ cpupower frequency-info | ||
| + | analyzing CPU 0: | ||
| + | no or unknown cpufreq driver is active on this CPU | ||
| + | CPUs which run at the same hardware frequency: Not Available | ||
| + | CPUs which need to have their frequency coordinated by software: Not Available | ||
| + | maximum transition latency: | ||
| + | hardware limits: Not Available | ||
| + | available cpufreq governors: Not Available | ||
| + | Unable to determine current Policy | ||
| + | current CPU frequency: Unable to call hardware | ||
| + | current CPU frequency: | ||
| + | boost state support: | ||
| + | Supported: yes | ||
| + | Active: yes | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | If you have Turbo Boost enabled in the UEFI/BIOS, you can turn boost on (1) or off (0) by running | ||
| + | ~~~bash | ||
| + | echo 1 > / | ||
| + | ~~~ | ||
| + | |||
| + | Limite d' | ||
| + | ~~~ | ||
| + | # cat / | ||
| + | 100 | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | cat / | ||
| + | ~~~ | ||
| + | |||
| + | Exemble de " | ||
| + | * performance | ||
| + | * powersave | ||
| + | * userspace | ||
| + | * ondemand | ||
| + | * conservative | ||
| + | |||
| + | ~~~bash | ||
| + | cpufreq-set -r -u 2.24Ghz | ||
| + | # | ||
| + | cpufreq-set -r -g performance | ||
| + | |||
| + | cat / | ||
| + | echo " | ||
| + | |||
| + | #echo " | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~bash | ||
| + | CMDLINE_LINUX_DEFAULT=" | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | update-grub | ||
| + | ~~~ | ||
| + | |||
| + | Pour remplacer `intel_pstate` par `acpi-cpufreq` | ||
| + | ~~~bash | ||
| + | cat / | ||
| + | ~~~ | ||
| + | |||
| + | La liste des drivers ici : | ||
| + | ~~~bash | ||
| + | ls -1 / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## BIOS frequency limitation | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | ~~~bash | ||
| + | cat / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | For trying this temporarily change the value in / | ||
| + | |||
| + | ~~~bash | ||
| + | echo 1 > / | ||
| + | ~~~ | ||
| + | |||
| + | For setting it permanent refer to Kernel modules or just read on. Add processor.ignore_ppc=1 to your kernel boot line or create | ||
| + | |||
| + | `/ | ||
| + | ~~~bash | ||
| + | |||
| + | # If the frequency of your machine gets wrongly limited by BIOS, this should help | ||
| + | options processor ignore_ppc=1 | ||
| + | ~~~ | ||
| + | |||
| + | ---- | ||
| + | Avec cpulimit | ||
| + | |||
| + | ~~~bash | ||
| + | sudo apt-get install cpulimit | ||
| + | ~~~ | ||
| + | |||
| + | http:// | ||
| + | |||
| + | |||
| + | ## Perf | ||
| + | |||
| + | |||
| + | perf | ||
| + | |||
| + | ~~~bash | ||
| + | apt-get install linux-base linux-tools | ||
| + | ~~~ | ||
| + | |||
| + | https:// | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | # Disable SMP | ||
| + | echo off > / | ||
| + | |||
| + | # Disable THP | ||
| + | echo " | ||
| + | |||
| + | # Disable turbo boost | ||
| + | echo 1 > / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ### commande perf | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | ## Nombre de core / CPU | ||
| + | |||
| + | / | ||
| + | |||
| + | getconf _NPROCESSORS_ONLN | ||
| + | |||
| + | ## Notes | ||
| + | |||
| + | service cpufrequtils stop | ||
| + | |||
| + | echo " | ||
| + | |||
| + | noatime | ||
| + | |||
| + | Swap config | ||
| + | |||
| + | Blacklist module | ||
| + | |||
| + | ## irqbalance | ||
| + | / | ||
| + | cat / | ||
| + | |||
| + | cpupower | ||
| + | |||
| + | ## Hotplug | ||
| + | |||
| + | http:// | ||
| + | |||
| + | * switch to the monitor | ||
| + | * type `cpu_set <n+1> online` | ||
| + | * A new cpu should appear on / | ||
| + | * bring it online by writting 1 to the " | ||
| + | * Try adding as many cpus as possible, and make sure we at least do not crash. | ||
| + | |||
| + | ## Monitoring | ||
| + | |||
| + | pcp | ||
| + | http:// | ||
| + | https:// | ||
| + | |||
| + | ## Kernel | ||
| + | |||
| + | Real-time kernel ? | ||
| + | |||
| + | http:// | ||
| + | |||
| + | https:// | ||
| + | |||
| + | https:// | ||
| + | |||
| + | https:// | ||
| + | |||
| + | http:// | ||
| + | |||
| + | http:// | ||
| + | |||
| + | https:// | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | ~~~ | ||
| + | root# dmidecode | grep HTT | ||
| + | HTT (Hyper-Threading Technology) | ||
| + | HTT (Hyper-Threading Technology) | ||
| + | |||
| + | root# egrep ' | ||
| + | siblings : 2 | ||
| + | cpu cores : 1 | ||
| + | |||
| + | root# grep ' | ||
| + | flags : fpu de tsc msr pae mce cx8 apic sep mca cmov pat clflush acpi mmx | ||
| + | fxsr sse sse2 ss ht syscall nx lm constant_tsc rep_good nopl nonstop_tsc pni | ||
| + | pclmulqdq est ssse3 cx16 sse4_1 sse4_2 popcnt aes f16c rdrand hypervisor lahf_lm ida | ||
| + | arat epb pln pts dts fsgsbase erms | ||
| + | |||
| + | root# dmidecode | grep Count # tests that HTT is available *and* enabled | ||
| + | Core Count: 1 | ||
| + | Thread Count: 2 | ||
| + | Core Count: 1 | ||
| + | Thread Count: 2 | ||
| + | ~~~ | ||
| + | Source : https:// | ||
| + | |||
