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 975B82BF000 for ; Thu, 20 Nov 2025 14:55:16 +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=1763650518; cv=none; b=nOJmm7rdL4o9lIDcyU9+DXG497o5xZbtUx2TZvyF7JeUBGXd2U27zS+SUVkLaObGNoTC/olnI9rY3NpwRnuNEPHGGCS5eH3rL56Ed2NJ+QRJvcDTi48TN+7EJHtQWC7i7NhNJfDwklFfcvqybVUyPMDCaxryVStsra/OzBsGObQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650518; c=relaxed/simple; bh=97s00dVAm96gl6jhhjz0yO4O9a1aMzRCzzCTMSSgL4s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hVQ+u0NrU9iWXjU29ogX9ADmgIucgkEaHsJ3H2WKhhRu7U3zvG8gkHI3SbeaYyZXZiZ2E/X7of/AfFjbKMfGza8l81fWPvRovhQVkze29gTgzR9lAPdJ501/jetK38HTGdQ8jNa22VaBb9ND4ltEjmz6Sy9AYkruhLtdjcizr8I= 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=lnlV193+; 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="lnlV193+" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AKCdFn5008180; Thu, 20 Nov 2025 14:54:18 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=+RJsHu qlgt04ccLVUJDbWa1K63ZGX5swVlXUJzNcPDM=; b=lnlV193+LbNrSMfxubTvdg bQWGwOChYxgmAlOSowGhQ9hhkRMvks9gAmW1KQq/PNzzMrwbeC9LZZnA+jlYi6x7 Ni+UUHSRIudOVnKmX5Kd6yO5pnrXQVfhP6dBOUYQ1VpP3YqF1NhJ/3wPxwYOOEee /dYdk3u95PqEEdglJ6bocVadNiVouxzyCmIAg6KaWOpmAPWWMaI9lQTN678R5pmw VZ4rs4XtThbgivmIdGpdhUkcPfevszVVpLVfY4Fbfb5nBxOpOVVO8Movz8dh9Evj cc8PLWyz+UNlRZ1Pl/+tOPHm4fZZ2SpIFDkOMW4zc4PWRYEZubFRgg3HHicCRGvQ == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aejmswmrc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Nov 2025 14:54:18 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5AKEXHsT012546; Thu, 20 Nov 2025 14:54:18 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 4aejmswmr8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Nov 2025 14:54:17 +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 5AKEc0eU017326; Thu, 20 Nov 2025 14:54:17 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4af6j1xm85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Nov 2025 14:54:17 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5AKEsFPg53608852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Nov 2025 14:54:15 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F5F62004B; Thu, 20 Nov 2025 14:54:15 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EAB820043; Thu, 20 Nov 2025 14:54:14 +0000 (GMT) Received: from [9.124.217.23] (unknown [9.124.217.23]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 20 Nov 2025 14:54:14 +0000 (GMT) Message-ID: Date: Thu, 20 Nov 2025 20:24:13 +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 01/17] sched/docs: Document cpu_paravirt_mask and Paravirt CPU concept To: Hillf Danton Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, seanjc@google.com, kprateek.nayak@amd.com References: <20251119124449.1149616-1-sshegde@linux.ibm.com> <20251119214857.9436-1-hdanton@sina.com> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20251119214857.9436-1-hdanton@sina.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 26o_RMxYbDRmj1uLzzi2DmvgCVX_I_v1 X-Authority-Analysis: v=2.4 cv=Rv3I7SmK c=1 sm=1 tr=0 ts=691f2b9a cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=VzDc_Xow_iNm7KAkw5UA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: zqFKYet8rQos9Q7dFGQ5tkUvHeh_K0Pc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfX6Ask4uGfSZOH KN70NLQVDU1GW1O6etEov4HNyUBhLLIVG4XVOzLfGAT05z3YT7YmCDwnThZFlHDvzf2XipbOx7W qLsZbk0fnRPT2Ev6hrcq6gmV2F86TZ8tZdRclPLKauX4/zgDO81MGuvGmfV9wopVxydV+Sz0xXa +lnEQkeN59cXxH9DaqtB8bT3lpVFjYm0KRrhDriBkcCkHLtoXz8dcBqZkOEIqZppvUIQXJsMVzy tvEZHJZPW5H91q+DXtTChK64YA+s4+7iFNPcSNWdy1V0DQtzLI9/uNdMYf/Tas1DhgRLpCFBxy6 pAQkJMUimeYgd4ooO1cl5FyvcePffs1DBPRafC5VFRe3HIUeSL3xVb2yeFed6o6o0mNW0BVD9u/ RigYFWmV0ewJGYKETO6qUXT22Kc/2Q== 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-20_05,2025-11-20_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 clxscore=1015 phishscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511150032 On 11/20/25 3:18 AM, Hillf Danton wrote: > On Wed, 19 Nov 2025 18:14:33 +0530 Shrikanth Hegde wrote: >> Add documentation for new cpumask called cpu_paravirt_mask. This could >> help users in understanding what this mask and the concept behind it. >> >> Signed-off-by: Shrikanth Hegde >> --- >> Documentation/scheduler/sched-arch.rst | 37 ++++++++++++++++++++++++++ >> 1 file changed, 37 insertions(+) >> >> diff --git a/Documentation/scheduler/sched-arch.rst b/Documentation/scheduler/sched-arch.rst >> index ed07efea7d02..6972c295013d 100644 >> --- a/Documentation/scheduler/sched-arch.rst >> +++ b/Documentation/scheduler/sched-arch.rst >> @@ -62,6 +62,43 @@ Your cpu_idle routines need to obey the following rules: >> arch/x86/kernel/process.c has examples of both polling and >> sleeping idle functions. >> >> +Paravirt CPUs >> +============= >> + >> +Under virtualised environments it is possible to overcommit CPU resources. >> +i.e sum of virtual CPU(vCPU) of all VM's is greater than number of physical >> +CPUs(pCPU). Under such conditions when all or many VM's have high utilization, >> +hypervisor won't be able to satisfy the CPU requirement and has to context >> +switch within or across VM. i.e hypervisor need to preempt one vCPU to run >> +another. This is called vCPU preemption. This is more expensive compared to >> +task context switch within a vCPU. >> + > What is missing is > 1) vCPU preemption is X% more expensive compared to task context switch within a vCPU. > This would change from arch to arch IMO. Will try to get numbers from PowerVM hypervisor. >> +In such cases it is better that VM's co-ordinate among themselves and ask for >> +less CPU by not using some of the vCPUs. Such vCPUs where workload can be >> +avoided at the moment for less vCPU preemption are called as "Paravirt CPUs". >> +Note that when the pCPU contention goes away, these vCPUs can be used again >> +by the workload. >> + > 2) given X, how to work out Y, the number of Paravirt CPUs for the simple > scenario like 8 pCPUs and 16 vCPUs (8 vCPUs from VM1, 8 vCPUs from VM2)? > Y need not be dependent on X. Note CPUs are marked as paravirt only when both VM's end up consuming all the CPU resource. Different cases: 1. VM1 is idle and VM2 is idle - No vCPUs are marked as paravirt. 2. VM1 is 100% busy and VM2 is idle - No steal time seen - No vCPUs is marked as paravirt. 3. VM1 is idle and VM2 is 100% busy - No steal time seen - No vCPUs is marked as paravirt. 4. VM1 is 100% busy and VM2 is 100% busy - 50% steal time would be seen in each - Since there are only 8 pCPUs (assuming each VM1 is allocated equally), 4 vCPUs in each VM will be marked as paravirt. Workload consolidates to remaining 4 vCPUs and hence no steal time will seen. Benefit would seen since host doesn't need to change expensive VM context switches. >> +Arch need to set/unset the specific vCPU in cpu_paravirt_mask. When set, avoid >> +that vCPU and when unset, use it as usual. >> + >> +Scheduler will try to avoid paravirt vCPUs as much as it can. >> +This is achieved by >> +1. Not selecting paravirt CPU at wakeup. >> +2. Push the task away from paravirt CPU at tick. >> +3. Not selecting paravirt CPU at load balance. >> + >> +This works only for SCHED_RT and SCHED_NORMAL. SCHED_EXT and userspace can make >> +choices accordingly using cpu_paravirt_mask. >> + >> +/sys/devices/system/cpu/paravirt prints the current cpu_paravirt_mask in >> +cpulist format. >> + >> +Notes: >> +1. A task pinned only on paravirt CPUs will continue to run there. >> +2. This feature is available under CONFIG_PARAVIRT >> +3. Refer to PowerPC for architecure implementation side. >> +4. Doesn't push out any task running on isolated CPUs. >> >> Possible arch/ problems >> ======================= >> -- >> 2.47.3