From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 1E208431496 for ; Mon, 13 Jul 2026 13:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783950538; cv=none; b=Orc8y/RH1oDi2rNdCcS5uNgCOhYKzaHivSbzidY6ZUinoLozZzREiBN2Ueuw6tv6ezzT1fYeJyHR03HVpYR5FMqFoKn8L3Oe8drni3mx7BjNgSBBwMwgsUhvqeaitv4b6m91Tq+69PJ5sp1gtX8U7K0CoC+ZOgWModXdCpdUI7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783950538; c=relaxed/simple; bh=+UeBgr/3oETL59f/IS+j1IQ/p/NMk8/4+wpi5kr0WO4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lgiresdCEqKzanjAgtPEmepXptBc66vcOorjvIwkS3RwgE1StQIQ24GUZ8oqJO69IPD+OQE2NG508uhruxU+DxvIcYKSOaQDQng3/3YOlLAORG6fM2SrG1I9h5kXHtkiEPceLDV8FASm/rV0o2XSvHZKjaYKhCiTXC8zlrABCMU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=readmodwrite.com; spf=none smtp.mailfrom=readmodwrite.com; dkim=pass (2048-bit key) header.d=readmodwrite-com.20251104.gappssmtp.com header.i=@readmodwrite-com.20251104.gappssmtp.com header.b=puJYv+lx; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=readmodwrite.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=readmodwrite.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=readmodwrite-com.20251104.gappssmtp.com header.i=@readmodwrite-com.20251104.gappssmtp.com header.b="puJYv+lx" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-697cee2eb6dso3217367a12.0 for ; Mon, 13 Jul 2026 06:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=readmodwrite-com.20251104.gappssmtp.com; s=20251104; t=1783950535; x=1784555335; 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=eXn5kMcR5nKmIutY68IqK6aV4F4qyXcvYDJKsjI+c7U=; b=puJYv+lx0ircsYqjjtqYeKjjw3QaB8Ldy/O5KFhnEca2DiViLJlPsx9UDI4miuUG9n n1+HQjhV74UP2dhs4ePnJe8UX6IVh70nwxDAEKfqrVYIDdPi4PqpOrlAdH2Gq5Bz9gdo NRznjSnLCdHGDx5eGLpdyFrNZeQQFHzvNLqAXS9DaNei2M1ImakCC8t4nAzAtGAvvYhx xh/55TQvrD1hLTXBRHUPEanyAT7zt9DlAMVLMT6iQVOdxx8tkMGT42gtMZpNYVDH+1Jr T2wXmvkCacsny0KvtSvo4RK5w10JL/S4U43KVV6OyyiP+JS6i6PhaeUQiGf4opnIxe/Z hOyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783950535; x=1784555335; 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=eXn5kMcR5nKmIutY68IqK6aV4F4qyXcvYDJKsjI+c7U=; b=PMIe5rc4co6YqWubseCMTmpa2gsoeprsd5zqYhLi27zf5eC1vv0OI1OCw1Og8wcUtG s0/NA26wNP7S96cLLNDyRUL1yAh4vdRJ2DAcxECVanIt7Xw6bRz7ZqsQG5p81A0hA5o3 6FMUhoNircxq49Cbaf3L11rOk5OEAcMd7I4rZhrrJmFvIiWUx7LLNRfTcbuGY1fYa/2P mMLv1t9biFyvmwtHic4sIlFnmnjDza1itSitN7YCyvCxnQR0hVU/UvfuH9JiBYOp2aIa LPQ4+bS4x3FXIfeJA7YOqoF439hcQOj3X2/xFub3tIOyVh/csYNKQon4Gm9W7+tXZcTI oDVg== X-Forwarded-Encrypted: i=1; AHgh+Rr0LD+S5IgcXoUpJANSxqhLudQ1fXRay1WVQm7NFaPybDqwx1Oo6lq7tcMoU6FkQ2FmNCPFlZcqUGaC1OQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzVwDsoEUUMPyCqJN6WHu4Q0hcCunM5XSNHZopXQ1458oaFzpn1 Mh+y72X1FLfREeJcCjQz5VyfbHAK88rYalTxb48zAA8Y1WQTcS7fjNiEI4Rv52aR1Fk= X-Gm-Gg: AfdE7cmpTHZ4Z/3xHYjARoaSPhISCad/TMS+r+G5ruPtDf/nNSd4Msq4Cl3tx5nQMkg 7906t2+prN3oLvNA/YCef7k8QsPjLGZTRCRSuigiAc+Y/Ts6cOs/UIGiWOweGFgd7ovvKOMpZwH 0DIT4wNTNcIBjBTWIpwR3BkM75mAsnYQxYQd/VL8O2ZIsrs4i01GiUrChAMEJ+Y90VdEY5IGCO3 9hukeMKRTks9f4ZckQ4Pc46+K0rgd9ACoNog0eYcw+4jaswSGYZkeGp2XcGRJSbKxMJJ1p7O6LP Wl1+bx2WGdpIL20t7c9vFy0dEDfRrO01eJnZG6xWGCBt62lORiRhxz/gTgHQ47u1hWd4oGDR3TE ni772y+6aIutymXdJ9+RqMHmUzTqlu1VD9nUG+5RKhJUO5obBhp3GL3mBhb4owhS99T0E5C5zRK c0 X-Received: by 2002:a05:6402:3512:b0:699:6415:750a with SMTP id 4fb4d7f45d1cf-69c5f12197cmr3696963a12.23.1783950535377; Mon, 13 Jul 2026 06:48:55 -0700 (PDT) Received: from localhost ([2a09:bac6:37a8:1f19::319:116]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-69a19d78a08sm16555473a12.18.2026.07.13.06.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 06:48:54 -0700 (PDT) Date: Mon, 13 Jul 2026 14:48:54 +0100 From: Matt Fleming To: Tejun Heo Cc: David Vernet , Andrea Righi , Changwoo Min , Johannes Weiner , 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, Sashiko AI Subject: Re: [PATCH 2/2] sched/psi: Shut down rtpoll_timer in psi_cgroup_free() Message-ID: References: <20260712174619.3553231-1-tj@kernel.org> <20260712174619.3553231-3-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-3-tj@kernel.org> On Sun, Jul 12, 2026 at 07:46:19AM -1000, Tejun Heo wrote: > psi_schedule_rtpoll_work() is called locklessly from the scheduler hotpath > and can race psi_trigger_destroy() taking down the last rtpoll trigger under > rtpoll_trigger_lock: > > psi_schedule_rtpoll_work() psi_trigger_destroy() > > rcu_read_lock(); > task = rcu_dereference(rtpoll_task); > rcu_assign_pointer(rtpoll_task, NULL); > timer_delete(&rtpoll_timer); > mod_timer(&rtpoll_timer, ...); > rcu_read_unlock(); > synchronize_rcu(); > kthread_stop(task_to_destroy); > > The group can then be freed with the re-armed timer still pending, and > poll_timer_fn() runs on freed memory. > > 461daba06bdc ("psi: eliminate kthread_worker from psi trigger scheduling > mechanism") deleted the timer synchronously after the synchronize_rcu(), > which prevented this but raced trigger creation instead: the deletion could > cancel the timer that a new trigger set armed during the grace period and, > as creation also reinitialized the timer at the time, corrupt it. > 8f91efd870ea ("psi: Fix race between psi_trigger_create/destroy") moved the > initialization into group_init() and the deletion into the locked section, > trading the creation races for the window above. > > Neither placement in the destruction path works. A pending timer firing > while the group is alive is harmless though. poll_timer_fn() just wakes the > rtpoll waitqueue and doesn't re-arm itself. Bind the timer to the group's > lifetime instead and shut it down in psi_cgroup_free(). Nothing can arm it > by then. timer_shutdown_sync() because the timer is never armed again. > > Fixes: 8f91efd870ea ("psi: Fix race between psi_trigger_create/destroy") > Cc: stable@vger.kernel.org # v5.10+ > Reported-by: Sashiko AI > Closes: https://lore.kernel.org/all/20260711000434.36C4A1F000E9@smtp.kernel.org/ > Signed-off-by: Tejun Heo > --- > kernel/sched/psi.c | 6 ++++++ > 1 file changed, 6 insertions(+) Tested-by: Matt Fleming