From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from va-1-115.ptr.blmpb.com (va-1-115.ptr.blmpb.com [209.127.230.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47437477E41 for ; Thu, 2 Jul 2026 11:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.115 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782993002; cv=none; b=iqThfQssoA1p98K808NPozrrGdDAPM+U7qXamOxPfCgAc9/lU6EMqQWRnWKSM+jNh7Hzf0Bz3o3bCBDebsh1l8qXdOhPuagwIomtPLyzFDo1UERfH+3gzOyRp6dkQoodZcK97mIwJDqZOiRTv2KsGu6ZuE3MDxUGqT7PowflsSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782993002; c=relaxed/simple; bh=ojmmqaoHyW67Y7chHIsfLkvbMSNve2NCReVedIqh0CM=; h=Message-Id:Content-Type:In-Reply-To:Subject:Date:References: Content-Disposition:To:Cc:From:Mime-Version; b=hfk1qZcHhTtZC35numMDAk9fUkNj9jDb85P8bztIPDZqcD1Pauj+YJ/xFLBjIfpMSu7PvdnakTmcIfH2EuL1ZE8OwgE5Jf1+aPyKmZNbuArxz+IuFmXH62y6CGZxrr22sUgDmxzlxczSncHmnLpUCFwuX0kLutxBIwAMGLaRSFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=kHKkGY2L; arc=none smtp.client-ip=209.127.230.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="kHKkGY2L" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1782992994; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=4/QOPqYF9DhjAZ7F+Edwkkd4P1XUKKzfo/vVJsE/OMk=; b=kHKkGY2LZTJY1osMM5Zb9eLC+J/+4xjaO/w4v9QXNZWz1sP1RXYTDOojb/aPT75B1wFIcu u97mHMLpvFQ0b/D0f3a7FqUvC0WE/wkYUReBGpGLp0wTKDFuDqwiaZvv0Bl/Yvx+c1YMzD eHltp84QxEUf/jd1SZC7JoOdzgi7ETIUgUa4rmXGRwrkgQJyJE2Wt9RQRCJxhc2dzjSQMl rKyTtXVMu+LQM47KBhtINYJCx4X7y3o/BPxJjD4CMh6R+Mk3HtHqdgJFxhQqoiLUquGJln vjqEE2V+8MMUUVuZnwpZWCWcgLcUJV4k2Fmo0OnDdO4PKwdjzaF+jPQzatf/Cw== Message-Id: <20260702114919.GA186418@bytedance.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit In-Reply-To: <20260624121327.190063948@infradead.org> Subject: Re: [PATCH 0/2] sched: Remove sched_class::balance() Date: Thu, 2 Jul 2026 19:49:19 +0800 References: <20260624121327.190063948@infradead.org> Content-Disposition: inline X-Original-From: Aaron Lu To: "Peter Zijlstra" Cc: , , , , , , , , , , , , From: "Aaron Lu" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Lms-Return-Path: Hi Peter, On Wed, Jun 24, 2026 at 02:13:27PM +0200, Peter Zijlstra wrote: > Hi! > > As mentioned [1], I was going to move sched_balance_newidle() into > balance_fair(). And while the patch was quickly done, something didn't feel > right. > Sorry for replying late, been busy with other stuffs. The test caused a panic with below msg: [ 110.613929] BUG: kernel NULL pointer dereference, address: 0000000000000014 [ 110.615988] #PF: supervisor read access in kernel mode [ 110.617444] #PF: error_code(0x0000) - not-present page [ 110.618929] PGD 1044c2067 P4D 0 [ 110.619938] Oops: Oops: 0000 [#1] SMP NOPTI [ 110.621491] CPU: 34 UID: 1000 PID: 1394 Comm: sh Not tainted 7.1.0-rc2-00109-gb17be96b4d6c #4 PREEMPT(lazy) [ 110.624764] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 [ 110.627559] RIP: 0010:pick_next_task+0x42b/0xa20 [ 110.628970] Code: 28 60 00 49 89 c7 8b 05 b3 8d 73 05 41 39 c7 0f 83 c3 01 00 00 49 63 cf 48 8b 1c cd 80 7b 96 82 48 01 eb 48 8b b3 50 0f 00 00 <8b> 4e 14 48 8b 0c cd 80 7b 96 82 48 8b 4c 29 20 48 39 ce 74 32 48 [ 110.634160] RSP: 0000:ffa000000435bc48 EFLAGS: 00010083 [ 110.635261] RAX: 0000000000000040 RBX: ff11000ff85fe140 RCX: 0000000000000022 [ 110.636753] RDX: 0000000000000022 RSI: 0000000000000000 RDI: ff110001008b54d8 [ 110.638230] RBP: ffffffff87452140 R08: 0000000000000022 R09: 00000000aed806e6 [ 110.639719] R10: 0000000000000001 R11: 0000000000000000 R12: ff11000ff85fe140 [ 110.641185] R13: 0000000000000000 R14: ff11000102373e88 R15: 0000000000000022 [ 110.642688] FS: 00007f698e381780(0000) GS:ff110010711ac000(0000) knlGS:0000000000000000 [ 110.644359] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 110.645255] CR2: 0000000000000014 CR3: 00000001044c1001 CR4: 0000000000371ef0 [ 110.646366] Call Trace: [ 110.646781] [ 110.647123] ? sched_clock+0x10/0x30 [ 110.647704] __schedule+0x1a4/0x7c0 [ 110.648249] ? local_clock_noinstr+0xd/0xc0 [ 110.648914] preempt_schedule+0x37/0x50 [ 110.649528] preempt_schedule_thunk+0x16/0x30 [ 110.650217] _raw_spin_unlock+0x37/0x40 [ 110.650833] wp_page_copy+0x2b7/0x5f0 [ 110.651408] __handle_mm_fault+0x45f/0x6e0 [ 110.652068] handle_mm_fault+0x96/0x250 [ 110.652685] do_user_addr_fault+0x236/0x6a0 [ 110.653333] exc_page_fault+0x7a/0x210 [ 110.653937] asm_exc_page_fault+0x26/0x30 [ 110.654577] RIP: 0033:0x7f698e3a1f84 [ 110.655077] Code: 8d 3d e0 d4 1c 00 e9 0b 15 05 00 0f 1f 00 48 89 7d f8 48 8d 3d cd d4 1c 00 e8 38 14 05 00 48 8b 55 f8 eb 8c 66 90 f3 0f 1e fa 05 b2 d4 1c 00 00 00 00 00 c3 90 f3 0f 1e fa 31 c9 e9 65 f9 ff [ 110.657442] RSP: 002b:00007fff9a5ff9e8 EFLAGS: 00010246 [ 110.658113] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 00007f698e443f63 [ 110.659037] RDX: 0000000000000000 RSI: 0000000000000018 RDI: 00007f698e381a60 [ 110.659973] RBP: 00007fff9a5ffa10 R08: 0000000000000000 R09: 000000000000000f [ 110.660896] R10: 00007f698e381a50 R11: 0000000000000246 R12: 0000000000000000 [ 110.661829] R13: 00000000ffffffff R14: 0000000000000000 R15: 00007fff9a5ffc20 [ 110.662745] [ 110.663040] Modules linked in: [ 110.663451] CR2: 0000000000000014 [ 110.663893] ---[ end trace 0000000000000000 ]--- [ 110.664487] RIP: 0010:pick_next_task+0x42b/0xa20 [ 110.665090] Code: 28 60 00 49 89 c7 8b 05 b3 8d 73 05 41 39 c7 0f 83 c3 01 00 00 49 63 cf 48 8b 1c cd 80 7b 96 82 48 01 eb 48 8b b3 50 0f 00 00 <8b> 4e 14 48 8b 0c cd 80 7b 96 82 48 8b 4c 29 20 48 39 ce 74 32 48 [ 110.667457] RSP: 0000:ffa000000435bc48 EFLAGS: 00010083 [ 110.668146] RAX: 0000000000000040 RBX: ff11000ff85fe140 RCX: 0000000000000022 [ 110.669074] RDX: 0000000000000022 RSI: 0000000000000000 RDI: ff110001008b54d8 [ 110.670009] RBP: ffffffff87452140 R08: 0000000000000022 R09: 00000000aed806e6 [ 110.670942] R10: 0000000000000001 R11: 0000000000000000 R12: ff11000ff85fe140 [ 110.671861] R13: 0000000000000000 R14: ff11000102373e88 R15: 0000000000000022 [ 110.672787] FS: 00007f698e381780(0000) GS:ff110010711ac000(0000) knlGS:0000000000000000 [ 110.673826] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 110.674567] CR2: 0000000000000014 CR3: 00000001044c1001 CR4: 0000000000371ef0 [ 110.675487] Kernel panic - not syncing: Fatal exception [ 111.737349] Shutting down cpus with NMI [ 111.738019] Kernel Offset: disabled [ 111.738373] Rebooting in 30 seconds.. $ ./scripts/faddr2line ../obj/guest/vmlinux pick_next_task+0x42b pick_next_task+0x42b/0xa20: task_cpu at include/linux/sched.h:2270 (inlined by) is_task_rq_idle at kernel/sched/core.c:6144 (inlined by) cookie_equals at kernel/sched/core.c:6149 (inlined by) pick_next_task at kernel/sched/core.c:6328 This is the cookie_equals(p, cookie) in pick_next_task(). Assume cpuX and cpuY are siblings, it appears the following happened: cpuX cpuY pick_next_task() goto restart_multi rqX->core_pick = pick_task(rqX) pick_task(rqY) pick_task_fair(rqY) sched_balance_newidle(rqY) raw_spin_rq_unlock(rqY) // drops core lock pick_next_task() goto restart_multi rqY->core_pick = pick_task(rqY) rqX->core_pick = pick_task(rqX) if (rqX->curr == rqX->core_pick) rqX->core_pick = NULL UNLOCK rq_lockp(rqY) raw_spin_rq_lock(rqY) rqY->core_pick = pick_task(rqY) p = rqX->core_pick // NULL cookie_equals(p, cookie) // NULL deref BTW, I applied this series on top of commit c095741713d1b("sched/fair: Fix newidle vs core-sched") of the queue/sched/core branch.