Re: [PATCH] x86: Implement _THIS_IP_ using inline asm for 32-bit

From: David Laight

Date: Thu May 21 2026 - 06:53:12 EST


On Thu, 21 May 2026 09:08:01 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> On Thu, May 21, 2026 at 02:00:09AM +0200, Marco Elver wrote:
..
> > #ifdef CONFIG_X86_32
> > #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
> > +#define _THIS_IP_ ({ unsigned long __ip; asm volatile("call 1f\n1: pop %0" : "=r" (__ip)); __ip; })
>
> This will mess up the RSB and cause bad performance ripple effects for a
> bit each use. Now, I don't think anybody still cares about performance
> on 32bit (I certainly don't), so perhaps this is fine. But urgh.

Nope, the cpu understands that code sequence and doesn't mess up the RSB.
It might even get decoded to a single u-op.

Basically it is present at the start of pretty much every PIC function.

-- David