Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Disable hyperthreading at startup.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
fredolic
n00b
n00b


Joined: 11 Jul 2005
Posts: 18

PostPosted: Wed Apr 15, 2020 7:35 am    Post subject: Disable hyperthreading at startup. Reply with quote

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
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31281
Location: here

PostPosted: Wed Apr 15, 2020 7:51 am    Post subject: Reply with quote

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
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2868

PostPosted: Wed Apr 15, 2020 7:59 am    Post subject: Reply with quote

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
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Wed Apr 15, 2020 7:21 pm    Post subject: Reply with quote

/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
View user's profile Send private message
fredolic
n00b
n00b


Joined: 11 Jul 2005
Posts: 18

PostPosted: Thu Apr 16, 2020 9:01 am    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6067
Location: Removed by Neddy

PostPosted: Sat Apr 18, 2020 12:06 am    Post subject: Reply with quote

*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.
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
fredolic
n00b
n00b


Joined: 11 Jul 2005
Posts: 18

PostPosted: Sat Apr 18, 2020 4:30 am    Post subject: Reply with quote

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
View user's profile Send private message
xdarma
l33t
l33t


Joined: 08 Dec 2003
Posts: 720
Location: tra veneto e friuli (italy)

PostPosted: Sat Apr 18, 2020 6:23 am    Post subject: Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3447

PostPosted: Sat Apr 18, 2020 9:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6067
Location: Removed by Neddy

PostPosted: Sat Apr 18, 2020 10:11 am    Post subject: Reply with quote

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.
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3447

PostPosted: Sat Apr 18, 2020 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6067
Location: Removed by Neddy

PostPosted: Sat Apr 18, 2020 11:48 am    Post subject: Reply with quote

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.
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum