2023-01-15 11:38:34

by Vincent Wang

[permalink] [raw]
Subject: [PATCH] cpufreq: Send CPUFREQ_CREATE_POLICY notification after the perf domain creation.

From: Vincent Wang <[email protected]>

We found the following issue during kernel boot on android phone:

[ 1.325272][ T1] cpu cpu0: EM: created perf domain
[ 1.329317][ T1] cpu cpu4: EM: created perf domain
[ 1.337597][ T76] pd_init: no EM found for CPU7
[ 1.350849][ T1] cpu cpu7: EM: created perf domain

pd init for cluster2 is executed in a kworker thread and
is earlier than the perf domain creation for cluster2.

pd_init() is called from the cpufreq notification of
CPUFREQ_CREATE_POLICY in cpufreq_online(), which is earlier
than that cpufreq_driver->register_em() is called.

To avoid this issue, cpufreq notification should be sent after
the perf domain creation.

Signed-off-by: Vincent Wang <[email protected]>
---
drivers/cpufreq/cpufreq.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7e56a42750ea..9e67df4fc334 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1506,6 +1506,9 @@ static int cpufreq_online(unsigned int cpu)
*/
if (cpufreq_driver->register_em)
cpufreq_driver->register_em(policy);
+
+ blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
+ CPUFREQ_CREATE_POLICY, policy);
}

ret = cpufreq_init_policy(policy);
--
2.25.1


2023-01-17 09:01:01

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: Send CPUFREQ_CREATE_POLICY notification after the perf domain creation.


Greeting,

FYI, we noticed WARNING:at_kernel/power/qos.c:#freq_qos_add_request due to commit (built with gcc-11):

commit: dc40c7a213ff7db6a31ea89aee4c7e38bcdd095f ("[PATCH] cpufreq: Send CPUFREQ_CREATE_POLICY notification after the perf domain creation.")
url: https://github.com/intel-lab-lkp/linux/commits/Vincent-Wang/cpufreq-Send-CPUFREQ_CREATE_POLICY-notification-after-the-perf-domain-creation/20230115-190437
base: https://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/all/[email protected]/
patch subject: [PATCH] cpufreq: Send CPUFREQ_CREATE_POLICY notification after the perf domain creation.

in testcase: ocfs2test
version: ocfs2test-x86_64-d802bf7-1_20210827
with following parameters:

disk: 1HDD
test: test-reserve_space



on test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-4790 v3 @ 3.60GHz (Haswell) with 6G memory

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):


If you fix the issue, kindly add following tag
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-lkp/[email protected]


[ 8.559106][ T1] ------------[ cut here ]------------
[ 8.566809][ T56] usb usb4: Product: xHCI Host Controller
[ 8.572062][ T1] freq_qos_add_request() called for active request
[ 8.572077][ T1] WARNING: CPU: 7 PID: 1 at kernel/power/qos.c:537 freq_qos_add_request (kbuild/src/x86_64-3/kernel/power/qos.c:537)
[ 8.572096][ T83] usb 1-1: New USB device found, idVendor=8087, idProduct=8008, bcdDevice= 0.04
[ 8.572111][ T83] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 8.577622][ T56] usb usb4: Manufacturer: Linux 6.2.0-rc3-00080-gdc40c7a213ff xhci-hcd
[ 8.578464][ T83] hub 1-1:1.0: USB hub found
[ 8.583916][ T1] Modules linked in:
[ 8.583920][ T1] CPU: 7 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc3-00080-gdc40c7a213ff #5
[ 8.583933][ T1] Hardware name: Dell Inc. OptiPlex 9020/03CPWF, BIOS A11 04/01/2015
[ 8.583934][ T1] RIP: 0010:freq_qos_add_request (kbuild/src/x86_64-3/kernel/power/qos.c:537)
[ 8.583953][ T83] hub 1-1:1.0: 6 ports detected
[ 8.593003][ T56] usb usb4: SerialNumber: 0000:00:14.0
[ 8.601792][ T1] Code: 0f 85 ee 00 00 00 48 8b 43 30 48 85 c0 74 2d 48 3d 00 f0 ff ff 77 25 48 c7 c6 00 6f 88 83 48 c7 c7 40 6e 88 83 e8 1f 4c 1a 02 <0f> 0b 48 83 c4 08 b8 ea ff ff ff 5b 5d 41 5c 41 5d c3 48 89 d9 48
All code
========
0: 0f 85 ee 00 00 00 jne 0xf4
6: 48 8b 43 30 mov 0x30(%rbx),%rax
a: 48 85 c0 test %rax,%rax
d: 74 2d je 0x3c
f: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax
15: 77 25 ja 0x3c
17: 48 c7 c6 00 6f 88 83 mov $0xffffffff83886f00,%rsi
1e: 48 c7 c7 40 6e 88 83 mov $0xffffffff83886e40,%rdi
25: e8 1f 4c 1a 02 callq 0x21a4c49
2a:* 0f 0b ud2 <-- trapping instruction
2c: 48 83 c4 08 add $0x8,%rsp
30: b8 ea ff ff ff mov $0xffffffea,%eax
35: 5b pop %rbx
36: 5d pop %rbp
37: 41 5c pop %r12
39: 41 5d pop %r13
3b: c3 retq
3c: 48 89 d9 mov %rbx,%rcx
3f: 48 rex.W

