From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 6972530DD1D for ; Tue, 9 Jun 2026 06:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780987406; cv=none; b=Qsi9uweHGt23j/x6tojdPR1fZgkHotbXvwNCGvJpdcj9ys3qZ2ADEPh7an/o1SOYc3GvaPHS7KhbdTAUlEVtto5Kznjn0T244uqNUaLuIm8zO5InAPLW7qTp97CvZYj5gMFx/DC745u+NunNVucPndvEC8FztKmM+VPB3l+GyZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780987406; c=relaxed/simple; bh=nmjY6pNjCdBMrOACmNF/HpTPTuWdto5V6wOGEYTzy7c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WGF6D2jbAfM4E/DSf4CZ7qN7cfiwPh6z+lRAvcYZiqrruoDu82Y/zA8ZwC4WwL3YCkedjZlPBtj34Pf3iPQQnwfZq8fVhzEIr0kBEMuIdJC14uC+ovBSof/eDAFlpZsMhDZ75Zy3+uU7YojW88F0wZVEfioJD7zFXXo8ZrKQ6xU= 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=PK9HLkDg; arc=none smtp.client-ip=148.163.156.1 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="PK9HLkDg" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6596Jehd3003996; Tue, 9 Jun 2026 06:43:04 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=RtYHK4 R34xDgyDn87GvKQtZWy1MzyZzsIYHoStNSyMg=; b=PK9HLkDgi+6SVxJJ1Pdg83 g0hnWZcR2XCLhm/A2KYJ3s5ZqBpiLaIG6dFsBJHRESWn6K6OZyh7suondYpOf3O6 8iuFzkmON/+fyPDm7wMxe50IncsGdQcchVftOhyh/dPxxVy7AmvAFyUG3D6xxhHL gCbdWwzhUwWUumsF0ryffLAUZokAeIxRfDd5au07ZstcgvdfG20vsap7bpPHPn7T qXZ32M/ydK+fV4KVdf9CfNL6F/4h1YLlo+uj80Blfw2XOtWcYUnc8RmJFfMHtolm ubUoCaYzGsdNJ3uLKIesAvZqa6A3bj6Dl3OuqalKvrTWErOTN1CIYVFot+eEafKQ == Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4emb95asdu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jun 2026 06:43:03 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6596YbXt025442; Tue, 9 Jun 2026 06:43:02 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4en03g0k38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jun 2026 06:43:02 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6596gxOJ28770590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Jun 2026 06:42:59 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3CBAE20040; Tue, 9 Jun 2026 06:42:59 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9050820043; Tue, 9 Jun 2026 06:42:52 +0000 (GMT) Received: from [9.39.27.33] (unknown [9.39.27.33]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 9 Jun 2026 06:42:52 +0000 (GMT) Message-ID: Date: Tue, 9 Jun 2026 12:12:51 +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 v3 17/20] sched/core: Introduce default arch handling code for inc/dec preferred CPUs To: Ilya Leoshkevich , linux-kernel@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, yury.norov@gmail.com, kprateek.nayak@amd.com Cc: tglx@kernel.org, gregkh@linuxfoundation.org, pbonzini@redhat.com, seanjc@google.com, vschneid@redhat.com, huschle@linux.ibm.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, mgorman@suse.de, bsegall@google.com, maddy@linux.ibm.com, srikar@linux.ibm.com, hdanton@sina.com, chleroy@kernel.org, vineeth@bitbyteword.org, frederic@kernel.org, arighi@nvidia.com, pauld@redhat.com, christian.loehle@arm.com, tj@kernel.org, tommaso.cucinotta@gmail.com, maz@kernel.org, rafael@kernel.org References: <20260514152204.481115-1-sshegde@linux.ibm.com> <20260514152204.481115-18-sshegde@linux.ibm.com> <8a1d506a-afea-4ac4-b842-9d67197b8a93@linux.ibm.com> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <8a1d506a-afea-4ac4-b842-9d67197b8a93@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=N4UZ0W9B c=1 sm=1 tr=0 ts=6a27b5f8 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=XlCIkzG5hXPfhqUrHNMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: SwvRJgYrlgVfhN43iqpeo8WqBum_LCAd X-Proofpoint-GUID: -FRAYWd7LSlIeYSx00R45QfjkdSfw09I X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA5MDA2MCBTYWx0ZWRfX+ky/SSu+z/Yr pptDiZFojUKxZpPQCd5aNTZbmqEClJuq07B9bpy+908nPbiDLgGq9MW7LEZvN6Avj0vTzRzJ9vG lsfl9nPlofQ2U+Ex3DN7x7GSlAX7UiE33+t9dlLgo0ZKFDtR8tKX7paC0hm4Snff602Qfb6QAue PYKxdctBEDjID38TqF2r1D6dgJYra+9GhVOsH2jvZNGlnbTPvgXyr5EdVMZPsiez2r6vnhUrG76 ihtFlsbxHvGhDS9kAdMU23+YzfbxTbJwL/Ro4dcp75Wo0KETt2wMOLalA+A6dln6msLrj5C0KNe vMeMJeo9H6TV4qeq7i17mYzP6UkKZydohaJQIeS92clqKhSxtsTNnIlNgvURfVWIic/ekVbsBsE ftpDhsrb/vUZzJrFRWMmYDWz5gyeq1RVPBEDZdjS/IyNFve2R7JKqrh3MhKEcS/XSADRSykhI00 4iFtYeBHXWROaJlWGnQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-09_01,2026-06-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 adultscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606090060 On 6/9/26 12:10 AM, Ilya Leoshkevich wrote: > > > On 5/14/26 17:22, Shrikanth Hegde wrote: >> Define default handlers for high/low steal time. If arch has better >> decision logic, may override the default implementation. >> >> - If the steal time higher than threshold, reduce the number of preferred >>    CPUs by 1 core. The last core in the intersection of online and >>    preferred CPUs will be marked as non-preferred. >>    Ensure at least one core is left as preferred always. >> >> - If the steal time lower than threshold, increase the number of >> preferred >>    CPUs by 1 core. First online core which is not in >> cpu_preferred_mask will >>    be marked as preferred. >>    If all cores are already set to preferred, bail out. >> >> Increase/Decrease may need to modify the splicing across NUMA nodes. >> It is >> being kept simple for now. >> >> Signed-off-by: Shrikanth Hegde >> --- >>   include/linux/sched.h |  2 ++ >>   kernel/sched/core.c   | 58 +++++++++++++++++++++++++++++++++++++++++++ >>   2 files changed, 60 insertions(+) > > [...] > >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index a3f65e9c7d30..195e3648b1b5 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -11368,6 +11368,64 @@ void sched_init_steal_monitor(void) >>       steal_mon.sampling_period_ms  = 1000;        /* once per second */ >>   } >> +/* >> + * Default implementation of decrementing the preferred CPUs based on >> steal >> + * time. This is simple logic and decrease the preferred CPUs by 1 core. >> + * It takes out the last core in the online & preferred. >> + * >> + * Ensure at least one housekeeping core is always kept as preferred >> + * >> + * Could be overwritten by arch specific handling. >> + */ >> +#ifndef arch_dec_preferred_cpus >> +void arch_dec_preferred_cpus(struct steal_monitor_t *sm, u64 >> steal_ratio) >> +{ >> +    int last_cpu, tmp_cpu; >> +    int this_cpu = raw_smp_processor_id(); >> + >> +    cpumask_and(sm->tmp_mask, cpu_online_mask, cpu_preferred_mask); > > Since preferred is always a subset of online, do we even need this? > Dropping tmp_mask will also make the error handling concern I posted > earlier go away. > You are right. Decrement doesn't need this. Thanks for catching this. I ran through the cases mentioned here and some more. I don't see a good reason to have the tmp_mask. https://lore.kernel.org/all/0d8412de-e18a-476f-9eb6-9a977f4474a3@linux.ibm.com/