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 E3A7F2E62D9 for ; Tue, 25 Nov 2025 10:03:12 +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=1764064994; cv=none; b=SD6j9kcxncWrzi3tBvH0p+nM572Ug8o5sE50eWtfVrvH9WEczG7Oa9enTVD/wq/IXEUPYGE8ZdJAHusmXEdr/kr4WSfXYxJTHlbM25blXEcfY/OpObvRjwOkPMCu6laMoM0njnvtvYhSpBwsOQqUjfQ+oG9sIRCrUgQCxcwSvqI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764064994; c=relaxed/simple; bh=moarqzBnr22fuo9cJIykOBUV/2PYFJQkYjm76BKwJpw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D2yPWUa4BJNPlu8DtIaI1RkCUYFuNwZvuThNJFuYY0m5YJ++rqroIMawJTh+5ys3bq5xMtgi3BVwUUh/TuenNIA/KZa/EWG3E/t4vc3PaTlQoLdEdx7VZhid/DM4oltBxkNxTBAiV6RV3FKArFKIiv22oNCoAN/0vDoiHsCmpYQ= 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=gxmEsVWY; 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="gxmEsVWY" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AP4mkfZ005125; Tue, 25 Nov 2025 10:02:47 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=OWzGMb 9bW0NlTEPQiR4NOp8ZYaqcCMN3+rDGQ6/eT8U=; b=gxmEsVWYNjxmM3rjE+qWGt wSSplHyDZ8USqqboRcmnkhsyiZug2fUEqsoTa9EdIByAOFcK7PoTPfz1MYJD0NoH C94C3Vg/OAz3odVhczP8bN7My2fhwq2Oy6CwsCKu9GMnDnHZ4Z9YabrJVe+NvmAL SC/KJWMxGcKuf3gzVRFFyQA84qVparO6HDy929s9rAwypyKg7W3e7njbcY/6Mm/X UlCBJ+m6tsqd5PaUSI1GD7J9Rsn7fOmm8dvPnb0SiDmBiJcaArk+O9fqd0ydEEDG LeMmivtt03XwqoHLdDchyN2SqDMys9bAOnzHHXUmqjLydkD50kYekyyROB+1e1Fw == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4ak3kjv67d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Nov 2025 10:02:47 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5APA0u44017773; Tue, 25 Nov 2025 10:02:46 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4ak3kjv679-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Nov 2025 10:02:46 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5AP7Z4Dd025108; Tue, 25 Nov 2025 10:02:45 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4akt71ap3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Nov 2025 10:02:45 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5APA2jas28246760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Nov 2025 10:02:45 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F77E58051; Tue, 25 Nov 2025 10:02:45 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 761045805C; Tue, 25 Nov 2025 10:02:39 +0000 (GMT) Received: from [9.43.115.103] (unknown [9.43.115.103]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 25 Nov 2025 10:02:39 +0000 (GMT) Message-ID: <78749dc9-52bc-45e3-bd74-026fbfeb77d5@linux.ibm.com> Date: Tue, 25 Nov 2025 15:32:18 +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] sched: update the rq->avg_idle when a task is moved to an idle CPU To: Shijie Huang Cc: Huang Shijie , 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, Madadi Vineeth Reddy References: <20251124023745.259267-1-shijie@os.amperecomputing.com> Content-Language: en-US From: Madadi Vineeth Reddy In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fY12RePIoSBHqFKfMhwzFJhNrc6eS1sd X-Authority-Analysis: v=2.4 cv=frbRpV4f c=1 sm=1 tr=0 ts=69257ec7 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=xhGV2N9cJkzbW6Lu:21 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=G73dZF0C66sspG7BR6cA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: c7cszy9fdBOkgRGK-1pl02sqVMRnAtz1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIyMDAwOCBTYWx0ZWRfX9iLT1ui1DtJh GH5cGDFYYRHfz0uVdiN0MOWlKN9SL4ZRyx3cLaGc8Vv+xh5Ql2mmA24SSXvPSvHHfd43Q6Nnr9D Sw/4sv5xmLK922Dt0f+8PRoB7go0rF9ZtrF6JQwjZSAyI4iTYUy6VVy0Od3u64mdFCd2s3AJ//+ 3KNlyvtII6SCtyXOANrqhoMTDbIv3V1VGWn0r/7XyFXE+0gx96gNZbmNI7pRREkWk+8TRbonh2m xgoXhgxqtUqKv2Fae7zcTJ+9SQvmIIl9ommaj1y6Q/EMVr6iTxUhU/SBXCzzRSCXlDNDBLBXStZ ks//qyw9ahAYZn3wD7NUUzYaqSjnkkVm903HHq31RCVg2abZzu8zvvUMfe3qzKYlTXDjdbh3esE jtNhGGhzpUSiH7APs7vYqmTHrpghNg== 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-25_02,2025-11-24_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 clxscore=1011 spamscore=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511220008 On 25/11/25 14:29, Shijie Huang wrote: > > On 25/11/2025 15:08, Madadi Vineeth Reddy wrote: >> I traced the activate_task() call paths and found that load balancing migrations >> through attach_task() in kernel/sched/fair.c may not be covered. > thanks for pointing this, I did not notice them. >> >> activate_task <- attach_task <- attach_tasks <- sched_balance_rq >> activate_task <- attach_task <- attach_one_task <- active_load_balance_cpu_stop >> >> These paths are called in periodic load balancing and when tasks are pulled >> towards an idle CPU via attach_task(), it doesn't update rq->avg_idle or clear >> idle_stamp. > > Yes, we should update the rq->avg_idle for them. > > I will add it in version 2. > >> >> Should attach_task() in kernel/sched/fair.c also call update_rq_avg_idle() >> after activation? > > IMHO,  we should not call the update_rq_avg_idle() directly in attach_task(). > > In the current attach_task(), there is no information for the context(newidle, idle, busy). > > The attach_task() is also called in the newidle code path. > > But we can call the update_rq_avg_idle() in attach_tasks() with a condition check. > IIUC, update_rq_avg_idle() already checks if (rq->idle_stamp) internally and in attach_task() we have rq available and the guard in update_rq_avg_idle() ensures we only update when the CPU was actually idle. Whether it's called during newidle, idle, or busy balancing shouldn't matter. Let me know if I am missing something. Thanks, Vineeth >> >> Also, can update_rq_avg_idle() be placed inside activate_task() to avoid >> all these? > > The same reason as above. > > > Thanks > > Huang Shijie >