RE: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Dexuan Cui
> From: Peter Zijlstra > Sent: Wednesday, December 16, 2020 2:59 AM > ... > So I think the reason your above module doesn't work, while the one in > vmx_init() does work (for 5.10) should be fixed by the completely > untested below. > > I've no clue about 5.4 and no desire to investigate. That's

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Jessica Yu
+++ Peter Zijlstra [16/12/20 14:23 +0100]: On Wed, Dec 16, 2020 at 02:10:16PM +0100, Jessica Yu wrote: +++ Peter Zijlstra [16/12/20 13:47 +0100]: > Only because we're having .init=false, incorrectly. See the other email. Ah yeah, you're right. I also misread the intention of the if

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Peter Zijlstra
On Wed, Dec 16, 2020 at 02:10:16PM +0100, Jessica Yu wrote: > +++ Peter Zijlstra [16/12/20 13:47 +0100]: > > Only because we're having .init=false, incorrectly. See the other email. > > Ah yeah, you're right. I also misread the intention of the if > conditional :/ If we're currently running an

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Jessica Yu
+++ Peter Zijlstra [16/12/20 13:47 +0100]: On Wed, Dec 16, 2020 at 12:55:25PM +0100, Jessica Yu wrote: +++ Peter Zijlstra [16/12/20 10:26 +0100]: [snip] > > PS, I originally found: in arch/x86/kvm/vmx/vmx.c: vmx_init(), it looks > > like the line "static_branch_enable(_evmcs);" does not take

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Peter Zijlstra
On Wed, Dec 16, 2020 at 12:55:25PM +0100, Jessica Yu wrote: > +++ Peter Zijlstra [16/12/20 10:26 +0100]: > [snip] > > > PS, I originally found: in arch/x86/kvm/vmx/vmx.c: vmx_init(), it looks > > > like the line "static_branch_enable(_evmcs);" does not take effect > > > in a v5.4-based kernel, but

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Jessica Yu
+++ Peter Zijlstra [16/12/20 10:26 +0100]: On Wed, Dec 16, 2020 at 03:54:29AM +, Dexuan Cui wrote: PS, I originally found: in arch/x86/kvm/vmx/vmx.c: vmx_init(), it looks like the line "static_branch_enable(_evmcs);" does not take effect in a v5.4-based kernel, but does take effect in the

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Jessica Yu
+++ Peter Zijlstra [16/12/20 10:26 +0100]: [snip] PS, I originally found: in arch/x86/kvm/vmx/vmx.c: vmx_init(), it looks like the line "static_branch_enable(_evmcs);" does not take effect in a v5.4-based kernel, but does take effect in the v5.10 kernel in the same x86-64 virtual machine on

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Peter Zijlstra
On Wed, Dec 16, 2020 at 10:26:49AM +0100, Peter Zijlstra wrote: > On Wed, Dec 16, 2020 at 03:54:29AM +, Dexuan Cui wrote: > > Hi, > > The below init_module() prints "foo: false". This is strange since > > static_branch_enable() is called before the static_branch_unlikely(). > > This strange

Re: static_branch_enable() does not work from a __init function?

2020-12-16 Thread Peter Zijlstra
On Wed, Dec 16, 2020 at 03:54:29AM +, Dexuan Cui wrote: > Hi, > The below init_module() prints "foo: false". This is strange since > static_branch_enable() is called before the static_branch_unlikely(). > This strange behavior happens to v5.10 and an old v5.4 kernel. > > If I remove the

static_branch_enable() does not work from a __init function?

2020-12-15 Thread Dexuan Cui
Hi, The below init_module() prints "foo: false". This is strange since static_branch_enable() is called before the static_branch_unlikely(). This strange behavior happens to v5.10 and an old v5.4 kernel. If I remove the "__init" marker from the init_module() function, then I get the expected