From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 89AFC18B467 for ; Mon, 27 Jan 2025 18:33:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738002788; cv=none; b=h/dgIn8wTIglsc4elYRIO9qsu2w5Xx6WJqMfbIc1I2ZOi9OrFYqzSaYUFdEBSh1/ereMF+XeM7Jbi6CqJMTJAzPCpCuYxSf6HzV/cLO/mG1QPV9CVdRvtt0f/l9AY75+7ixqTcR6Nng2sfPuR6Ez9FteLhR58Lu1LAH2YvWgWhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738002788; c=relaxed/simple; bh=7j2yQdPLFbg8z2XR+7+OIUOiwjIqLYJvqHQbLP9x19g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DyxZ8C/o36cZlIGdnLkD/wlIlaazgeTl3XRW5oljX05rUoHSaHYt1F80KlsMQSvjc+juPHxKE2jviinWkdDniRS0Me8tRbMZZDsQ5qw6+kccdXbudDVy8hovQrdmIeMHOwMMXJag7SnR4OAjTQfYGAy4TqofnbtxSEria90K4m8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ssg+tWx4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ssg+tWx4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD0B0C4CEE0; Mon, 27 Jan 2025 18:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738002788; bh=7j2yQdPLFbg8z2XR+7+OIUOiwjIqLYJvqHQbLP9x19g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ssg+tWx4cR9pjwzOwahuV/tE+j+nE8hLAFD2Jqo7g1ODVguAw48hCbMUla9C5AaCd SQsSNs+c4pJUMrXIN00LbSwm0ohIHNoPVRl0UnNY1vC922wrMDWPrNnqqIrXpg5sKx cLPGuxY/CUymClKD9em89RFm/NzAkXwqaqM9NUdIfwdC3EEFJQCc1iWao8Ct58oIbz U+BuBrH3N9MV/cZRgVu2NBM5xeKyyclaRQwXsqY/tA+EN/6Q06Xc3YbFashu9I8Fpx qgRWVuhalIobSHPdI5M1L1oWbKlZyCI2I9DaVCnHR5oYkOI+RtCD3WXidMnTx08IeB UjCfzF60IwgTg== Date: Mon, 27 Jan 2025 08:33:06 -1000 From: Tejun Heo To: Peter Zijlstra 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: 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 Applied to sched_ext/for-6.14-fixes. Thanks. -- tejun