View previous topic :: View next topic |
Author |
Message |
fredolic n00b
Joined: 11 Jul 2005 Posts: 18
|
Posted: Wed Apr 15, 2020 7:35 am Post subject: Disable hyperthreading at startup. |
|
|
Hi,
I can't seem to remember how to pass options to /sys on startup. I have checked my notes, and tried to search online for such a ridicule question, but I am stuck.
So here it goes: I want to have hyperthreading enabled in the kernel, but I want to disable it at startup. Hence, I need to pass "echo off > /sys/devices/system/cpu/smt/control". I must probably deal with some file in "/etc/conf.d", but I can't seem to remember. How can I do that?
I am using openrc.
Thank you. |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 31288 Location: here
|
Posted: Wed Apr 15, 2020 7:51 am Post subject: |
|
|
You can made it adding nosmt to GRUB_CMDLINE_LINUX variable in /etc/default/grub _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2873
|
Posted: Wed Apr 15, 2020 7:59 am Post subject: |
|
|
If "still" want to use sysfs, personally I use /etc/local.d for these with OpenRC. See /etc/local.d/README (the "local" service is already enabled by default I believe and merely does nothing if no scripts found) |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Wed Apr 15, 2020 7:21 pm Post subject: |
|
|
/usr/src/linux/Documentation/admin-guide/kernel-parameters.txt: | nosmt [KNL,S390] Disable symmetric multithreading (SMT).
Equivalent to smt=1.
[KNL,x86] Disable symmetric multithreading (SMT).
nosmt=force: Force disable SMT, cannot be undone
via the sysfs control file. |
You're better off disabling it in the BIOS if possible, as that stops the processor reserving hardware resources for the inaccessible threads. |
|
Back to top |
|
|
fredolic n00b
Joined: 11 Jul 2005 Posts: 18
|
Posted: Thu Apr 16, 2020 9:01 am Post subject: |
|
|
Dear all,
Thank you very much for all the replies.
I was looking for something like /etc/local.d. I think this is the most flexible approach.
I didn't knew that disabling it in the BIOS also had an effect at the hardware level (if you can say it this way). I will explore it.
But my idea is to have something flexible, that I can move to hyperthreading or not, based on the work that I am done. I sometimes have to run scientific software (MCMC simulations that need maximum clockspeed, and not to move a lot between processors, and not to share resources at the core level), and hyperthreading does not seem to be a good idea. So disabling it at the BIOS or at GRUB is less convenient for me.
I will try to make local.d/local.start work.
Thank you, again, everyone. |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6070 Location: Removed by Neddy
|
Posted: Sat Apr 18, 2020 12:06 am Post subject: |
|
|
*IF* you are after guaranteed resource have you considered Cgroups?
you can lock processes to specific cores, dedicate RAM, network etc...
This is the approach I do to manage resources on a simulation box I manage. _________________ #define HelloWorld int
#define Int main()
#define Return printf
#define Print return
#include <stdio>
HelloWorld Int {
Return("Hello, world!\n");
Print 0; |
|
Back to top |
|
|
fredolic n00b
Joined: 11 Jul 2005 Posts: 18
|
Posted: Sat Apr 18, 2020 4:30 am Post subject: |
|
|
No, I haven't, @Naib.
I have never thougth of cgroups as working in a personal computer. A first quick overview seems not evident to configure. Do you think it it worth trying? Would it be possible to say like "use these 3 CPUs for this R/JAGS/Stan process and this amount of memory" relatively easy or is it more complicated than that? Would it make a noticeable difference in computation time?
Thank you very much for the suggestion. |
|
Back to top |
|
|
xdarma l33t
Joined: 08 Dec 2003 Posts: 720 Location: tra veneto e friuli (italy)
|
Posted: Sat Apr 18, 2020 6:23 am Post subject: |
|
|
Perhaps "taskset" can be useful. It can bind a process to a list of cpus.
If you want to avoid multithreading you can define only odd or even cpus.
For example: taskset -c 1,3,5,7 /usr/bin/myfavouritgame
It's part of sys-apps/util-linux package. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3467
|
Posted: Sat Apr 18, 2020 9:46 am Post subject: |
|
|
Why not just disable HT in bios? I mean, what is that thing you're doing that actually benefits from HT? To me it looks a bit like a corner case / marketing BS.
But... You can disable CPU cores via /sys. With exception of CPU0, since the boot cpu can't be disabled.
Code: | Quad /sys/devices/system/cpu/cpu1 # echo 0 > online
Quad /sys/devices/system/cpu/cpu1 # LANG=C lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 40 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0,2,3
Off-line CPU(s) list: 1
Thread(s) per core: 1
Core(s) per socket: 3
Socket(s): 1 |
Cgroups can limit resources available to a particular process and it's children. AFAIK all containers use this, lxc, docker, you name it.
I don't know if there is a way to guarantee resources for a process. Taskset can ban a process from any cpu, but I don't know if it's also possible to prevent a CPU from accepting other tasks (new processes) by default and only serve the particular application. |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6070 Location: Removed by Neddy
|
Posted: Sat Apr 18, 2020 10:11 am Post subject: |
|
|
szatox wrote: | Why not just disable HT in bios? I mean, what is that thing you're doing that actually benefits from HT? To me it looks a bit like a corner case / marketing BS.
But... You can disable CPU cores via /sys. With exception of CPU0, since the boot cpu can't be disabled.
Code: | Quad /sys/devices/system/cpu/cpu1 # echo 0 > online
Quad /sys/devices/system/cpu/cpu1 # LANG=C lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 40 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0,2,3
Off-line CPU(s) list: 1
Thread(s) per core: 1
Core(s) per socket: 3
Socket(s): 1 |
Cgroups can limit resources available to a particular process and it's children. AFAIK all containers use this, lxc, docker, you name it.
I don't know if there is a way to guarantee resources for a process. Taskset can ban a process from any cpu, but I don't know if it's also possible to prevent a CPU from accepting other tasks (new processes) by default and only serve the particular application. |
thats exactly what cgroups does. it locks processes to a specific CPU (or a number of CPU's).
This use-case screams cgroups. _________________ #define HelloWorld int
#define Int main()
#define Return printf
#define Print return
#include <stdio>
HelloWorld Int {
Return("Hello, world!\n");
Print 0; |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3467
|
Posted: Sat Apr 18, 2020 10:14 am Post subject: |
|
|
Yes, I know it's easy to lock a particular process to a CPU.
Is it also possible to lock every other process out of that CPU? Like in "every" other process, not "every process I found and manually banned from this core" |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6070 Location: Removed by Neddy
|
Posted: Sat Apr 18, 2020 11:48 am Post subject: |
|
|
szatox wrote: | Yes, I know it's easy to lock a particular process to a CPU.
Is it also possible to lock every other process out of that CPU? Like in "every" other process, not "every process I found and manually banned from this core" |
yes. Once you create a cgroup group, processes associated with that group have exclusive access to that resource. So if you make a group and assign CPU0 to that group, nothing but processes in that group can use CPU0. Now you might then add one or many processes to that group. _________________ #define HelloWorld int
#define Int main()
#define Return printf
#define Print return
#include <stdio>
HelloWorld Int {
Return("Hello, world!\n");
Print 0; |
|
Back to top |
|
|
|