Skip to contentSkip to conversation

Variable size jump_label support

RFC PATCH Ingo Molnar 3 participants 4 messages Oct 7, 2019 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

[ Sorry, fixed the Cc:lkml line. ]

Quoted 12 lines · Peter Zijlstra

These here patches are something I've been poking at for a while, enabling jump_label to use 2 byte jumps/nops.

It _almost_ works :-/

That is, you can build some kernels with it (x86_64-defconfig for example works just fine).

The problem comes when GCC generates a branch into another section, mostly .text.unlikely. At that point GAS just gives up and throws a fit (more details in the last patch).

Quoted 5 lines

Aside from anyone coming up with a really clever GAS trick, I don't see how we can do this other than:

- use 'jmp' and get objtool to rewrite the text. Steven has earlier proposed something like that (using recordmcount) and Linus hated that.

As long as GCC+GAS correctly generates a 2-byte or 5-byte JMP depending on the target distance, the objtool solution should work fine, shouldn't it?

I can see the recordmcount solution sucking, it would depend on early kernel patchery. But build time patchery is something we already depend on, so assuming some objtool catastrophy it's a more robust solution, isn't it?

Thanks,

Ingo

#4 lore raw
Quoted 1 line · On Mon, 7 Oct 2019 13:26:06 +0200 Ingo Molnar <[email protected]> wrote:

[ Sorry, fixed the Cc:lkml line. ]

/me joining the fun.

Quoted 21 lines · Peter Zijlstra
Quoted 13 lines

These here patches are something I've been poking at for a while, enabling jump_label to use 2 byte jumps/nops.

It _almost_ works :-/

That is, you can build some kernels with it (x86_64-defconfig for example works just fine).

The problem comes when GCC generates a branch into another section, mostly .text.unlikely. At that point GAS just gives up and throws a fit (more details in the last patch).

Quoted 5 lines

Aside from anyone coming up with a really clever GAS trick, I don't see how we can do this other than:

- use 'jmp' and get objtool to rewrite the text. Steven has earlier proposed something like that (using recordmcount) and Linus hated that.

Quoted 9 lines

As long as GCC+GAS correctly generates a 2-byte or 5-byte JMP depending on the target distance, the objtool solution should work fine, shouldn't it?

I can see the recordmcount solution sucking, it would depend on early kernel patchery. But build time patchery is something we already depend on, so assuming some objtool catastrophy it's a more robust solution, isn't it?

Actually, even back then I said that it would be best to merge all the tools into one (I just didn't have the time to implement it), and then we could pull this off. I have one of my developers working to merge record-mcount into objtool now (there's been some patches floating around).

Then with a single tool, it shouldn't be controversial.

-- Steve

#5 lore raw
Quoted 5 lines · Steven Rostedt

Actually, even back then I said that it would be best to merge all the tools into one (I just didn't have the time to implement it), and then we could pull this off. I have one of my developers working to merge record-mcount into objtool now (there's been some patches floating around).

Right, but while working on this I discovered GCC's -mrecord-mcount (and the kernel using this), so how much do we really still need the record-mcount tool?

Do we really only need the tool for the little hole between gcc-4.6 (minimal supported GCC version) and gcc-5 (when -mrecord-mcount was introduced) ?

#6 lore raw
Quoted 10 lines · On Mon, 7 Oct 2019 18:13:02 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 5 lines · Steven Rostedt

Actually, even back then I said that it would be best to merge all the tools into one (I just didn't have the time to implement it), and then we could pull this off. I have one of my developers working to merge record-mcount into objtool now (there's been some patches floating around).

Right, but while working on this I discovered GCC's -mrecord-mcount (and the kernel using this), so how much do we really still need the record-mcount tool?

That only works for some archs, not all of them. At least not yet that I'm aware of.

Quoted 4 lines

Do we really only need the tool for the little hole between gcc-4.6 (minimal supported GCC version) and gcc-5 (when -mrecord-mcount was introduced) ?

Again, it's for more than just x86 ;-)

-- Steve