Re: [PATCH 0/3] jump label: updates for 2.6.37

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: H. Peter Anvin
Date: Tuesday, November 23, 2010 - 4:32 pm

On 11/23/2010 03:11 PM, Steven Rostedt wrote:

The JUMP_LABEL() macro is rather ugly, and I found from the
static_cpu_has() work that inlines like (somewhat pseudocode here):

static inline bool SWITCH_POINT(void *metadata)
{
	asm goto("1: <5 byte nop>\n"
	         ".section \".metadata\",\"a\"\n"
		 ".long 1b, %p0\n"
		 ".previous\n"
	         : : "i" (metadata)
		 : : l_yes);
	return false;
l_yes:
	return true;
}

... work quite well; with the resulting SWITCH_POINT() being usable like
any other boolean expression in the kernel, i.e. as part of if, while,
etc.  Most of the time, gcc is smart enough to just use the flow of
control provided, and it also permits backwards compatibility with older
gcc by patching in a one-byte immediate instead.

There are some instances where it double-jumps; those can be avoided by
always jumping (allowing the patch code to replace the jump with a
5-byte NOP opportunistically a posteori) but unfortunately current gcc
tends to not order the sequentially next code afterwards if one does that.

	-hpa
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3] jump label: updates for 2.6.37, Jason Baron, (Tue Nov 23, 2:27 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, H. Peter Anvin, (Tue Nov 23, 2:36 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Tue Nov 23, 2:42 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Jason Baron, (Tue Nov 23, 2:56 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Tue Nov 23, 4:10 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Tue Nov 23, 4:11 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, H. Peter Anvin, (Tue Nov 23, 4:32 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Tue Nov 23, 5:10 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Tue Nov 23, 5:36 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, H. Peter Anvin, (Tue Nov 23, 5:37 pm)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Peter Zijlstra, (Wed Nov 24, 1:29 am)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Andi Kleen, (Wed Nov 24, 2:21 am)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Wed Nov 24, 5:47 am)
Re: [PATCH 0/3] jump label: updates for 2.6.37, Steven Rostedt, (Wed Nov 24, 6:49 am)