1

everyone. I’m tring to use udev to set my cpu's scaling_governor value from powersave to performance. And here is my udev rule file:

[root@node1 ~]$ cat /etc/udev/rules.d/50-scaling-governor.rules
SUBSYSTEM=="cpu", KERNEL=="cpu[0-9]|cpu[0-9][0-9]", ACTION=="add", ATTR{cpufreq/scaling_governor}="performance"

Before testing my 50-scaling-governor.rules, let's see what the value of scaling_governor is first.

[root@node1 ~]$ cat /sys/devices/system/cpu/cpu16/cpufreq/scaling_governor
powersave

And then I use udevadm command to execute my 50-scaling-governor.rule

[root@node1 ~]$ udevadm test --action="add" /devices/system/cpu/cpu16
calling: test
version 219
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          219
file size:         8873994 bytes
header size             80 bytes
strings            2300642 bytes
nodes              6573272 bytes
Load module index
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
# omit some unrelevant messages
...
Reading rules file: /etc/udev/rules.d/50-scaling-governor.rules
...
rules contain 49152 bytes tokens (4096 * 12 bytes), 21456 bytes strings
3908 strings (46431 bytes), 2777 de-duplicated (26107 bytes), 1132 trie nodes used
no db file to read /run/udev/data/+cpu:cpu16: No such file or directory
ATTR '/sys/devices/system/cpu/cpu16/cpufreq/scaling_governor' writing 'performance' /etc/udev/rules.d/50-scaling-governor.rules:1
IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/50-udev-default.rules:11
IMPORT builtin 'hwdb' returned non-zero
RUN 'kmod load $env{MODALIAS}' /usr/lib/udev/rules.d/80-drivers.rules:5
RUN '/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --no-block /usr/lib/udev/kdump-udev-throttler'' /usr/lib/udev
/rules.d/98-kexec.rules:14
ACTION=add
DEVPATH=/devices/system/cpu/cpu16
DRIVER=processor
MODALIAS=cpu:type:x86,ven0000fam0006mod004F:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0015,0016,
0017,0018,0019,001A,001B,001C,001D,001F,002B,0034,003A,003B,003D,0068,006B,006C,006D,006F,0070,0072,0074,0075,0076,0078,0079,007C,0080,0081,0082,0083,008
4,0085,0086,0087,0088,0089,008B,008C,008D,008E,008F,0091,0092,0093,0094,0095,0096,0097,0098,0099,009A,009B,009C,009D,009E,00C0,00C5,00C8,00E1,00E3,00E4,0
0E6,00E7,00EB,00EC,00F0,00F1,00F3,00F5,00F6,00F9,00FA,00FB,00FD,0100,0101,0102,0103,0104,0111,0120,0121,0123,0124,0125,0127,0128,0129,012A,012B,012C,012D
,012F,0132,0133,0134,0139,0140,0160,0161,0162,0163,0165,01C0,01C1,01C2,01C4,01C5,01C6,024A,025A,025B,025C,025F
SUBSYSTEM=cpu
USEC_INITIALIZED=184210753630
run: 'kmod load cpu:type:x86,ven0000fam0006mod004F:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,001
5,0016,0017,0018,0019,001A,001B,001C,001D,001F,002B,0034,003A,003B,003D,0068,006B,006C,006D,006F,0070,0072,0074,0075,0076,0078,0079,007C,0080,0081,0082,0
083,0084,0085,0086,0087,0088,0089,008B,008C,008D,008E,008F,0091,0092,0093,0094,0095,0096,0097,0098,0099,009A,009B,009C,009D,009E,00C0,00C5,00C8,00E1,00E3
,00E4,00E6,00E7,00EB,00EC,00F0,00F1,00F3,00F5,00F6,00F9,00FA,00FB,00FD,0100,0101,0102,0103,0104,0111,0120,0121,0123,0124,0125,0127,0128,0129,012A,012B,01
2C,012D,012F,0132,0133,0134,0139,0140,0160,0161,0162,0163,0165,01C0,01C1,01C2,01C4,01C5,01C6,024A,025A,025B,025C,025F'
run: '/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --no-block /usr/lib/udev/kdump-udev-throttler''
Unload module index
Unloaded link configuration context.

And now, the value of cpu16/scaling_governor has changed, so it's nothing wrong with my udev rule.

[root@node1 ~]$ cat /sys/devices/system/cpu/cpu16/cpufreq/scaling_governor
performance

But after rebooting my server, I find that the scaling_governor value of cpu16 is still powersave. I have no idea why my udev rule can work properly by udevadm while failing by rebooting.

Some environment information about my machine is as follows:

OS: CentOS Linux release 7.9.2009 (Core)

kernel version: 5.4.154-1.el7.elrepo.x86_64

udev version: 219

Can anyone give me some hint or advice? Thanks in advance

Phoenix Chao
  • 390
  • 3
  • 19
  • `I’m tring to use udev` why udev? Why not use something else? Like `/etc/rc.local` or `systemd-tmpfiles` ? I think, maybe, udev is not around when cpu is added - cpu is there, when udev is starting up, so it does not see any `add`. Does it make sense? – KamilCuk Nov 21 '21 at 10:21
  • In my opinion, udev is a sort of device management thing in Linux, and the CPU is also a device. So using udev to manage a CPU is quite straightforward. But if it doesn't, I would try to use systemd to achieve my goal. Thanks for your comment. – Phoenix Chao Nov 22 '21 at 01:27

0 Answers0