From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 1FA1B377016 for ; Tue, 28 Jul 2026 08:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785228799; cv=none; b=L4JhDXu1VIQke8n4lj7b91gqxwElIYBG99bDJGTQqUGmqC/4BmidIzehYvLAAeX81BfX2HGAZqBec7LX/EKiXqiXFkQFtXCmk1tP/a870IcNFRcRNf+pwkSih2T5lZxlZO/XdWgl0b0/hWtfCC+j8SOPFFs//k/2fYkvHPOd3/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785228799; c=relaxed/simple; bh=bAbI7oJDGz8+AkCxwI2+DKJktxn7Uk19TEkfU3/fUhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EWptUf+MP8DuGjjMBv637R05SF0t7S11azW0BQ61MYfzJmWqwMH4gECDmOeAH/eudIJc2Nsoz9nUczbBwSJXPZnjrndjQE/kW/MMjX7HJGHTX7uygYyxXiFXu+i4bUd3vBmYdXYsqujCQDU6HhNk51OeJffeLiqrvS78beJGLR8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=dYc+xppB; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="dYc+xppB" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785228794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bAbI7oJDGz8+AkCxwI2+DKJktxn7Uk19TEkfU3/fUhs=; b=dYc+xppBdBiV6YZad+9fwjgJd8Y/NMAfyNlUeQ6WMzzZbZqhXVct+SDREyOb0y7TXHf0KR YjTiFGww6+NY/6sWawBwUVZDSsWPrnJT7VufcSBGoog+Ig7MDb2ou319UAagEBoHS5ivCu 2R5J+a0FB1Rdw7wbOi+b56yGuXA76Y8= From: Tao Cui To: guopeng.zhang@linux.dev Cc: akpm@linux-foundation.org, bsegall@google.com, dietmar.eggemann@arm.com, hannes@cmpxchg.org, juri.lelli@redhat.com, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, surenb@google.com, vincent.guittot@linaro.org, vschneid@redhat.com, cui.tao@linux.dev, Tao Cui Subject: Re: [PATCH 2/2] sched/psi: Fix overflow in trigger time conversion on 32-bit Date: Tue, 28 Jul 2026 16:52:55 +0800 Message-ID: <20260728085255.2366221-1-cui.tao@linux.dev> In-Reply-To: <20260717102824.985950-3-guopeng.zhang@linux.dev> References: <20260717102824.985950-3-guopeng.zhang@linux.dev> 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=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Tao Cui On Fri, Jul 17, 2026 at 3:29 AM Guopeng Zhang wrote: > > From: Guopeng Zhang > > threshold_us and window_us are u32, while NSEC_PER_USEC is 1000L. On > 32-bit architectures, multiplication by NSEC_PER_USEC is evaluated > using 32-bit unsigned arithmetic and can wrap before the result is > assigned to the u64 trigger fields. > > For a valid 4,000,000 us threshold and 6,000,000 us window, the > threshold is stored as 4,000,000,000 ns, while the window wraps to > 1,705,032,704 ns. The stored window is therefore shorter than the > threshold, so the trigger no longer monitors the requested 4-second > threshold over a 6-second window. > > Cast both values to u64 before the multiplication so that the > conversion to nanoseconds is performed using 64-bit arithmetic. > > Fixes: 0e94682b73bf ("psi: introduce psi monitor") > Signed-off-by: Guopeng Zhang Acked-by: Tao Cui