mbox series

[v1,0/4] Kill the time spent in patch_instruction()

Message ID cover.1647962456.git.christophe.leroy@csgroup.eu (mailing list archive)
Headers show
Series Kill the time spent in patch_instruction() | expand

Message

Christophe Leroy March 22, 2022, 3:40 p.m. UTC
This series reduces by 70% the time required to activate
ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.

Measure is performed in function ftrace_replace_code() using mftb()
around the loop.

With the series,
- Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
- With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.

Before this series,
- Without CONFIG_STRICT_KERNEL_RWX, 427000 TB ticks are measured.
- With CONFIG_STRICT_KERNEL_RWX, 1744000 TB ticks are measured.

Before the series, CONFIG_STRICT_KERNEL_RWX multiplies the time
required for ftrace activation by more than 4.

With the series, CONFIG_STRICT_KERNEL_RWX increases the time
required for ftrace activation by only 30%

Christophe Leroy (4):
  powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without
    CONFIG_MODULES
  powerpc/code-patching: Speed up page mapping/unmapping
  powerpc/code-patching: Use jump_label for testing freed initmem
  powerpc/code-patching: Use jump_label to check if poking_init() is
    done

 arch/powerpc/include/asm/code-patching.h |  2 ++
 arch/powerpc/lib/code-patching.c         | 37 +++++++++++++++---------
 arch/powerpc/mm/mem.c                    |  2 ++
 3 files changed, 28 insertions(+), 13 deletions(-)

Comments

Michael Ellerman May 15, 2022, 10:28 a.m. UTC | #1
On Tue, 22 Mar 2022 16:40:17 +0100, Christophe Leroy wrote:
> This series reduces by 70% the time required to activate
> ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.
> 
> Measure is performed in function ftrace_replace_code() using mftb()
> around the loop.
> 
> With the series,
> - Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
> - With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.
> 
> [...]

Patches 1, 3 and 4 applied to powerpc/next.

[1/4] powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without CONFIG_MODULES
      https://git.kernel.org/powerpc/c/cb3ac45214c03852430979a43180371a44b74596
[3/4] powerpc/code-patching: Use jump_label for testing freed initmem
      https://git.kernel.org/powerpc/c/b033767848c4115e486b1a51946de3bee2ac0fa6
[4/4] powerpc/code-patching: Use jump_label to check if poking_init() is done
      https://git.kernel.org/powerpc/c/1751289268ef959db68b0b6f798d904d6403309a

cheers
Christophe Leroy May 17, 2022, 6:44 a.m. UTC | #2
Le 15/05/2022 à 12:28, Michael Ellerman a écrit :
> On Tue, 22 Mar 2022 16:40:17 +0100, Christophe Leroy wrote:
>> This series reduces by 70% the time required to activate
>> ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.
>>
>> Measure is performed in function ftrace_replace_code() using mftb()
>> around the loop.
>>
>> With the series,
>> - Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
>> - With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.
>>
>> [...]
> 
> Patches 1, 3 and 4 applied to powerpc/next.
> 
> [1/4] powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without CONFIG_MODULES
>        https://git.kernel.org/powerpc/c/cb3ac45214c03852430979a43180371a44b74596
> [3/4] powerpc/code-patching: Use jump_label for testing freed initmem
>        https://git.kernel.org/powerpc/c/b033767848c4115e486b1a51946de3bee2ac0fa6
> [4/4] powerpc/code-patching: Use jump_label to check if poking_init() is done
>        https://git.kernel.org/powerpc/c/1751289268ef959db68b0b6f798d904d6403309a
> 

Patch 2 was the keystone of this series. What happened to it ?

Christophe
Michael Ellerman May 17, 2022, 12:37 p.m. UTC | #3
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 15/05/2022 à 12:28, Michael Ellerman a écrit :
>> On Tue, 22 Mar 2022 16:40:17 +0100, Christophe Leroy wrote:
>>> This series reduces by 70% the time required to activate
>>> ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.
>>>
>>> Measure is performed in function ftrace_replace_code() using mftb()
>>> around the loop.
>>>
>>> With the series,
>>> - Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
>>> - With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.
>>>
>>> [...]
>> 
>> Patches 1, 3 and 4 applied to powerpc/next.
>> 
>> [1/4] powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without CONFIG_MODULES
>>        https://git.kernel.org/powerpc/c/cb3ac45214c03852430979a43180371a44b74596
>> [3/4] powerpc/code-patching: Use jump_label for testing freed initmem
>>        https://git.kernel.org/powerpc/c/b033767848c4115e486b1a51946de3bee2ac0fa6
>> [4/4] powerpc/code-patching: Use jump_label to check if poking_init() is done
>>        https://git.kernel.org/powerpc/c/1751289268ef959db68b0b6f798d904d6403309a
>> 
>
> Patch 2 was the keystone of this series. What happened to it ?

It broke on 64-bit. I think I know why but I haven't had time to test
it. Will try and get it fixed in the next day or two.

