From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 5D1B23E7BB6 for ; Mon, 13 Jul 2026 10:51:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939891; cv=none; b=Y/Ny3u8RxJndm3vK91BnG/SivtSx+wlQtR88Bk1CpDc4Ek6+ikdDIT2wSmf+gLr5Wy79BQsTGnkJU/fxBTjh5yRg8+JFGmTtOrTmzCvjWaSDmXe1hWUprbqxCDHvjbz6GYwESkv98aG/PnbAOGF/a7AMuKL7nkpUXssK3ZAYKc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939891; c=relaxed/simple; bh=z11t9LwXEAps95nmJFn9bgrfWgmUbK8OsamIUC9xo1A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RW3YUoQ9+baG5FB1ebBvAu/bUMS91xUF2BpX9iSLO7a4f7o3TDd5codOKZiUOXHk8whDRXIToXJoLX8fR/mIPQQnHEgtV/ILbVdePbIyIa0dWnM2SUHSNObCZzLuiglTsE12upQCE87DYE6GXJrKnp5ILIDp3ApP7A/o53byRWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=JPVlFIdy; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="JPVlFIdy" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-493c7902f47so27742045e9.1 for ; Mon, 13 Jul 2026 03:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1783939886; x=1784544686; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=0xXW5DaPK6zTkeDY542N1FQHx5XzZ6y+YRGl+QSs6T8=; b=JPVlFIdyMwRdVhC86ydqr99/64xCRL6D6aF7eae8LtLF9rc06YsiWrtdCA6PObfymd 3/iU7jvxeokSR0uG0D5kNWpUvJbKcYUgyzH971ynv8JdInuUHCC0bQRP+EH77UqyPLZt QCD0dX99TjviXX/e2LpI02dPhqLtVEwkJP8OMpRFTXpGek+0t/MceBgJ0OJB73KWgx3d qkEO8VFFRzJ97pHa2OCT7TnGdGAxFpPzTQZvw9a1Ycgni+XHAUtcJdTVbP2A8hjEwFFM d9N5tL+VwXNiTEbRZsNT9fODiW4YSz7GH8gqHcNZJRkbjMjKTC5cI+kWcNrEOE6OUQH0 LFBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783939886; x=1784544686; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=0xXW5DaPK6zTkeDY542N1FQHx5XzZ6y+YRGl+QSs6T8=; b=Sr2udY6NI4PFH0En7piRm+qfI7JAeq64qT1AWFFiYA4HzAiPEsocjNfCUjJZCxC1Fo yNpWfBMGoc7O+ciCFtkYSFJecesdUXYxV1z1M9+Eucvgw5YULsSuPPVKyWtNXQchcEAz 2z4TY9l21oq/x1Ervw3tzXDwyKRplvVocLFFCzdo5iba8NBZq3YcRN1AD7apsP5TQcSK BVNRJdkfmlS6h8s4aqf/jamGRymKRnCvYEfJq034rWWgtBTOwOwSOk/4GxKMijExL8OU IrWTibzsz9kbvu15h6XRWaFga/ES4A4PlvojmAsPjTpmJUwBwQ/aX4W5CO0uvh+C33G/ gjIA== X-Forwarded-Encrypted: i=1; AHgh+RqiaZyhdsWKgT+BDWJ3udU94sQAbdYPyWPGzKEws6b5++9YtQ49j1x/yWK6dSmwkd3V+oJ1B/eJg5LldJo=@vger.kernel.org X-Gm-Message-State: AOJu0YwI6fCAsjpnBG9jU91F+R/Kj/b1rHK7A+Tj2uGxMQ4tW1CDboyu 3XO/KpdvU8i/ZKE5H7Bs7nLhSDxieo2FzFci1s1C8g9VrqpAx8kKhpxmrWy+au/DHOI= X-Gm-Gg: AfdE7ckmMCw6D4mZL69e7pcCCGSzJsI2BkLt+KUOw/rbOizO9To8aXYRur6DsRfB2G6 /yOLJ5zpukU/jUxJXo3I6IJdjQEQBk9r/SW4qYam6oGhNtIUFVMHRbS+hdTD8KqGbBWJYRtnrqF g9ZoMdm6V5jPyYDHfLMYGJuJhP6RaYq/ltFPmTc5TkhuSoRbmSp7+fhLkNlo/dkEeNcS4fU7Ggn GlITFtIXt660dWyUT1YGTjF5dFGCwn4aQ84J5chgcW+H5WLWkgKk1KAvYzHh//i+FhgpFHXnBTi /no7Y3eKwTBnXlnx+WUJNn3CvhYT8k3bH0L7Y85yLsENU23ji8TkMgwSN8Np9Sx7xccQfRnFPKu 7zCi2RDekUfKgcAWckF3EDVzZteyAB0kpddlJpUZTdLZhwri7hc+DUXiOADPLNGJZj3DksnR1o5 pp14DsZkC0jQ== X-Received: by 2002:a05:600c:1906:b0:493:c8a6:b517 with SMTP id 5b1f17b1804b1-493f883b7e8mr84731245e9.38.1783939886273; Mon, 13 Jul 2026 03:51:26 -0700 (PDT) Received: from localhost ([2a02:8071:6401:180:d892:bf43:a0b4:83b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493eb6f3b85sm573716585e9.2.2026.07.13.03.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 03:51:25 -0700 (PDT) Date: Mon, 13 Jul 2026 06:51:23 -0400 From: Johannes Weiner To: Tejun Heo Cc: Matt Fleming , David Vernet , Andrea Righi , Changwoo Min , Suren Baghdasaryan , Peter Zijlstra , Edward Adam Davis , Chen Ridong , Zhaoyang Huang , "ziwei . dai" , "ke . wang" , Matt Fleming , sched-ext@lists.linux.dev, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@cloudflare.com Subject: Re: [PATCH 1/2] sched/psi: Create the psimon kthread outside of cgroup_mutex Message-ID: <20260713105123.GB276793@cmpxchg.org> References: <20260712174619.3553231-1-tj@kernel.org> <20260712174619.3553231-2-tj@kernel.org> 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: <20260712174619.3553231-2-tj@kernel.org> On Sun, Jul 12, 2026 at 07:46:18AM -1000, Tejun Heo wrote: > a5b98009f16d ("sched/psi: fix race between file release and pressure write") > made pressure_write() hold cgroup_mutex across psi_trigger_create(), which > forks the psimon kthread for the first rtpoll trigger. As kthread creation > depends on the whole fork path, the commit inadvertently created a lot of > unwanted locking dependencies from cgroup_mutex. > > sched_ext got hit by one: its enable path blocks forks and then grabs > cgroup_mutex, so a pressure write racing a scheduler enable deadlocks, with > every other fork piling up behind. > > Fix it by splitting trigger creation so that the worker is forked with > cgroup_mutex dropped and the kernfs active reference left broken. The latter > matters because rmdir and cgroup.pressure writes drain active references > under cgroup_mutex. Publishing the trigger last keeps error reporting > synchronous and preserves the of->priv lifetime rules. > > The trigger registered in the first stage pins the group's rtpoll machinery > across the unlocked window, leaving only creation races to resolve. The > catch-up poll on installation covers scheduling attempts dropped while there > was no worker. > > v2: Retagged sched/psi (was cgroup). > > Fixes: a5b98009f16d ("sched/psi: fix race between file release and pressure write") > Cc: stable@vger.kernel.org > Cc: Johannes Weiner > Cc: Edward Adam Davis > Cc: Chen Ridong > Reported-by: Matt Fleming > Closes: https://lore.kernel.org/all/20260710100441.2653477-1-matt@readmodwrite.com/ > Signed-off-by: Tejun Heo Acked-by: Johannes Weiner