[patch V2 08/37] rseq: Avoid CPU/MM CID updates when no event pending

Thomas Gleixner posted 37 patches 1 month, 1 week ago
There is a newer version of this series
[patch V2 08/37] rseq: Avoid CPU/MM CID updates when no event pending
Posted by Thomas Gleixner 1 month, 1 week ago
There is no need to update these values unconditionally if there is no
event pending.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/rseq.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -464,11 +464,12 @@ void __rseq_handle_notify_resume(struct
 		t->rseq_event_pending = false;
 	}
 
-	if (IS_ENABLED(CONFIG_DEBUG_RSEQ) || event) {
-		ret = rseq_ip_fixup(regs, event);
-		if (unlikely(ret < 0))
-			goto error;
-	}
+	if (!IS_ENABLED(CONFIG_DEBUG_RSEQ) && !event)
+		return;
+
+	ret = rseq_ip_fixup(regs, event);
+	if (unlikely(ret < 0))
+		goto error;
 
 	if (unlikely(rseq_update_cpu_node_id(t)))
 		goto error;
Re: [patch V2 08/37] rseq: Avoid CPU/MM CID updates when no event pending
Posted by Mathieu Desnoyers 1 month, 1 week ago
On 2025-08-23 12:39, Thomas Gleixner wrote:
> There is no need to update these values unconditionally if there is no
> event pending.

I agree with this change.

On a related note, I wonder if arch/powerpc/mm/numa.c:
find_and_update_cpu_nid() should set the rseq_event pending bool to true
for each thread in the system ?

Thanks,

Mathieu

> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>   kernel/rseq.c |   11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> --- a/kernel/rseq.c
> +++ b/kernel/rseq.c
> @@ -464,11 +464,12 @@ void __rseq_handle_notify_resume(struct
>   		t->rseq_event_pending = false;
>   	}
>   
> -	if (IS_ENABLED(CONFIG_DEBUG_RSEQ) || event) {
> -		ret = rseq_ip_fixup(regs, event);
> -		if (unlikely(ret < 0))
> -			goto error;
> -	}
> +	if (!IS_ENABLED(CONFIG_DEBUG_RSEQ) && !event)
> +		return;
> +
> +	ret = rseq_ip_fixup(regs, event);
> +	if (unlikely(ret < 0))
> +		goto error;
>   
>   	if (unlikely(rseq_update_cpu_node_id(t)))
>   		goto error;
> 


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Re: [patch V2 08/37] rseq: Avoid CPU/MM CID updates when no event pending
Posted by Thomas Gleixner 1 month ago
On Mon, Aug 25 2025 at 14:02, Mathieu Desnoyers wrote:
> On 2025-08-23 12:39, Thomas Gleixner wrote:
>> There is no need to update these values unconditionally if there is no
>> event pending.
>
> I agree with this change.
>
> On a related note, I wonder if arch/powerpc/mm/numa.c:
> find_and_update_cpu_nid() should set the rseq_event pending bool to true
> for each thread in the system ?

What for? That's the hotplug path, which establishes the CPU to node
relationship for newly added CPUs and their [hyper]threads _before_
those CPUs are able to run anything.

Thanks,

        tglx
Re: [patch V2 08/37] rseq: Avoid CPU/MM CID updates when no event pending
Posted by Mathieu Desnoyers 4 weeks, 1 day ago
On 2025-09-02 09:41, Thomas Gleixner wrote:
> On Mon, Aug 25 2025 at 14:02, Mathieu Desnoyers wrote:
>> On 2025-08-23 12:39, Thomas Gleixner wrote:
>>> There is no need to update these values unconditionally if there is no
>>> event pending.
>>
>> I agree with this change.
>>
>> On a related note, I wonder if arch/powerpc/mm/numa.c:
>> find_and_update_cpu_nid() should set the rseq_event pending bool to true
>> for each thread in the system ?
> 
> What for? That's the hotplug path, which establishes the CPU to node
> relationship for newly added CPUs and their [hyper]threads _before_
> those CPUs are able to run anything.

Agreed. Thanks!

Mathieu

> 
> Thanks,
> 
>          tglx


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com