From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 909163002D7 for ; Fri, 28 Nov 2025 10:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764324505; cv=none; b=izvg176pSkxr6AvxCSnfREpB89WgE2Z4mA2g8vIDL7y5X23xRp5IYa4q4srxMMLF60Xjot+LYiU3UTRx40P/qZT8DpCoT387CcpZ6IFk2LWGPPr+DCUkzxII8P2PVGzi9T40oIUE72MGhjToK1xNEgbRM0KzodXEuJvv/Ky/t1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764324505; c=relaxed/simple; bh=wViTBQb5yijMyxi1Vciad7w2uzQaqvULc+dNKv/IGlE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lXQgfqCyO/hdaUPvU6bp2lwG5nUDYpcgj/8bzDv5vP0xNzHvNGp+O7TQNTWV218pkV9VbvzGEoSokl01Wy/+f26GphQPAgdrmmKa1cw422bNfKPpDTeGMoi3kzJWO9LXK5e1ef1DI5YhW4wWarlgZK1l1+CAyTKe3Nl1Q1ubmjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=MR9O0hK0; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="MR9O0hK0" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AS9otMJ007359; Fri, 28 Nov 2025 10:08:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=JhJHS9 dOGRmlM9lyqJm2DKTLxfH6oKNMN+iqSdsANUA=; b=MR9O0hK0vd4Y7b56Lbq7tY 4S9jhbVQldHl5iVtVa+8rVD3eBMGdS96Y+f8mUq0DcBHCKhkWp56OKEeHbPKoVtP 61yNVfZz4ObNKtfYAUD1bY9iS0PJZNNN+3xK3VWK7Ui9KRf5taZiPLFbJW4ymKv+ 5712gi1c7hUAG++R7QtUQEkagQJsDVCzByQrFA0R3k/xXducRRZzlZOkkDfO2WnI YWfsXM2BgJajM7GAPI9kFqVmaJVY1RlpkZjeIgRpS2eDMtjRqIZe4qOzawHh4EBo 1koEkABEL6AXH9oG74eLy9x13IJaysHQ3g3RTkNWa6BB8UOawcLfDYUgV8OWJ+UQ == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4ak2kqcbwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Nov 2025 10:08:01 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5ASA80uF028777; Fri, 28 Nov 2025 10:08:00 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4ak2kqcbwe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Nov 2025 10:08:00 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5AS7uvbA000831; Fri, 28 Nov 2025 10:08:00 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4akqvycgbd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Nov 2025 10:07:59 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5ASA7xeu31654428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Nov 2025 10:07:59 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B73658059; Fri, 28 Nov 2025 10:07:59 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AEA058055; Fri, 28 Nov 2025 10:07:48 +0000 (GMT) Received: from [9.43.31.220] (unknown [9.43.31.220]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 28 Nov 2025 10:07:47 +0000 (GMT) Message-ID: <1b0facef-8d3c-45fa-a490-506204e1395d@linux.ibm.com> Date: Fri, 28 Nov 2025 15:37:44 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/2] sched/fair: set rq->idle_stamp at the end of the sched_balance_newidle To: Huang Shijie Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, patches@amperecomputing.com, cl@linux.com, Shubhang@os.amperecomputing.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org, vschneid@redhat.com, kprateek.nayak@amd.com, Madadi Vineeth Reddy References: <20251128075454.676765-1-shijie@os.amperecomputing.com> <20251128075454.676765-2-shijie@os.amperecomputing.com> Content-Language: en-US From: Madadi Vineeth Reddy In-Reply-To: <20251128075454.676765-2-shijie@os.amperecomputing.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIyMDAwMCBTYWx0ZWRfX/Avj55i2WagN wW2ldIYlsF2jYUI5R0xIHHXWjTkmspoiSpMwDlYoD1CNuGHDXN5G/3OSlAyO4O0ikostPlRct+0 0OY/aul+QVdlWx8i9cWipnJvGSjiJkEtzCxoliyPno6juyouEXIEI4Q1bzAzSelt3EE09JC/yxl 03eltMTsScLf7eJ6tujzwklCA/lOChW3sTFcdOEyH7pMs07+lQx8H1pkyfEFp1IsNxBOEKY0eEH pIo2vP1gL7jhJNQADp1Hu5MXh6jg7nFV+c54WbEop+jHK8Co9AbmVWx3WXiuwL7bCZ2NYz0i2eA a3ypIhQ0h98DtlfPCkWLWAxj9nHNwoeCzz1R7wzYtoRk5K/v402hNncOK5+kHcmae1Ve0iytpjl SGgdGLXAJtx4IRpeRWJTSh2D5itddQ== X-Authority-Analysis: v=2.4 cv=fJM0HJae c=1 sm=1 tr=0 ts=69297481 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=vzhER2c_AAAA:8 a=yOoPl39vMG339Kno8JsA:9 a=QEXdDO2ut3YA:10 a=0YTRHmU2iG2pZC6F1fw2:22 X-Proofpoint-GUID: fquXQhYgxi6qhGWt-6RQHRsrjkXA5i-z X-Proofpoint-ORIG-GUID: 3wdLKFWn_Pdu2ZLIn_giR04lYMs94Nq_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-28_03,2025-11-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511220000 Hi Huang, On 28/11/25 13:24, Huang Shijie wrote: > Save the idle_stamp at the beginning of sched_balance_newidle(), > if it cannot pull any task, set it for rq->idle_stamp. > > This patch does not change the logic of rq->idle_stamp. > > Signed-off-by: Huang Shijie > --- > kernel/sched/fair.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 769d7b7990df..c1a8fa043156 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -12862,6 +12862,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf) > u64 t0, t1, curr_cost = 0; > struct sched_domain *sd; > int pulled_task = 0; > + u64 idle_stamp; > > update_misfit_status(NULL, this_rq); > > @@ -12877,7 +12878,9 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf) > * for CPU_NEWLY_IDLE, such that we measure the this duration > * as idle time. > */ > - this_rq->idle_stamp = rq_clock(this_rq); > + idle_stamp = rq_clock(this_rq); > + > + this_rq->idle_stamp = 0; IIUC, by setting this_rq->idle_stamp = 0 at the beginning, any call to update_rq_avg_idle() during load balancing when tasks are pulled will fail the if (rq->idle_stamp) check, preventing the average idle time from being updated. Thanks, Vineeth > > /* > * Do not pull tasks towards !active CPUs... > @@ -12989,10 +12992,11 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf) > if (time_after(this_rq->next_balance, next_balance)) > this_rq->next_balance = next_balance; > > - if (pulled_task) > - this_rq->idle_stamp = 0; > - else > + if (!pulled_task) { > + /* Set it here on purpose. */ > + this_rq->idle_stamp = idle_stamp; > nohz_newidle_balance(this_rq); > + } > > rq_repin_lock(this_rq, rf); >