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 0C36A26B74A for ; Fri, 10 Apr 2026 17:58:27 +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=1775843909; cv=none; b=pB/8YruPc8M6h4kUiTITLuREM9//q5nNj9kRsmx+OjWc61Co1GIdSl4NvvnlO1IuZg/1Lt0/B/0/7gAr9Edmv5Mqe1C1iV9VHVrIV4T9C1+nTVViR5JN1DN3peMgwWVeZIFdQSXW30CyR8w248UztEVpvvz490AXBvQfB8h2D+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775843909; c=relaxed/simple; bh=+kGaB1Nc+BtPlQiCuksk1uCvapT+AZma7lCamRT+nB8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=e3aYnXlLlDWr3Z61lZp9T5kqBWH5YXE66T/4fJdtzttByp+JrxlaLn1s0aOu4H33LYMNzISNOfyAsr1DsdtSs/jgnZiwRg4vIHnHXwahhFPg7Hxbsy70uDVweARYRuidArjxqrWOPnuhO/5ITdvxA+ErP7Kdu1KQId/lBmXDvNM= 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=tOVEp1MT; 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="tOVEp1MT" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63AE3hS02210122; Fri, 10 Apr 2026 17:57:58 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=qJGbDR NYBFiw1/I1MqbqeCW9x/+OCoUJql8nGBOYAik=; b=tOVEp1MTwhL6ZVRspUw2QL 54Qj1yzlH8wzE9m+0J4a4M1W0o2tRK9OaCx3Olvy+/9E5WRwyUGBWvysuWuBdfcC FowWTD8rkOyZlssmrsBPt/jXODAmtUl3sDZVTctVg7nAyvJIKAuj1MBTo5hy9acu mVph0+Nb7dw5/mh+rxzFUESl/IxDcLsEPmudoz6ZZJCdMWDZukpemwIALMWrqUE7 7TMNtvWj99kMq1XypUnMCRhasrnorVSqdK8KttEztxuOWo9Id6v04tvuNzV+N9Bm wgUov9uAepV52MWVknhl6kkcUEAELp0TFYpbP9AZrWAYfa1m7eaWjjNg3UC3zumA == 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 4dcn2ht74q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Apr 2026 17:57:58 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63AGgXkR018965; Fri, 10 Apr 2026 17:57:57 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dcme9sa4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Apr 2026 17:57:57 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63AHvrIR33685922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Apr 2026 17:57:53 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A04F2004B; Fri, 10 Apr 2026 17:57:53 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1B5D20040; Fri, 10 Apr 2026 17:57:51 +0000 (GMT) Received: from [9.39.25.34] (unknown [9.39.25.34]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Apr 2026 17:57:51 +0000 (GMT) Message-ID: Date: Fri, 10 Apr 2026 23:27:50 +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: [RFC] in-kernel rseq To: Peter Zijlstra , linux-kernel@vger.kernel.org, Thomas Gleixner , mathieu.desnoyers@efficios.com, Mark Rutland , cmarinas@kernel.org, maddy@linux.ibm.com, hca@linux.ibm.com Cc: ryan.roberts@arm.com References: <20260223163843.GR1282955@noisy.programming.kicks-ass.net> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20260223163843.GR1282955@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEwMDE2NyBTYWx0ZWRfXzIEZKzb6Lmdq F/5OwK1k5GEllIKPE01wb/BFT9uCqsKIhEI//OypVd5aBOLCuKirtFEG0nRJ6dfbZdJ3VzsbM6D ovlphLE86OcpUF8ojpnDKB+0kdztDVjLKMuJtw8FFwH4tf2TVypvr/B4KYveWin+rJNI2WhrCmj ciyfOtkZKuqyOWWeBeLI7BPoFuCXKo3LK8YFtaFvhNtPChUrZhpIkSjW+BrAKa0+Wv7prOfnq5V Rnn/X5gmVd1uKVnM7WQGGp9/Kp5NlHvaHxacu1Qqg3fZpfLFMucw1Sw7b5hHi3+GpsIDBBsldUi 5k4T8iiHvLib6iVh+ehC+kp1Rb+RqTMMY7rNEyr40yafgqyc39K/9ZKapXmgEy3T2rNGrhleHYo hSoK1XWzyJq5yBYkbeR0NNodFoeY02fAyFQB+y7TYcx/N4kXmMGf/AMtx8jHnHncZwRK4Kj3tpU sqRNZnTj2/vXPS2JeDw== X-Proofpoint-GUID: vb9GYq2YUnCuVRK6Reht3PWsWPzgFfl7 X-Authority-Analysis: v=2.4 cv=a/wAM0SF c=1 sm=1 tr=0 ts=69d93a26 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=T2JdNsW0OE0KxGm6fXsA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: vb9GYq2YUnCuVRK6Reht3PWsWPzgFfl7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-10_05,2026-04-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1011 spamscore=0 impostorscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604100167 Hi Peter, On 2/23/26 10:08 PM, Peter Zijlstra wrote: > Hi, > > It has come to my attention that various people are struggling with > preempt_disable()+preempt_enable() costs for various architectures. > > Mostly in relation to things like this_cpu_ and or local_. > > The below is a very crude (and broken, more on that below) POC. > > So the 'main' advantage of this over preempt_disable()/preempt_enable(), > it on the preempt_enable() side, this elides the whole conditional and > call schedule() nonsense. This might be a very stupid question. Why not just call preempt_enable_no_resched instead? this_cpu operations would have disabled preemption so the per_cpu structures are protected from thread migration right? intention here is likely not to call schedule. No? PS: Sorry for the long delay in response. > > Now, on to the broken part, the below 'commit' address should be the > address of the 'STORE' instruction. In case of LL/SC, it should be the > SC, in case of LSE, it should be the LSE instruction. > > This means, it needs to be woven into the asm... and I'm not that handy > with arm64 asm. > > The pseudo code would be something like: > > current->sched_seq = &_R; > ... > > _start: compute per cpu-addr > load addr > $OP > _commit: store addr > > ... > current->sched_rseq = NULL; > > > Then when preemption happens (from interrupt), the instruction pointer > is 'simply' reset to _start and it tries again. > > Anyway, this was aimed at arm64, which chose to use atomics for > this_cpu. But if we move sched_rseq() from schedule-tail into interrupt > entry, then this would also work for things like Power. > > Anyway, just throwing ideas out there. > >