public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()
@ 2024-05-31  3:08 pugaowei
  2024-06-03  5:51 ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: pugaowei @ 2024-05-31  3:08 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, vschneid
  Cc: linux-kernel, pugaowei

we should update the weight of cfs_rq before update_cfs_group().
Ensure that we can get accurate shares of the cfs_rq when its
weights changes. we can find this work was done correctly in
dequeue_entity(). so fix it.

Signed-off-by: pugaowei <pugaowei@oppo.com>
---
 kernel/sched/fair.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a5b1ae0aa55..395840f3fa1d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5304,6 +5304,12 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 	 */
 	update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH);
 	se_update_runnable(se);
+
+	/*
+	 * we should update the weight of cfs_rq before update_cfs_group.
+	 * Ensure we can get accurate shares of the cfs_rq when its weights changes.
+	 */
+	account_entity_enqueue(cfs_rq, se);
 	/*
 	 * XXX update_load_avg() above will have attached us to the pelt sum;
 	 * but update_cfs_group() here will re-adjust the weight and have to
@@ -5318,8 +5324,6 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 	if (!curr)
 		place_entity(cfs_rq, se, flags);
 
-	account_entity_enqueue(cfs_rq, se);
-
 	/* Entity has migrated, no longer consider this task hot */
 	if (flags & ENQUEUE_MIGRATED)
 		se->exec_start = 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()
  2024-05-31  3:08 [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity() pugaowei
@ 2024-06-03  5:51 ` kernel test robot
  2024-06-04  1:57   ` 答复: " 普高伟(kuroky)
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2024-06-03  5:51 UTC (permalink / raw)
  To: pugaowei
  Cc: oe-lkp, lkp, linux-kernel, aubrey.li, yu.c.chen, mingo, peterz,
	juri.lelli, vincent.guittot, dietmar.eggemann, rostedt, bsegall,
	mgorman, bristot, vschneid, pugaowei, oliver.sang



Hello,

kernel test robot noticed "WARNING:at_kernel/sched/fair.c:#place_entity" on:

commit: 06d0c29c533e77cef4f1793343c78180b32645e0 ("[PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()")
url: https://github.com/intel-lab-lkp/linux/commits/pugaowei/sched-fair-updates-weight-of-cfs_rq-before-update_cfs_group-in-enqueue_entity/20240531-111010
base: https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git 402de7fc880fef055bc984957454b532987e9ad0
patch link: https://lore.kernel.org/all/20240531030833.3375-1-pugaowei@oppo.com/
patch subject: [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()

in testcase: boot

compiler: gcc-13
test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G

(please refer to attached dmesg/kmsg for entire log/backtrace)


+----------------------------------------------+------------+------------+
|                                              | 402de7fc88 | 06d0c29c53 |
+----------------------------------------------+------------+------------+
| WARNING:at_kernel/sched/fair.c:#place_entity | 0          | 8          |
| RIP:place_entity                             | 0          | 8          |
+----------------------------------------------+------------+------------+


If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202406031240.f2476e94-oliver.sang@intel.com


[    0.400409][    T0] ------------[ cut here ]------------
[ 0.400603][ T0] WARNING: CPU: 0 PID: 0 at kernel/sched/fair.c:5256 place_entity (kernel/sched/fair.c:5256 (discriminator 1)) 
[    0.400603][    T0] Modules linked in:
[    0.400603][    T0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.10.0-rc1-00003-g06d0c29c533e #1
[    0.400603][    T0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[ 0.400603][ T0] RIP: 0010:place_entity (kernel/sched/fair.c:5256 (discriminator 1)) 
[ 0.400603][ T0] Code: 29 c5 eb 82 b9 02 00 00 00 49 c1 ee 0a 49 39 ce 4c 0f 42 f1 49 8d 0c 16 eb d4 48 89 de e8 a0 5c ff ff 48 89 c7 e9 50 ff ff ff <0f> 0b eb d1 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90
All code
========
   0:	29 c5                	sub    %eax,%ebp
   2:	eb 82                	jmp    0xffffffffffffff86
   4:	b9 02 00 00 00       	mov    $0x2,%ecx
   9:	49 c1 ee 0a          	shr    $0xa,%r14
   d:	49 39 ce             	cmp    %rcx,%r14
  10:	4c 0f 42 f1          	cmovb  %rcx,%r14
  14:	49 8d 0c 16          	lea    (%r14,%rdx,1),%rcx
  18:	eb d4                	jmp    0xffffffffffffffee
  1a:	48 89 de             	mov    %rbx,%rsi
  1d:	e8 a0 5c ff ff       	callq  0xffffffffffff5cc2
  22:	48 89 c7             	mov    %rax,%rdi
  25:	e9 50 ff ff ff       	jmpq   0xffffffffffffff7a
  2a:*	0f 0b                	ud2    		<-- trapping instruction
  2c:	eb d1                	jmp    0xffffffffffffffff
  2e:	0f 1f 40 00          	nopl   0x0(%rax)
  32:	90                   	nop
  33:	90                   	nop
  34:	90                   	nop
  35:	90                   	nop
  36:	90                   	nop
  37:	90                   	nop
  38:	90                   	nop
  39:	90                   	nop
  3a:	90                   	nop
  3b:	90                   	nop
  3c:	90                   	nop
  3d:	90                   	nop
  3e:	90                   	nop
  3f:	90                   	nop

Code starting with the faulting instruction
===========================================
   0:	0f 0b                	ud2    
   2:	eb d1                	jmp    0xffffffffffffffd5
   4:	0f 1f 40 00          	nopl   0x0(%rax)
   8:	90                   	nop
   9:	90                   	nop
   a:	90                   	nop
   b:	90                   	nop
   c:	90                   	nop
   d:	90                   	nop
   e:	90                   	nop
   f:	90                   	nop
  10:	90                   	nop
  11:	90                   	nop
  12:	90                   	nop
  13:	90                   	nop
  14:	90                   	nop
  15:	90                   	nop
[    0.400603][    T0] RSP: 0000:ffffffff8f403d38 EFLAGS: 00010046
[    0.400603][    T0] RAX: 0000000000000000 RBX: ffff9a3e4026a880 RCX: 0000000000000400
[    0.400603][    T0] RDX: 0000000000000000 RSI: fffffffffff00000 RDI: 00000000000b71b0
[    0.400603][    T0] RBP: fffffffffff00000 R08: 0000000000000001 R09: 0000000000000000
[    0.400603][    T0] R10: 0000000000000000 R11: 0000000094f4efa8 R12: ffff9a416fc348c0
[    0.400603][    T0] R13: 0000000000000008 R14: 0000000000000400 R15: 0000000000000001
[    0.400603][    T0] FS:  0000000000000000(0000) GS:ffff9a416fc00000(0000) knlGS:0000000000000000
[    0.400603][    T0] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.400603][    T0] CR2: ffff9a417ffff000 CR3: 00000001e4a1c000 CR4: 00000000000406f0
[    0.400603][    T0] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[    0.400603][    T0] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[    0.400603][    T0] Call Trace:
[    0.400603][    T0]  <TASK>
[ 0.400603][ T0] ? __warn (kernel/panic.c:693) 
[ 0.400603][ T0] ? place_entity (kernel/sched/fair.c:5256 (discriminator 1)) 
[ 0.400603][ T0] ? report_bug (lib/bug.c:180 lib/bug.c:219) 
[ 0.400603][ T0] ? handle_bug (arch/x86/kernel/traps.c:239) 
[ 0.400603][ T0] ? exc_invalid_op (arch/x86/kernel/traps.c:260 (discriminator 1)) 
[ 0.400603][ T0] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:621) 
[ 0.400603][ T0] ? place_entity (kernel/sched/fair.c:5256 (discriminator 1)) 
[ 0.400603][ T0] ? place_entity (kernel/sched/fair.c:5182) 
[ 0.400603][ T0] enqueue_entity (kernel/sched/fair.c:5328) 
[ 0.400603][ T0] enqueue_task_fair (kernel/sched/fair.c:6785) 
[ 0.400603][ T0] wake_up_new_task (kernel/sched/core.c:2015 (discriminator 2) kernel/sched/core.c:4693 (discriminator 2)) 
[ 0.400603][ T0] kernel_clone (kernel/fork.c:2831 (discriminator 1)) 
[ 0.400603][ T0] user_mode_thread (kernel/fork.c:2876) 
[ 0.400603][ T0] ? __pfx_kernel_init (init/main.c:1459) 
[ 0.400603][ T0] rest_init (init/main.c:712) 
[ 0.400603][ T0] start_kernel (include/trace/events/initcall.h:27 init/main.c:1234 init/main.c:1001) 
[ 0.400603][ T0] x86_64_start_reservations (arch/x86/kernel/head64.c:495) 
[ 0.400603][ T0] x86_64_start_kernel (arch/x86/kernel/head64.c:437 (discriminator 5)) 
[ 0.400603][ T0] common_startup_64 (arch/x86/kernel/head_64.S:421) 
[    0.400603][    T0]  </TASK>
[    0.400603][    T0] ---[ end trace 0000000000000000 ]---



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20240603/202406031240.f2476e94-oliver.sang@intel.com



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* 答复: [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()
  2024-06-03  5:51 ` kernel test robot
@ 2024-06-04  1:57   ` 普高伟(kuroky)
  0 siblings, 0 replies; 3+ messages in thread
From: 普高伟(kuroky) @ 2024-06-04  1:57 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-lkp@lists.linux.dev, lkp@intel.com,
	linux-kernel@vger.kernel.org, aubrey.li@linux.intel.com,
	yu.c.chen@intel.com, mingo@redhat.com, peterz@infradead.org,
	juri.lelli@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com,
	mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com

I have submitted a V2 to fix this warning yesterday:
https://lore.kernel.org/linux-kernel/20240603091805.858-1-pugaowei@oppo.com/T/

tks.

-----邮件原件-----
发件人: kernel test robot <oliver.sang@intel.com> 
发送时间: 2024年6月3日 13:51
收件人: 普高伟(kuroky) <pugaowei@oppo.com>
抄送: oe-lkp@lists.linux.dev; lkp@intel.com; linux-kernel@vger.kernel.org; aubrey.li@linux.intel.com; yu.c.chen@intel.com; mingo@redhat.com; peterz@infradead.org; juri.lelli@redhat.com; vincent.guittot@linaro.org; dietmar.eggemann@arm.com; rostedt@goodmis.org; bsegall@google.com; mgorman@suse.de; bristot@redhat.com; vschneid@redhat.com; 普高伟(kuroky) <pugaowei@oppo.com>; oliver.sang@intel.com
主题: Re: [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()



Hello,

kernel test robot noticed "WARNING:at_kernel/sched/fair.c:#place_entity" on:

commit: 06d0c29c533e77cef4f1793343c78180b32645e0 ("[PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()")
url: https://github.com/intel-lab-lkp/linux/commits/pugaowei/sched-fair-updates-weight-of-cfs_rq-before-update_cfs_group-in-enqueue_entity/20240531-111010
base: https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git 402de7fc880fef055bc984957454b532987e9ad0
patch link: https://lore.kernel.org/all/20240531030833.3375-1-pugaowei@oppo.com/
patch subject: [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity()

in testcase: boot

compiler: gcc-13
test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G

(please refer to attached dmesg/kmsg for entire log/backtrace)


+----------------------------------------------+------------+------------+
|                                              | 402de7fc88 | 06d0c29c53 
| |
+----------------------------------------------+------------+------------+
| WARNING:at_kernel/sched/fair.c:#place_entity | 0          | 8          |
| RIP:place_entity                             | 0          | 8          |
+----------------------------------------------+------------+------------+


If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: 
| https://lore.kernel.org/oe-lkp/202406031240.f2476e94-oliver.sang@intel
| .com


[    0.400409][    T0] ------------[ cut here ]------------
[ 0.400603][ T0] WARNING: CPU: 0 PID: 0 at kernel/sched/fair.c:5256 place_entity (kernel/sched/fair.c:5256 (discriminator 1)) 
[    0.400603][    T0] Modules linked in:
[    0.400603][    T0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.10.0-rc1-00003-g06d0c29c533e #1
[    0.400603][    T0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[ 0.400603][ T0] RIP: 0010:place_entity (kernel/sched/fair.c:5256 (discriminator 1)) [ 0.400603][ T0] Code: 29 c5 eb 82 b9 02 00 00 00 49 c1 ee 0a 49 39 ce 4c 0f 42 f1 49 8d 0c 16 eb d4 48 89 de e8 a0 5c ff ff 48 89 c7 e9 50 ff ff ff <0f> 0b eb d1 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 All code ========
   0:	29 c5                	sub    %eax,%ebp
   2:	eb 82                	jmp    0xffffffffffffff86
   4:	b9 02 00 00 00       	mov    $0x2,%ecx
   9:	49 c1 ee 0a          	shr    $0xa,%r14
   d:	49 39 ce             	cmp    %rcx,%r14
  10:	4c 0f 42 f1          	cmovb  %rcx,%r14
  14:	49 8d 0c 16          	lea    (%r14,%rdx,1),%rcx
  18:	eb d4                	jmp    0xffffffffffffffee
  1a:	48 89 de             	mov    %rbx,%rsi
  1d:	e8 a0 5c ff ff       	callq  0xffffffffffff5cc2
  22:	48 89 c7             	mov    %rax,%rdi
  25:	e9 50 ff ff ff       	jmpq   0xffffffffffffff7a
  2a:*	0f 0b                	ud2    		<-- trapping instruction
  2c:	eb d1                	jmp    0xffffffffffffffff
  2e:	0f 1f 40 00          	nopl   0x0(%rax)
  32:	90                   	nop
  33:	90                   	nop
  34:	90                   	nop
  35:	90                   	nop
  36:	90                   	nop
  37:	90                   	nop
  38:	90                   	nop
  39:	90                   	nop
  3a:	90                   	nop
  3b:	90                   	nop
  3c:	90                   	nop
  3d:	90                   	nop
  3e:	90                   	nop
  3f:	90                   	nop

Code starting with the faulting instruction ===========================================
   0:	0f 0b                	ud2    
   2:	eb d1                	jmp    0xffffffffffffffd5
   4:	0f 1f 40 00          	nopl   0x0(%rax)
   8:	90                   	nop
   9:	90                   	nop
   a:	90                   	nop
   b:	90                   	nop
   c:	90                   	nop
   d:	90                   	nop
   e:	90                   	nop
   f:	90                   	nop
  10:	90                   	nop
  11:	90                   	nop
  12:	90                   	nop
  13:	90                   	nop
  14:	90                   	nop
  15:	90                   	nop
[    0.400603][    T0] RSP: 0000:ffffffff8f403d38 EFLAGS: 00010046
[    0.400603][    T0] RAX: 0000000000000000 RBX: ffff9a3e4026a880 RCX: 0000000000000400
[    0.400603][    T0] RDX: 0000000000000000 RSI: fffffffffff00000 RDI: 00000000000b71b0
[    0.400603][    T0] RBP: fffffffffff00000 R08: 0000000000000001 R09: 0000000000000000
[    0.400603][    T0] R10: 0000000000000000 R11: 0000000094f4efa8 R12: ffff9a416fc348c0
[    0.400603][    T0] R13: 0000000000000008 R14: 0000000000000400 R15: 0000000000000001
[    0.400603][    T0] FS:  0000000000000000(0000) GS:ffff9a416fc00000(0000) knlGS:0000000000000000
[    0.400603][    T0] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.400603][    T0] CR2: ffff9a417ffff000 CR3: 00000001e4a1c000 CR4: 00000000000406f0
[    0.400603][    T0] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[    0.400603][    T0] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[    0.400603][    T0] Call Trace:
[    0.400603][    T0]  <TASK>
[ 0.400603][ T0] ? __warn (kernel/panic.c:693) [ 0.400603][ T0] ? place_entity (kernel/sched/fair.c:5256 (discriminator 1)) [ 0.400603][ T0] ? report_bug (lib/bug.c:180 lib/bug.c:219) [ 0.400603][ T0] ? handle_bug (arch/x86/kernel/traps.c:239) [ 0.400603][ T0] ? exc_invalid_op (arch/x86/kernel/traps.c:260 (discriminator 1)) [ 0.400603][ T0] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:621)
[ 0.400603][ T0] ? place_entity (kernel/sched/fair.c:5256 (discriminator 1)) [ 0.400603][ T0] ? place_entity (kernel/sched/fair.c:5182) [ 0.400603][ T0] enqueue_entity (kernel/sched/fair.c:5328) [ 0.400603][ T0] enqueue_task_fair (kernel/sched/fair.c:6785) [ 0.400603][ T0] wake_up_new_task (kernel/sched/core.c:2015 (discriminator 2) kernel/sched/core.c:4693 (discriminator 2)) [ 0.400603][ T0] kernel_clone (kernel/fork.c:2831 (discriminator 1)) [ 0.400603][ T0] user_mode_thread (kernel/fork.c:2876) [ 0.400603][ T0] ? __pfx_kernel_init (init/main.c:1459) [ 0.400603][ T0] rest_init (init/main.c:712) [ 0.400603][ T0] start_kernel (include/trace/events/initcall.h:27 init/main.c:1234 init/main.c:1001) [ 0.400603][ T0] x86_64_start_reservations (arch/x86/kernel/head64.c:495) [ 0.400603][ T0] x86_64_start_kernel (arch/x86/kernel/head64.c:437 (discriminator 5)) [ 0.400603][ T0] common_startup_64 (arch/x86/kernel/head_64.S:421) 
[    0.400603][    T0]  </TASK>
[    0.400603][    T0] ---[ end trace 0000000000000000 ]---



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20240603/202406031240.f2476e94-oliver.sang@intel.com



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-04  1:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-31  3:08 [PATCH] sched/fair: updates weight of cfs_rq before update_cfs_group() in enqueue_entity() pugaowei
2024-06-03  5:51 ` kernel test robot
2024-06-04  1:57   ` 答复: " 普高伟(kuroky)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox