assegnare cpu x di y e ram x di y ad un processo : systemd o container

Il bestio in questione ha deciso di andare a donnine allegre proprio quando decido di fare un backup, quindi devo rifare tutto da capo.

Prima avevo risolto usando i container, ma non potendo accedere al backup, vorrei utilizzare systemd.

Ricordo che quando lo stavo configurando avevo trovato un link che suggeriva questa possibilità
(e giustamente pure in link non si trova).

Una nuova ricerca mi rimanda al sequnte link del https://access.redhat.com/solutions/2142471 ma non posso accedervi
dovrebbe essere possibile usare i cgroup ma tutti i link che trovo non mi aiutato a rispondere alla semplice domanda:

come posso dire al sistema che le risorse da assegnare al processo boinc sono 1 cpu e 1GB di ram

grazie
R.

Beh, se hai gia’ un docker impacchettato e pronto, la soluzione viene facilissima usando la sua limitazione di risorse: https://docs.docker.com/config/containers/resource_constraints/
(che sotto sotto sono dei cgroups ed altri magheggi)

Questo è quello che viene indicato nella pagina del supporto:

Resolution
The most straightforward way to do this is to edit the service definition file as follows.

Assuming you want to tie the service to CPU #24, you would add the CPUAffinity line to the [Service] definition. In the example below, we’ve also used isolcpus to isolate most of the CPUs from the process scheduler, so we can assign them to specific services. See What is the use of kernel parameter “isolcpus” ? for more information on isolcpus.

Raw
# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root crashkernel=auto rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet isolcpus=1-3,5-31

#  grep -A2 Service /usr/lib/systemd/system/httpd.service
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd

# sed '/^\[Service\]$/a CPUAffinity=24' /usr/lib/systemd/system/httpd.service > /etc/systemd/system/test.service

# grep -A2 Service /etc/systemd/system/test.service 
[Service]
CPUAffinity=24
Type=notify

# systemctl start test.service

# systemctl status test.service
● test.service - The Apache HTTP Server
   Loaded: loaded (/etc/systemd/system/test.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2016-01-27 18:55:19 EST; 1s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 2910 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/test.service
           ├─2910 /usr/sbin/httpd -DFOREGROUND
           ├─2911 /usr/sbin/httpd -DFOREGROUND
           ├─2912 /usr/sbin/httpd -DFOREGROUND
           ├─2913 /usr/sbin/httpd -DFOREGROUND
           ├─2914 /usr/sbin/httpd -DFOREGROUND
           └─2915 /usr/sbin/httpd -DFOREGROUND

Jan 27 18:55:17 amnesiac systemd[1]: Starting The Apache HTTP Server...
Jan 27 18:55:19 amnesiac systemd[1]: Started The Apache HTTP Server.

# grep -i cpu /proc/291?/status
/proc/2910/status:Cpus_allowed: 01000000
/proc/2910/status:Cpus_allowed_list:    24
/proc/2911/status:Cpus_allowed: 01000000
/proc/2911/status:Cpus_allowed_list:    24
/proc/2912/status:Cpus_allowed: 01000000
/proc/2912/status:Cpus_allowed_list:    24
/proc/2913/status:Cpus_allowed: 01000000
/proc/2913/status:Cpus_allowed_list:    24
/proc/2914/status:Cpus_allowed: 01000000
/proc/2914/status:Cpus_allowed_list:    24
/proc/2915/status:Cpus_allowed: 01000000
/proc/2915/status:Cpus_allowed_list:    24

Note that CPUAffinity takes a space-separated list of CPU indices. This option may be specified more than once in which case the specified CPU affinity masks are merged. If the empty string is assigned, the mask is reset, all assignments prior to this will have no effect.

Per @bebo_sudo

pensavo che fosse intuibile che l’andare a donnine allegre comprendesse anche l’hardware (è morto il disco) :frowning:
comunue mi sa che dovrò usare una situazione mista

  • container per Folding@Home (almeno finchè usano python 2.7)
    server fedora + container CentOS 6.7 o è meglio CentOS + CentOS?

  • systemd per Nextcloud, Boinc

per @palir1927

0: Grazie
1: io ho un Pentium N3700 (4 core) e per confinare il processo sul numero 3
CPUAffinity=3
corretto?

R.

Pensavo che parlando di docker containers, tu li avessi pushati sul docker hub, da dove si potrebbero scaricare con un docker pull.

Questo e’ totalmente indifferente; un container vede solo il kernel dell’host, non vede altro, quindi sotto puoi usare qualsiasi distribuzione linux con un kernel recente.

Leggevo che un tizio dice che serve un reboot (mah) e che sembra che il counter parta da zero (e questo mi sembra piu’ ragionevole), e quindi per metterlo sul terzo processo dovresti usare

CPUAffinity=2

https://stackoverflow.com/a/57178385/5810105