Code starting with the faulting instruction
===========================================
0: 0f 0b ud2
2: 48 83 c4 08 add $0x8,%rsp
6: b8 ea ff ff ff mov $0xffffffea,%eax
b: 5b pop %rbx
c: 5d pop %rbp
d: 41 5c pop %r12
f: 41 5d pop %r13
11: c3 retq
12: 48 89 d9 mov %rbx,%rcx
15: 48 rex.W
[ 8.601795][ T1] RSP: 0000:ffffc90000037a60 EFLAGS: 00010282
[ 8.601807][ T1] RAX: 0000000000000000 RBX: ffff88810e420ba8 RCX: 0000000000000000
[ 8.601809][ T1] RDX: 0000000000000000 RSI: 0000000000000004 RDI: fffff52000006f3e
[ 8.601810][ T1] RBP: ffff888139899890 R08: 0000000000000001 R09: ffffc900000378eb
[ 8.611046][ T56] hub 4-0:1.0: USB hub found
[ 8.617612][ T1] R10: fffff52000006f1d R11: 0000000000000001 R12: 0000000000000002
[ 8.617614][ T1] R13: ffff88810e420bd8 R14: 1ffff11027313301 R15: 0000000000000000
[ 8.622078][ T56] hub 4-0:1.0: 6 ports detected
[ 8.625737][ T1] FS: 0000000000000000(0000) GS:ffff888154f80000(0000) knlGS:0000000000000000
[ 8.625739][ T1] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 8.687380][ T80] usb 2-1: New USB device found, idVendor=8087, idProduct=8000, bcdDevice= 0.04
[ 8.690715][ T1] CR2: 0000000000000000 CR3: 000000019d00e001 CR4: 00000000001706e0
[ 8.690719][ T1] Call Trace:
[ 8.698484][ T80] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 8.706248][ T1] <TASK>
[ 8.712229][ T80] hub 2-1:1.0: USB hub found
[ 8.718421][ T1] acpi_thermal_cpufreq_init (kbuild/src/x86_64-3/drivers/acpi/processor_thermal.c:143)
[ 8.726371][ T80] hub 2-1:1.0: 8 ports detected
[ 8.730876][ T1] acpi_processor_notifier (kbuild/src/x86_64-3/drivers/acpi/processor_driver.c:240)
[ 8.795922][ T1] blocking_notifier_call_chain (kbuild/src/x86_64-3/kernel/notifier.c:87 kbuild/src/x86_64-3/kernel/notifier.c:382 kbuild/src/x86_64-3/kernel/notifier.c:370)
[ 8.801545][ T1] cpufreq_online (kbuild/src/x86_64-3/drivers/cpufreq/cpufreq.c:73 kbuild/src/x86_64-3/drivers/cpufreq/cpufreq.c:1062 kbuild/src/x86_64-3/drivers/cpufreq/cpufreq.c:1514)
[ 8.806130][ T1] ? __mutex_lock_slowpath (kbuild/src/x86_64-3/kernel/locking/mutex.c:282)
[ 8.811234][ T1] cpufreq_add_dev (kbuild/src/x86_64-3/drivers/cpufreq/cpufreq.c:1570)
[ 8.815815][ T1] subsys_interface_register (kbuild/src/x86_64-3/drivers/base/bus.c:1038)
[ 8.821260][ T1] ? subsys_interface_unregister (kbuild/src/x86_64-3/drivers/base/bus.c:1022)
[ 8.827049][ T1] ? mutex_unlock (kbuild/src/x86_64-3/arch/x86/include/asm/atomic64_64.h:190 kbuild/src/x86_64-3/include/linux/atomic/atomic-long.h:449 kbuild/src/x86_64-3/include/linux/atomic/atomic-instrumented.h:1790 kbuild/src/x86_64-3/kernel/locking/mutex.c:181 kbuild/src/x86_64-3/kernel/locking/mutex.c:540)
[ 8.831375][ T1] ? __mutex_unlock_slowpath+0x2a0/0x2a0
[ 8.837855][ T1] cpufreq_register_driver (kbuild/src/x86_64-3/drivers/cpufreq/cpufreq.c:2864)
[ 8.843126][ T1] intel_pstate_register_driver (kbuild/src/x86_64-3/drivers/cpufreq/intel_pstate.c:3106)
[ 8.848742][ T1] intel_pstate_init (kbuild/src/x86_64-3/drivers/cpufreq/intel_pstate.c:3462)
[ 8.853495][ T1] ? intel_pstate_setup (kbuild/src/x86_64-3/drivers/cpufreq/intel_pstate.c:3365)
[ 8.858507][ T1] do_one_initcall (kbuild/src/x86_64-3/init/main.c:1306)
[ 8.863016][ T1] ? trace_event_raw_event_initcall_level (kbuild/src/x86_64-3/init/main.c:1297)
[ 8.869580][ T1] ? parse_one (kbuild/src/x86_64-3/kernel/params.c:170)
[ 8.873818][ T1] ? __kmem_cache_alloc_node (kbuild/src/x86_64-3/mm/slub.c:3454 kbuild/src/x86_64-3/mm/slub.c:3491)
[ 8.879264][ T1] ? kasan_set_track (kbuild/src/x86_64-3/mm/kasan/common.c:52)
[ 8.883845][ T1] ? __kasan_kmalloc (kbuild/src/x86_64-3/mm/kasan/common.c:381)
[ 8.888426][ T1] do_initcalls (kbuild/src/x86_64-3/init/main.c:1378 kbuild/src/x86_64-3/init/main.c:1395)
[ 8.892748][ T1] kernel_init_freeable (kbuild/src/x86_64-3/init/main.c:1638)
[ 8.897772][ T1] ? console_on_rootfs (kbuild/src/x86_64-3/init/main.c:1604)
[ 8.902528][ T1] ? usleep_range_state (kbuild/src/x86_64-3/kernel/time/timer.c:2129)
[ 8.907542][ T1] ? _raw_spin_lock_bh (kbuild/src/x86_64-3/kernel/locking/spinlock.c:169)
[ 8.912298][ T1] ? rest_init (kbuild/src/x86_64-3/init/main.c:1514)
[ 8.916536][ T1] ? rest_init (kbuild/src/x86_64-3/init/main.c:1514)
[ 8.920772][ T1] kernel_init (kbuild/src/x86_64-3/init/main.c:1524)
[ 8.924923][ T1] ret_from_fork (kbuild/src/x86_64-3/arch/x86/entry/entry_64.S:314)
[ 8.929170][ T1] </TASK>
[ 8.932028][ T1] ---[ end trace 0000000000000000 ]---
[ 8.937300][ T1] Failed to add freq constraint for CPU0 (-22)


To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
sudo bin/lkp install job.yaml # job file is attached in this email
bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run
sudo bin/lkp run generated-yaml-file

# if come across any failure that blocks the test,
# please remove ~/.lkp and /lkp dir to run from a clean state.



--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests



Attachments:
(No filename) (8.68 kB)
config-6.2.0-rc3-00080-gdc40c7a213ff (174.66 kB)
job-script (5.96 kB)
dmesg.xz (37.07 kB)
ocfs2test (168.16 kB)
job.yaml (4.85 kB)
Download all attachments