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 EBAEB3E3D9A for ; Mon, 8 Jun 2026 18:41:16 +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=1780944078; cv=none; b=ZgvviSs0nBcM/F3zH9b1dtDbN9lP85H6qwXOnV22oRRDs4pZ67i+7i8octr0nbRo9yoD/ZiysNJ3y6q09Om6l9nLbTfiyuBZt3a+7D3u9CB9WAQVC2tloLkaXTF8NNxbMslChtb6OoHGLHulIFbc6su8Xfm86QZLK/irwTsmGXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780944078; c=relaxed/simple; bh=KKH1tHMsgRKf76sVXX1QEgkHiHpiEgd28o4abT5He1A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l3VyNvwN0uaLbqvh0MfY893X0C1OMAQHG3Ro5uQgiqjYQLKb6UyFhFFUo4tYxQ5++tqu1nS/rS2Lbe+ZXV/kAVnd2vkHFCR+0hPsOkue9W7veZ8qt+Gp0E5ggMXNf0Ew1bYf76H2fWL1sjEbAILXaUuOIAMqp3tQplTifVaHMoI= 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=m08YYEJ5; 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="m08YYEJ5" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 658Cwqhg3073838; Mon, 8 Jun 2026 18:40:57 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=Tw/+J0 hao9r1GXRmGXLh80j207j0SkaRVJAuhlambro=; b=m08YYEJ5e/ekGzsyKylkuY B1/JtDqOpF34jPr7VXvz2mWnCnNqtRkYUrl+e+5z53l47D5M9w++u0W5hhArdm8v hh7LaMh696SV8G/SUd/QqGHa2Rly3dPHWqct1EL2oh40uWs7dpqoq+JnDafkDEVz +xIjcSnAphwykr/ADCLYJS8jT/yAHZD6Ohc6k5gM582/CfJ1XIPsUVXF5Way5my+ dvjoBBQv0J62OOCglUAyTNP8irviBvvTL0eKXNhMekxKXVWgKMG+1a9/UtGkpecX mvF/rGOi+OF561TYP/V1PBIrBzOeq6x0HJN2dLnjE55ylgGT6xxQ0KRM9bpS5y5g == Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4emb7qgrht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jun 2026 18:40:56 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 658IYbws004453; Mon, 8 Jun 2026 18:40:55 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4emycgxja3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jun 2026 18:40:54 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 658IepV543778362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jun 2026 18:40:51 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E300620043; Mon, 8 Jun 2026 18:40:50 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0477520040; Mon, 8 Jun 2026 18:40:49 +0000 (GMT) Received: from [0.0.0.0] (unknown [9.111.15.218]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 8 Jun 2026 18:40:48 +0000 (GMT) Message-ID: <8a1d506a-afea-4ac4-b842-9d67197b8a93@linux.ibm.com> Date: Mon, 8 Jun 2026 20:40:48 +0200 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: Shrikanth Hegde , 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> Content-Language: en-US From: Ilya Leoshkevich In-Reply-To: <20260514152204.481115-18-sshegde@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=HppG3UTS c=1 sm=1 tr=0 ts=6a270cb8 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=N5HBtarQ6IVFIh_eA_wA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: TG5RSmyqdPdDqXertaihHMUNCQvbACcB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA4MDE3NCBTYWx0ZWRfX52kdwAd8ORRL zuJ49fbuwdVvUDr8ZF9fW02tfAZqj+QxdiWSHdh7c3fwySSnX4iDp0tRBUbjA5fARviQHv7DxXj Arxe24XgLTZXfnGcWCPj/R6kfYrHaGRCkk9jIdJWRk2Tz4hrJMPptKtfCEc7ZYtgwoYOnwhvSlR 7r0iaqjNHtgz7/6hC5fjyeyRccs5LYTYGCUNnvo5fT4E97kpZMwKfVXbMmdH3EbnnFzn2XaAM+U 7XAfkZhZJgvudySG4qrkpGS2G7kjkkelYbZAlXluT21GTXAs228UNPKV3kzaVCdvylq4+HW0Faq rjax2wAbixqZuv/UOmhGPoyww9GJ9RxIPHRDLOJdKWqnpWLNG4hRQ7x0jOymc3Cgkbl/O9dfeNE L3j8DkswAD2cr00V1sb5JfRXwX29rJhVhRYSqbp7o1qxx0JX9522UuPX79GZkvgSWpzUGzwPF5l MlzW5dqTzt7fg5ks5Pg== X-Proofpoint-ORIG-GUID: 2uWeeLsCZakJLt4gQiPZ-4Z8iU5RSqpX 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-08_04,2026-06-05_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606080174 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. [...]