From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 3E143175A68 for ; Sat, 20 Jun 2026 04:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781929182; cv=none; b=SaKhXbLUfw0Oh6C31A6ZhCbzcaIH6fe/nh6QdYSxaHEhpEmq7+wQXLpAJjYigT1zNeje0/7Ci0ZdCywwFLn+XP0VJUfn2pGDnS7rUwjL9x0plILA5WuwL6fmWuS+SD050Nn5X+vPl7J1wtyofepKlcbATKsiWGYgluA2qeU3EBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781929182; c=relaxed/simple; bh=DM7HPBc30Fj6X8Ldr/uRFlaK2yGgK7jG77J43rw8+jQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jS6+7rX1gRmFyf1INnFbC/46L69k1rcTFSAR0UA4z4wEY6kOpG4BX5QvLwFl96utwRDZx+1jyaAHI6O68jNoRRtllLKXYRfFR7dZIGVRoBPKVvrP2Ml8yrHlNKAkuoyOYR3X6I4hlJWUJAvFciiKrDGktLATU0gGQ7aio9Nu8pM= 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=rs3TyiHU; arc=none smtp.client-ip=91.218.175.188 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="rs3TyiHU" Date: Fri, 19 Jun 2026 21:19:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781929177; 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: in-reply-to:in-reply-to:references:references; bh=RCMktU8ssVVWOY8171eAKFdomK30x6Xys+dZdEKy3kk=; b=rs3TyiHUwzmV+mSY3Juav6ERZqjnkQ7s0twtXpeo6AkiJxJd5Cen4QyBUq+Q2T297v26H4 wjM5JVyUUiTUr5p1cM97gbQe4rHPsa1mKNls0hZMYs3totBHk06jGHc7Jy0TPwbZXX6fva rwRuHK9XIaWdreDOS2WQD2czLzr8RpY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Usama Arif Cc: Andrew Morton , david@kernel.org, linux-mm@kvack.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, riel@surriel.com, kernel-team@meta.com Subject: Re: [PATCH 1/1] sched/psi: skip irqtime accounting when no new irq time has elapsed Message-ID: References: <20260617175219.2494857-1-usama.arif@linux.dev> <20260617175219.2494857-2-usama.arif@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=us-ascii Content-Disposition: inline In-Reply-To: <20260617175219.2494857-2-usama.arif@linux.dev> X-Migadu-Flow: FLOW_OUT On Wed, Jun 17, 2026 at 10:50:06AM -0700, Usama Arif wrote: > psi_account_irqtime() reads irq_time_read() into a per-rq cumulative > counter and only bails out when the delta vs. the previously accounted > amount is negative. A delta of exactly zero is treated as "do the > work": psi_write_begin() is taken, cpu_clock(cpu) is read (which on > x86 ends up in native_sched_clock() / rdtsc) and the cgroup ancestor > chain is walked to add zero to every group's PSI_IRQ_FULL bucket. > > The zero-delta case is common in practice -- it fires every time a > context switch crosses a PSI group boundary on a CPU that hasn't > serviced an interrupt between the two switches. > > Measured on a 176-thread AMD EPYC 9D64 server running a compute > intensive production workload, instrumented with bpftrace over a 30s > window (irq_time_read() read directly from the per-CPU cpu_irqtime so > that delta == 0 and delta < 0 could be separated): > > @total 17,229,311 (100.0%) > @ret_curr_swapper 7,864,195 ( 45.6%) curr->pid == 0 > @ret_samegrp 323,299 ( 1.9%) same cgroup as prev > @reached_delta 9,041,817 ( 52.5%) > @delta_positive 6,358,192 ( 36.9%) real work > @delta_zero 2,683,625 ( 15.6%) work wasted (this patch) > @delta_negative (0) ( 0.0%) monotonic clock > > So 15.6 % of all psi_account_irqtime() calls - and 29.7 % of the > calls that get past the early returns - hit the delta == 0 case; > delta < 0 did not occur once in the 30 s window. Under the current > code each of those ~89 k calls per second performs the full seqcount > write + cpu_clock() read + cgroup-chain walk just to add 0 to every > group's PSI_IRQ_FULL counter. > > Extend the early-return to also cover delta == 0. rq->psi_irq_time > does not need updating in that case (it would store the same value > back) and no PSI bucket would change. The existing behaviour for > delta > 0 is untouched. > > Signed-off-by: Usama Arif Reviewed-by: Shakeel Butt