cheers
Christophe Leroy May 31, 2022, 6:24 a.m. UTC | #4
Le 17/05/2022 à 14:37, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> Le 15/05/2022 à 12:28, Michael Ellerman a écrit :
>>> On Tue, 22 Mar 2022 16:40:17 +0100, Christophe Leroy wrote:
>>>> This series reduces by 70% the time required to activate
>>>> ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.
>>>>
>>>> Measure is performed in function ftrace_replace_code() using mftb()
>>>> around the loop.
>>>>
>>>> With the series,
>>>> - Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
>>>> - With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.
>>>>
>>>> [...]
>>>
>>> Patches 1, 3 and 4 applied to powerpc/next.
>>>
>>> [1/4] powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without CONFIG_MODULES
>>>         https://git.kernel.org/powerpc/c/cb3ac45214c03852430979a43180371a44b74596
>>> [3/4] powerpc/code-patching: Use jump_label for testing freed initmem
>>>         https://git.kernel.org/powerpc/c/b033767848c4115e486b1a51946de3bee2ac0fa6
>>> [4/4] powerpc/code-patching: Use jump_label to check if poking_init() is done
>>>         https://git.kernel.org/powerpc/c/1751289268ef959db68b0b6f798d904d6403309a
>>>
>>
>> Patch 2 was the keystone of this series. What happened to it ?
> 
> It broke on 64-bit. I think I know why but I haven't had time to test
> it. Will try and get it fixed in the next day or two.
> 

You didn't find any solution at the end, or didn't have time ?

What was the problem exactly ? I made a quick try on QEMU and it was 
working as expected.

Christophe
Christophe Leroy June 24, 2022, 7:06 a.m. UTC | #5
Michael ?

Le 31/05/2022 à 08:24, Christophe Leroy a écrit :
> 
> 
> Le 17/05/2022 à 14:37, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>> Le 15/05/2022 à 12:28, Michael Ellerman a écrit :
>>>> On Tue, 22 Mar 2022 16:40:17 +0100, Christophe Leroy wrote:
>>>>> This series reduces by 70% the time required to activate
>>>>> ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.
>>>>>
>>>>> Measure is performed in function ftrace_replace_code() using mftb()
>>>>> around the loop.
>>>>>
>>>>> With the series,
>>>>> - Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
>>>>> - With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.
>>>>>
>>>>> [...]
>>>>
>>>> Patches 1, 3 and 4 applied to powerpc/next.
>>>>
>>>> [1/4] powerpc/code-patching: Don't call is_vmalloc_or_module_addr() 
>>>> without CONFIG_MODULES
>>>>         
>>>> https://git.kernel.org/powerpc/c/cb3ac45214c03852430979a43180371a44b74596 
>>>>
>>>> [3/4] powerpc/code-patching: Use jump_label for testing freed initmem
>>>>         
>>>> https://git.kernel.org/powerpc/c/b033767848c4115e486b1a51946de3bee2ac0fa6 
>>>>
>>>> [4/4] powerpc/code-patching: Use jump_label to check if 
>>>> poking_init() is done
>>>>         
>>>> https://git.kernel.org/powerpc/c/1751289268ef959db68b0b6f798d904d6403309a 
>>>>
>>>>
>>>
>>> Patch 2 was the keystone of this series. What happened to it ?
>>
>> It broke on 64-bit. I think I know why but I haven't had time to test
>> it. Will try and get it fixed in the next day or two.
>>
> 
> You didn't find any solution at the end, or didn't have time ?
> 
> What was the problem exactly ? I made a quick try on QEMU and it was 
> working as expected.
> 

Should I make it a ppc32-only change ?
Christophe Leroy Sept. 27, 2022, 2:38 p.m. UTC | #6
Argh !! Looks like I sent an old already applied series nested in the 
new one.

Ignore those x/4 patches, only look at the x/6 ones.


Le 27/09/2022 à 16:33, Christophe Leroy a écrit :
> This series reduces by 70% the time required to activate
> ftrace on an 8xx with CONFIG_STRICT_KERNEL_RWX.
> 
> Measure is performed in function ftrace_replace_code() using mftb()
> around the loop.
> 
> With the series,
> - Without CONFIG_STRICT_KERNEL_RWX, 416000 TB ticks are measured.
> - With CONFIG_STRICT_KERNEL_RWX, 546000 TB ticks are measured.
> 
> Before this series,
> - Without CONFIG_STRICT_KERNEL_RWX, 427000 TB ticks are measured.
> - With CONFIG_STRICT_KERNEL_RWX, 1744000 TB ticks are measured.
> 
> Before the series, CONFIG_STRICT_KERNEL_RWX multiplies the time
> required for ftrace activation by more than 4.
> 
> With the series, CONFIG_STRICT_KERNEL_RWX increases the time
> required for ftrace activation by only 30%
> 
> Christophe Leroy (4):
>    powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without
>      CONFIG_MODULES
>    powerpc/code-patching: Speed up page mapping/unmapping
>    powerpc/code-patching: Use jump_label for testing freed initmem
>    powerpc/code-patching: Use jump_label to check if poking_init() is
>      done
> 
>   arch/powerpc/include/asm/code-patching.h |  2 ++
>   arch/powerpc/lib/code-patching.c         | 37 +++++++++++++++---------
>   arch/powerpc/mm/mem.c                    |  2 ++
>   3 files changed, 28 insertions(+), 13 deletions(-)
>