From nobody Fri Nov 22 16:17:24 2024 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 390571922C6 for ; Sat, 16 Nov 2024 19:24:52 +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=1731785094; cv=none; b=B2OjpTm4fY4W7lIPeP0ujJSbHE2gcY2SxZOy0hutgX2edfXwKJQBqkp4rO2hnLsjNfvKGsjKHHvkAOM1BXeAmIfiCoZoPjrNNlcGotK8YNsci3UbkKVpWnFaOai/ZS/qjyJzmKwjL21iR2KnkzlCvb5k3ID1dAft+SL9B0SXqI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731785094; c=relaxed/simple; bh=rc0atpV04re56yLGzNLaF/aSbxoLXUvOLrdl4Tby6Kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UJKjiXM5VCgL83p7TsMJKQ0vFjPkqZOcgrdqCSkloHTWzuPFUIqlPssNtRX1hybZYbDJyl72V8VoMLJIIQsibfXl4zDIiTsB7lsegtSxzODMBF8vaX/NflfiGIE5oewzEi8ngNoe2sR3DeiWjmEyYLzDyeCnDf7iOslOPxlX5uU= 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=cZVTOFLa; 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="cZVTOFLa" 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 4AGJEnMY028002; Sat, 16 Nov 2024 19:24:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=pIWwu8rsxFtQAayBK 8IDKpwBaVLfjgU+PfZ7RpKKpjU=; b=cZVTOFLaHsTqDWTZvFKlTGUJ9vLTsNGAD nsH+Hi9tNAAremPKuqp3IF8uZkqxGsa72JC61uslvY4haFRoriXSm/fSCJIvLdXU p07LYA6icW+cU7s0XDih1wsts5juzNPdmdVYnEo/u0Jv98nkWoe7yCL3E2KDFpL7 yaLzAiJbSbXv8exUVMS0hf0+/0DWdRJoQoOEJFRU+Y+q5ag0dVQ0y3cw16+b9eOL x30zrMWc1Mx/sV+6Jct2nKe8IAnzTgQNtO+rBbDJPC3esnmVKsCtYdy+GrYTbyLU Dl63b8sA6Vt7YuPsyUneEwL2XR24HE9RsLSWlzaBjmlqeipnNia0w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xgtstv38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 19:24:30 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4AGJOTwD016678; Sat, 16 Nov 2024 19:24:29 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xgtstv36-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 19:24:29 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4AGIE3Ku010568; Sat, 16 Nov 2024 19:24:28 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tj2scqt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 19:24:28 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4AGJOPmF54985174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Nov 2024 19:24:25 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39C632004B; Sat, 16 Nov 2024 19:24:25 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FC6120040; Sat, 16 Nov 2024 19:24:23 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.220.93]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 16 Nov 2024 19:24:22 +0000 (GMT) From: Shrikanth Hegde To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Cc: sshegde@linux.ibm.com, npiggin@gmail.com, christophe.leroy@csgroup.eu, maddy@linux.ibm.com, bigeasy@linutronix.de, ankur.a.arora@oracle.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] powerpc: Add preempt lazy support Date: Sun, 17 Nov 2024 00:53:05 +0530 Message-ID: <20241116192306.88217-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241116192306.88217-1-sshegde@linux.ibm.com> References: <20241116192306.88217-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4ZI95TW5w8BRGMyEQFN_MqFQkrRxH4on X-Proofpoint-ORIG-GUID: FIpnOeNRUFwFSfwCJDcZpwWTqPOOTeM2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=882 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411160165 Content-Type: text/plain; charset="utf-8" Define preempt lazy bit for Powerpc. Use bit 9 which is free and within 16 bit range of NEED_RESCHED, so compiler can issue single andi. Since Powerpc doesn't use the generic entry/exit, add lazy check at exit to user. CONFIG_PREEMPTION is defined for lazy/full/rt so use it for return to kernel. Ran a few benchmarks and db workload on Power10. Performance is close to preempt=3Dnone/voluntary. =20 Since Powerpc systems can have large core count and large memory, preempt lazy is going to be helpful in avoiding soft lockup issues. Reviewed-by: Sebastian Andrzej Siewior Reviewed-by: Ankur Arora Signed-off-by: Shrikanth Hegde --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/thread_info.h | 9 ++++++--- arch/powerpc/kernel/interrupt.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 8094a01974cc..2f625aecf94b 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -145,6 +145,7 @@ config PPC select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_PMEM_API + select ARCH_HAS_PREEMPT_LAZY select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC_BOOK= 3S_64 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/= asm/thread_info.h index 6ebca2996f18..2785c7462ebf 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h @@ -103,6 +103,7 @@ void arch_setup_new_exec(void); #define TIF_PATCH_PENDING 6 /* pending live patching update */ #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ #define TIF_SINGLESTEP 8 /* singlestepping active */ +#define TIF_NEED_RESCHED_LAZY 9 /* Scheduler driven lazy preemption = */ #define TIF_SECCOMP 10 /* secure computing */ #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ #define TIF_NOERROR 12 /* Force successful syscall return */ @@ -122,6 +123,7 @@ void arch_setup_new_exec(void); #define _TIF_SYSCALL_TRACE (1<msr & MSR_EE)); again: - if (IS_ENABLED(CONFIG_PREEMPT)) { + if (IS_ENABLED(CONFIG_PREEMPTION)) { /* Return to preemptible kernel context */ if (unlikely(read_thread_flags() & _TIF_NEED_RESCHED)) { if (preempt_count() =3D=3D 0) --=20 2.43.5 From nobody Fri Nov 22 16:17:24 2024 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 46CB8191F7A for ; Sat, 16 Nov 2024 19:24:58 +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=1731785099; cv=none; b=QoGD1w2kfioJYintH9mVTFbMpsEp2AkMCfoeunyz5oJrp4QfOiZu8jeY2MdBNCW7N+vmAozHWuqazHN5qiJ2m2qmdd+hv4yWqXKmRZEJ00mIkwRDa6XzO499Q8UcRVMYp6b24uIW7Xdjn0p+EAos4awur9Z63xCtFJIrUv5+nQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731785099; c=relaxed/simple; bh=XajJ7P8F2bVIM3HEVhGPIKHiQNp5ggNKVqY/VX2leIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PA87O3s52NuYVtkcclBT3ApkD02ZoJi21YLFeqmAOFsuAzPXbx0u60MYg34jAqEeAZLpVqOceSTJIN5AzUsmwgyJHD+vuw7v5QXuuKocMLSBkce7N6DAGSr1uHgjuiI9bs2zMjvcq6xUbC3GxAwcPeLMobKX/Iv8ZQ7YaaYc82w= 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=pQpo47wX; 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="pQpo47wX" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AGHTUjs023793; Sat, 16 Nov 2024 19:24:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=VrXm4CcyPZMofJB5r tl6eM3KG+92o/0fEeQSzM6etFs=; b=pQpo47wXALyEOOOKSd7JCZodJRCH1EJKB Pozagr59R9uczuih6FsJg3w/GGg38Y3YSY4TSgHseUlDsynzPMnBhUKwBaHqFnYA N4OWbLgHJN19aS90WVBDDb+KgnhRCPK2OZAA48oDFeP5NIzKqeGEFPfZjkByZl+R UVWsxSc/HlcMYwmF7ErNBo2zBQG9smUxPxM/9UluvvFqD4GvngfV/5UaYI8dgbZk BLpp6MUz16H/Ord4ajOEi+aTj2U4g3B/9oqLQ/cGJtWWYq/1F/ifNBbCqNKwfSWj TNP9PUxtLcD3ee64RaPw+o87QArPGRO5PODSeDuJFo+dQ7OxesrDg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xyu18ag9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 19:24:34 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4AGJK7ZL032457; Sat, 16 Nov 2024 19:24:33 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 42xyu18ag7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 19:24:33 +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 4AGHwjVa008392; Sat, 16 Nov 2024 19:24:32 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42tjf0y5hc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 19:24:32 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4AGJOTmb53412138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Nov 2024 19:24:29 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03D3520043; Sat, 16 Nov 2024 19:24:29 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAC4120040; Sat, 16 Nov 2024 19:24:26 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.220.93]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 16 Nov 2024 19:24:26 +0000 (GMT) From: Shrikanth Hegde To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Cc: sshegde@linux.ibm.com, npiggin@gmail.com, christophe.leroy@csgroup.eu, maddy@linux.ibm.com, bigeasy@linutronix.de, ankur.a.arora@oracle.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] powerpc: Large user copy aware of full:rt:lazy preemption Date: Sun, 17 Nov 2024 00:53:06 +0530 Message-ID: <20241116192306.88217-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241116192306.88217-1-sshegde@linux.ibm.com> References: <20241116192306.88217-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: EdNCyaoVO74elOKg6CZ6IappUiebcywk X-Proofpoint-ORIG-GUID: -mJAzlN_T8nOW_D2ZgQuWCuNhBTMAScI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411160165 Content-Type: text/plain; charset="utf-8" Large user copy_to/from (more than 16 bytes) uses vmx instructions to=20 speed things up. Once the copy is done, it makes sense to try schedule=20 as soon as possible for preemptible kernels. So do this for=20 preempt=3Dfull/lazy and rt kernel.=20 Not checking for lazy bit here, since it could lead to unnecessary=20 context switches. Suggested-by: Sebastian Andrzej Siewior Signed-off-by: Shrikanth Hegde --- arch/powerpc/lib/vmx-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/lib/vmx-helper.c b/arch/powerpc/lib/vmx-helper.c index d491da8d1838..58ed6bd613a6 100644 --- a/arch/powerpc/lib/vmx-helper.c +++ b/arch/powerpc/lib/vmx-helper.c @@ -45,7 +45,7 @@ int exit_vmx_usercopy(void) * set and we are preemptible. The hack here is to schedule a * decrementer to fire here and reschedule for us if necessary. */ - if (IS_ENABLED(CONFIG_PREEMPT) && need_resched()) + if (IS_ENABLED(CONFIG_PREEMPTION) && need_resched()) set_dec(1); return 0; } --=20 2.43.5