From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA0F025A646 for ; Mon, 27 Jan 2025 11:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737977104; cv=none; b=Rh+xHgKv05CpPXHmm4Qp2O2s6j8ixew4pj2TmX7kZGriEIAHUWxYeMGZvXEQolVCAMFQ6VU5CmERV6VvdU9Ymg6EKsXeZZFz/jbwPVV9D1462piaq0geZRtCNHZox85VdQ21IQ5sJ1gDEDy/uX8FMlm52DvWU9yf41MDtOrG/tg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737977104; c=relaxed/simple; bh=C2bJHJtJJQPwdoq9X/daDnW1s3xSWL/jcqjrXz2CX2A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DPwYWAnKdGftYEAGSu2P83UbHjudowFxaT/8OHbKTi02Ft1iuFmwhlMUMahpMyHWOHTwhDgBgiZYO9X10HhW3q5Oht7qKTeSZIwsRJOXcIVkTuN8mF3xBuc9OUp8hYrOAebAYITTb/7cB28OvE3pURv9KpkBAOLcDkCiZqda15Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=qm3qXtGj; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qm3qXtGj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DiAt7SVGoxadKO1iGAixQXY1GS106OO3xLOMlLV55CE=; b=qm3qXtGjiC5NsqnnshL4avMjzR BcX+K2u+SjZ59wtmXg3DVLq2qXAVheS/W6F2+iqXgqEafj06Jgf/MXnI5v1u+ZY75dH11nj53VDij q2a/GVtwtO6Hz7JS+xEoBz5pKjY5Sb76t7catV0xywi5dLlEUVvXXCaW5pNxQ2JuAGuWlkP/I95a6 qlykt/smu2bwOOp5Eslub6iwLQ+ZslCekOO5EX5L0XuTd7ettBxAhvGV0ltVuNMotsbY+VArzxVHP e7XdgmZepPs1UJhTZJG2ayjPMj31BhEam6veital1alYYip3AK6sOpCnN+zIzNxccSRmXWe/JRTXX Eqx6Cjgw==; Received: from 77-249-17-89.cable.dynamic.v4.ziggo.nl ([77.249.17.89] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tcNEe-00000009KSa-2Lcp; Mon, 27 Jan 2025 11:24:56 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 244C03004DE; Mon, 27 Jan 2025 12:24:56 +0100 (CET) Date: Mon, 27 Jan 2025 12:24:55 +0100 From: Peter Zijlstra To: Tejun Heo Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, sched-ext@meta.com, David Vernet , Andrea Righi , Changwoo Min Subject: Re: [PATCH sched_ext/for-6.14-fixes] sched_ext: Fix incorrect autogroup migration detection Message-ID: <20250127112455.GG16742@noisy.programming.kicks-ass.net> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jan 24, 2025 at 12:22:12PM -1000, Tejun Heo wrote: > scx_move_task() is called from sched_move_task() and tells the BPF scheduler > that cgroup migration is being committed. sched_move_task() is used by both > cgroup and autogroup migrations and scx_move_task() tried to filter out > autogroup migrations by testing the destination cgroup and PF_EXITING but > this is not enough. In fact, without explicitly tagging the thread which is > doing the cgroup migration, there is no good way to tell apart > scx_move_task() invocations for racing migration to the root cgroup and an > autogroup migration. > > This led to scx_move_task() incorrectly ignoring a migration from non-root > cgroup to an autogroup of the root cgroup triggering the following warning: > > WARNING: CPU: 7 PID: 1 at kernel/sched/ext.c:3725 scx_cgroup_can_attach+0x196/0x340 > ... > Call Trace: > > cgroup_migrate_execute+0x5b1/0x700 > cgroup_attach_task+0x296/0x400 > __cgroup_procs_write+0x128/0x140 > cgroup_procs_write+0x17/0x30 > kernfs_fop_write_iter+0x141/0x1f0 > vfs_write+0x31d/0x4a0 > __x64_sys_write+0x72/0xf0 > do_syscall_64+0x82/0x160 > entry_SYSCALL_64_after_hwframe+0x76/0x7e > > Fix it by adding an argument to sched_move_task() that indicates whether the > moving is for a cgroup or autogroup migration. After the change, > scx_move_task() is called only for cgroup migrations and renamed to > scx_cgroup_move_task(). > > Link: https://github.com/sched-ext/scx/issues/370 > Fixes: 819513666966 ("sched_ext: Add cgroup support") > Cc: stable@vger.kernel.org # v6.12+ > Signed-off-by: Tejun Heo > --- > Peter, I can also flag the task that's doing the cgroup migration but that > seems unnecessarily convoluted. If you're okay with the change, I'll route > this through the sched_ext tree. ACK, Thanks!