Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-30 Thread Scott Wood
On Mon, 2014-12-29 at 23:32 -0500, Pranith Kumar wrote:
> On Mon, Dec 29, 2014 at 5:03 AM, Martin Schwidefsky
>  wrote:
> > On Sat, 27 Dec 2014 12:17:43 -0500
> > Pranith Kumar  wrote:
> >
> >> @@ -65,10 +65,13 @@
> >>  #include 
> >>  #include 
> >>  #include 
> >> -#include 
> >>  #include 
> >>  #include 
> >>
> >> +#if IS_ENABLED(CONFIG_KVM)
> >> +#include 
> >> +#endif
> >> +
> >>  #ifdef DEBUG
> >>  #define DBG(fmt...) udbg_printf(fmt)
> >>  #else
> >
> > I always cringe when I see an include protected by an #ifdef.
> > Is this really necessary? All that is done in asm-offsets.c is
> > to calculate offsets, the code where the two offsets in question
> > are used (entry64.S) does have the #ifdef for CONFIG_KVM.
> 
> I agree that this is not the ideal way to do this. But, it has been
> the way things were already being done. If you see
> arch/powerpc/kernel/asm-offsets.c, there are quite some includes which
> are within ifdefs.

asm-offsets.c is unusual in that respect, and I think most of those
ifdefs could go away without breaking anything (head_booke.h is not a
normal header file, and kvm_book3s.h should just be removed as it will
be pulled in by kvm_ppc.h if applicable).

> I've considered other alternatives (though not in-depth) and found
> that they will require quite some refactoring. One simple idea is to
> move this #ifdef to within kvm_ppc.h. That should make the inclusion
> of this file a no-op in all the places where this is being included
> without KVM being enabled. But I am not 100% sure of that approach.
> 
> Any suggestions are welcome.

As I suggested elsewhere in the thread, why not be more fine-grained in
what you ifdef in the srcu header?  How will that require excessive
refactoring?

Or, just stick with the linker error.

I also wonder if this is worthwhile just to save around 2000 bytes.
What other core synchronization mechanisms are optional?  What
real-world configs will actually have this disabled?

-Scott


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-30 Thread Scott Wood
On Mon, 2014-12-29 at 23:32 -0500, Pranith Kumar wrote:
 On Mon, Dec 29, 2014 at 5:03 AM, Martin Schwidefsky
 schwidef...@de.ibm.com wrote:
  On Sat, 27 Dec 2014 12:17:43 -0500
  Pranith Kumar bobby.pr...@gmail.com wrote:
 
  @@ -65,10 +65,13 @@
   #include asm/kexec.h
   #include asm/mmu_context.h
   #include asm/code-patching.h
  -#include asm/kvm_ppc.h
   #include asm/hugetlb.h
   #include asm/epapr_hcalls.h
 
  +#if IS_ENABLED(CONFIG_KVM)
  +#include asm/kvm_ppc.h
  +#endif
  +
   #ifdef DEBUG
   #define DBG(fmt...) udbg_printf(fmt)
   #else
 
  I always cringe when I see an include protected by an #ifdef.
  Is this really necessary? All that is done in asm-offsets.c is
  to calculate offsets, the code where the two offsets in question
  are used (entry64.S) does have the #ifdef for CONFIG_KVM.
 
 I agree that this is not the ideal way to do this. But, it has been
 the way things were already being done. If you see
 arch/powerpc/kernel/asm-offsets.c, there are quite some includes which
 are within ifdefs.

asm-offsets.c is unusual in that respect, and I think most of those
ifdefs could go away without breaking anything (head_booke.h is not a
normal header file, and kvm_book3s.h should just be removed as it will
be pulled in by kvm_ppc.h if applicable).

 I've considered other alternatives (though not in-depth) and found
 that they will require quite some refactoring. One simple idea is to
 move this #ifdef to within kvm_ppc.h. That should make the inclusion
 of this file a no-op in all the places where this is being included
 without KVM being enabled. But I am not 100% sure of that approach.
 
 Any suggestions are welcome.

As I suggested elsewhere in the thread, why not be more fine-grained in
what you ifdef in the srcu header?  How will that require excessive
refactoring?

Or, just stick with the linker error.

I also wonder if this is worthwhile just to save around 2000 bytes.
What other core synchronization mechanisms are optional?  What
real-world configs will actually have this disabled?

-Scott


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Pranith Kumar
On Mon, Dec 29, 2014 at 6:05 PM, Scott Wood  wrote:
> On Sat, 2014-12-27 at 12:17 -0500, Pranith Kumar wrote:
>> Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
>> there
>> is a compile time failure if srcu is used when not enabled. This was decided 
>> to
>> be better than waiting until link time for a failure to occur.
>
> Yes, false positives and extra ifdefs are so much better. :-P
>
> Why not just ifdef the functions/macros, and leave the types alone?  If
> you're worried about direct access to struct members, you could even
> ifdef the members away while leaving the struct itself.  It is not
> normal practice in Linux to need ifdefs around #includes.

Yup, totally agree that this is not ideal. The idea here is to not
even compile the structure for tinification purposes. ifdefs for
headers are ugly, but given the current code structure, I was not able
to figure out any other way around it without major overhaul.

>
>> There are places which include kvm headers and utilize kvm data structures
>> without checking if KVM is enabled. In two such archs(s390, ppc64), the 
>> current
>> patch makes the uses of KVM conditional on KVM being enabled. The other 
>> option,
>> which is to enable KVM unconditionally seemed a bit too much as we could 
>> easily
>> figure out KVM only parts and enclose them in ifdefs.
>
> Maybe not so easy (mpc85xx_smp_defconfig with NOTIFY stuff turned off so
> that SRCU gets deselected):
>
> In file included from 
> /home/scott/fsl/git/linux/upstream/arch/powerpc/include/asm/kvm_ppc.h:30:0,
>  from 
> /home/scott/fsl/git/linux/upstream/arch/powerpc/kernel/smp.c:39:
> /home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:366:21: error: 
> field 'srcu' has incomplete type
> /home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:367:21: error: 
> field 'irq_srcu' has incomplete type
> /home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
> target 'arch/powerpc/kernel/smp.o' failed
> make[2]: *** [arch/powerpc/kernel/smp.o] Error 1
> /home/scott/fsl/git/linux/upstream/Makefile:955: recipe for target 
> 'arch/powerpc/kernel' failed
> make[1]: *** [arch/powerpc/kernel] Error 2
> make[1]: *** Waiting for unfinished jobs
>
> Are you sure KVM is the only SRCU user so impacted?  It's also likely
> that new such problems get introduced, because most people are going to
> have SRCU enabled and thus not notice the breakage they're adding.

Well, it is the major one which I encountered until now. There might
be other problems lurking which I will gladly try to fix if and when
they are reported.

>
> There's also at least one place that needs to be fixed, that currently
> expects to get other headers indirectly via srcu.h:
>
> /home/scott/fsl/git/linux/upstream/lib/assoc_array.c: In function 
> 'assoc_array_apply_edit':
> /home/scott/fsl/git/linux/upstream/lib/assoc_array.c:1425:2: error: implicit 
> declaration of function 'call_rcu' [-Werror=implicit-function-declaration]
> cc1: some warnings being treated as errors
> /home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
> target 'lib/assoc_array.o' failed

I will send a patch fixing this(need to use rcupdate.h here
explicitly). Thanks for reporting these!

>
> -Scott
>
>



-- 
Pranith
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Pranith Kumar
On Mon, Dec 29, 2014 at 5:03 AM, Martin Schwidefsky
 wrote:
> On Sat, 27 Dec 2014 12:17:43 -0500
> Pranith Kumar  wrote:
>
>> @@ -65,10 +65,13 @@
>>  #include 
>>  #include 
>>  #include 
>> -#include 
>>  #include 
>>  #include 
>>
>> +#if IS_ENABLED(CONFIG_KVM)
>> +#include 
>> +#endif
>> +
>>  #ifdef DEBUG
>>  #define DBG(fmt...) udbg_printf(fmt)
>>  #else
>
> I always cringe when I see an include protected by an #ifdef.
> Is this really necessary? All that is done in asm-offsets.c is
> to calculate offsets, the code where the two offsets in question
> are used (entry64.S) does have the #ifdef for CONFIG_KVM.

I agree that this is not the ideal way to do this. But, it has been
the way things were already being done. If you see
arch/powerpc/kernel/asm-offsets.c, there are quite some includes which
are within ifdefs.

I've considered other alternatives (though not in-depth) and found
that they will require quite some refactoring. One simple idea is to
move this #ifdef to within kvm_ppc.h. That should make the inclusion
of this file a no-op in all the places where this is being included
without KVM being enabled. But I am not 100% sure of that approach.

Any suggestions are welcome.

-- 
Pranith
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Scott Wood
On Sat, 2014-12-27 at 12:17 -0500, Pranith Kumar wrote:
> Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
> there
> is a compile time failure if srcu is used when not enabled. This was decided 
> to
> be better than waiting until link time for a failure to occur.

Yes, false positives and extra ifdefs are so much better. :-P

Why not just ifdef the functions/macros, and leave the types alone?  If
you're worried about direct access to struct members, you could even
ifdef the members away while leaving the struct itself.  It is not
normal practice in Linux to need ifdefs around #includes.

> There are places which include kvm headers and utilize kvm data structures
> without checking if KVM is enabled. In two such archs(s390, ppc64), the 
> current
> patch makes the uses of KVM conditional on KVM being enabled. The other 
> option,
> which is to enable KVM unconditionally seemed a bit too much as we could 
> easily
> figure out KVM only parts and enclose them in ifdefs.

Maybe not so easy (mpc85xx_smp_defconfig with NOTIFY stuff turned off so
that SRCU gets deselected):

In file included from 
/home/scott/fsl/git/linux/upstream/arch/powerpc/include/asm/kvm_ppc.h:30:0,
 from 
/home/scott/fsl/git/linux/upstream/arch/powerpc/kernel/smp.c:39:
/home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:366:21: error: 
field 'srcu' has incomplete type
/home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:367:21: error: 
field 'irq_srcu' has incomplete type
/home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
target 'arch/powerpc/kernel/smp.o' failed
make[2]: *** [arch/powerpc/kernel/smp.o] Error 1
/home/scott/fsl/git/linux/upstream/Makefile:955: recipe for target 
'arch/powerpc/kernel' failed
make[1]: *** [arch/powerpc/kernel] Error 2
make[1]: *** Waiting for unfinished jobs

Are you sure KVM is the only SRCU user so impacted?  It's also likely
that new such problems get introduced, because most people are going to
have SRCU enabled and thus not notice the breakage they're adding.

There's also at least one place that needs to be fixed, that currently
expects to get other headers indirectly via srcu.h:

/home/scott/fsl/git/linux/upstream/lib/assoc_array.c: In function 
'assoc_array_apply_edit':
/home/scott/fsl/git/linux/upstream/lib/assoc_array.c:1425:2: error: implicit 
declaration of function 'call_rcu' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
/home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
target 'lib/assoc_array.o' failed

-Scott


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Martin Schwidefsky
On Sat, 27 Dec 2014 12:17:43 -0500
Pranith Kumar  wrote:

> @@ -65,10 +65,13 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
> 
> +#if IS_ENABLED(CONFIG_KVM)
> +#include 
> +#endif
> +
>  #ifdef DEBUG
>  #define DBG(fmt...) udbg_printf(fmt)
>  #else

I always cringe when I see an include protected by an #ifdef.
Is this really necessary? All that is done in asm-offsets.c is
to calculate offsets, the code where the two offsets in question
are used (entry64.S) does have the #ifdef for CONFIG_KVM.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Martin Schwidefsky
On Sat, 27 Dec 2014 12:17:43 -0500
Pranith Kumar bobby.pr...@gmail.com wrote:

 @@ -65,10 +65,13 @@
  #include asm/kexec.h
  #include asm/mmu_context.h
  #include asm/code-patching.h
 -#include asm/kvm_ppc.h
  #include asm/hugetlb.h
  #include asm/epapr_hcalls.h
 
 +#if IS_ENABLED(CONFIG_KVM)
 +#include asm/kvm_ppc.h
 +#endif
 +
  #ifdef DEBUG
  #define DBG(fmt...) udbg_printf(fmt)
  #else

I always cringe when I see an include protected by an #ifdef.
Is this really necessary? All that is done in asm-offsets.c is
to calculate offsets, the code where the two offsets in question
are used (entry64.S) does have the #ifdef for CONFIG_KVM.

-- 
blue skies,
   Martin.

Reality continues to ruin my life. - Calvin.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Scott Wood
On Sat, 2014-12-27 at 12:17 -0500, Pranith Kumar wrote:
 Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
 there
 is a compile time failure if srcu is used when not enabled. This was decided 
 to
 be better than waiting until link time for a failure to occur.

Yes, false positives and extra ifdefs are so much better. :-P

Why not just ifdef the functions/macros, and leave the types alone?  If
you're worried about direct access to struct members, you could even
ifdef the members away while leaving the struct itself.  It is not
normal practice in Linux to need ifdefs around #includes.

 There are places which include kvm headers and utilize kvm data structures
 without checking if KVM is enabled. In two such archs(s390, ppc64), the 
 current
 patch makes the uses of KVM conditional on KVM being enabled. The other 
 option,
 which is to enable KVM unconditionally seemed a bit too much as we could 
 easily
 figure out KVM only parts and enclose them in ifdefs.

Maybe not so easy (mpc85xx_smp_defconfig with NOTIFY stuff turned off so
that SRCU gets deselected):

In file included from 
/home/scott/fsl/git/linux/upstream/arch/powerpc/include/asm/kvm_ppc.h:30:0,
 from 
/home/scott/fsl/git/linux/upstream/arch/powerpc/kernel/smp.c:39:
/home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:366:21: error: 
field 'srcu' has incomplete type
/home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:367:21: error: 
field 'irq_srcu' has incomplete type
/home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
target 'arch/powerpc/kernel/smp.o' failed
make[2]: *** [arch/powerpc/kernel/smp.o] Error 1
/home/scott/fsl/git/linux/upstream/Makefile:955: recipe for target 
'arch/powerpc/kernel' failed
make[1]: *** [arch/powerpc/kernel] Error 2
make[1]: *** Waiting for unfinished jobs

Are you sure KVM is the only SRCU user so impacted?  It's also likely
that new such problems get introduced, because most people are going to
have SRCU enabled and thus not notice the breakage they're adding.

There's also at least one place that needs to be fixed, that currently
expects to get other headers indirectly via srcu.h:

/home/scott/fsl/git/linux/upstream/lib/assoc_array.c: In function 
'assoc_array_apply_edit':
/home/scott/fsl/git/linux/upstream/lib/assoc_array.c:1425:2: error: implicit 
declaration of function 'call_rcu' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
/home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
target 'lib/assoc_array.o' failed

-Scott


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Pranith Kumar
On Mon, Dec 29, 2014 at 5:03 AM, Martin Schwidefsky
schwidef...@de.ibm.com wrote:
 On Sat, 27 Dec 2014 12:17:43 -0500
 Pranith Kumar bobby.pr...@gmail.com wrote:

 @@ -65,10 +65,13 @@
  #include asm/kexec.h
  #include asm/mmu_context.h
  #include asm/code-patching.h
 -#include asm/kvm_ppc.h
  #include asm/hugetlb.h
  #include asm/epapr_hcalls.h

 +#if IS_ENABLED(CONFIG_KVM)
 +#include asm/kvm_ppc.h
 +#endif
 +
  #ifdef DEBUG
  #define DBG(fmt...) udbg_printf(fmt)
  #else

 I always cringe when I see an include protected by an #ifdef.
 Is this really necessary? All that is done in asm-offsets.c is
 to calculate offsets, the code where the two offsets in question
 are used (entry64.S) does have the #ifdef for CONFIG_KVM.

I agree that this is not the ideal way to do this. But, it has been
the way things were already being done. If you see
arch/powerpc/kernel/asm-offsets.c, there are quite some includes which
are within ifdefs.

I've considered other alternatives (though not in-depth) and found
that they will require quite some refactoring. One simple idea is to
move this #ifdef to within kvm_ppc.h. That should make the inclusion
of this file a no-op in all the places where this is being included
without KVM being enabled. But I am not 100% sure of that approach.

Any suggestions are welcome.

-- 
Pranith
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-29 Thread Pranith Kumar
On Mon, Dec 29, 2014 at 6:05 PM, Scott Wood scottw...@freescale.com wrote:
 On Sat, 2014-12-27 at 12:17 -0500, Pranith Kumar wrote:
 Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
 there
 is a compile time failure if srcu is used when not enabled. This was decided 
 to
 be better than waiting until link time for a failure to occur.

 Yes, false positives and extra ifdefs are so much better. :-P

 Why not just ifdef the functions/macros, and leave the types alone?  If
 you're worried about direct access to struct members, you could even
 ifdef the members away while leaving the struct itself.  It is not
 normal practice in Linux to need ifdefs around #includes.

Yup, totally agree that this is not ideal. The idea here is to not
even compile the structure for tinification purposes. ifdefs for
headers are ugly, but given the current code structure, I was not able
to figure out any other way around it without major overhaul.


 There are places which include kvm headers and utilize kvm data structures
 without checking if KVM is enabled. In two such archs(s390, ppc64), the 
 current
 patch makes the uses of KVM conditional on KVM being enabled. The other 
 option,
 which is to enable KVM unconditionally seemed a bit too much as we could 
 easily
 figure out KVM only parts and enclose them in ifdefs.

 Maybe not so easy (mpc85xx_smp_defconfig with NOTIFY stuff turned off so
 that SRCU gets deselected):

 In file included from 
 /home/scott/fsl/git/linux/upstream/arch/powerpc/include/asm/kvm_ppc.h:30:0,
  from 
 /home/scott/fsl/git/linux/upstream/arch/powerpc/kernel/smp.c:39:
 /home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:366:21: error: 
 field 'srcu' has incomplete type
 /home/scott/fsl/git/linux/upstream/include/linux/kvm_host.h:367:21: error: 
 field 'irq_srcu' has incomplete type
 /home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
 target 'arch/powerpc/kernel/smp.o' failed
 make[2]: *** [arch/powerpc/kernel/smp.o] Error 1
 /home/scott/fsl/git/linux/upstream/Makefile:955: recipe for target 
 'arch/powerpc/kernel' failed
 make[1]: *** [arch/powerpc/kernel] Error 2
 make[1]: *** Waiting for unfinished jobs

 Are you sure KVM is the only SRCU user so impacted?  It's also likely
 that new such problems get introduced, because most people are going to
 have SRCU enabled and thus not notice the breakage they're adding.

Well, it is the major one which I encountered until now. There might
be other problems lurking which I will gladly try to fix if and when
they are reported.


 There's also at least one place that needs to be fixed, that currently
 expects to get other headers indirectly via srcu.h:

 /home/scott/fsl/git/linux/upstream/lib/assoc_array.c: In function 
 'assoc_array_apply_edit':
 /home/scott/fsl/git/linux/upstream/lib/assoc_array.c:1425:2: error: implicit 
 declaration of function 'call_rcu' [-Werror=implicit-function-declaration]
 cc1: some warnings being treated as errors
 /home/scott/fsl/git/linux/upstream/scripts/Makefile.build:257: recipe for 
 target 'lib/assoc_array.o' failed

I will send a patch fixing this(need to use rcupdate.h here
explicitly). Thanks for reporting these!


 -Scott





-- 
Pranith
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-27 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

There are places which include kvm headers and utilize kvm data structures
without checking if KVM is enabled. In two such archs(s390, ppc64), the current
patch makes the uses of KVM conditional on KVM being enabled. The other option,
which is to enable KVM unconditionally seemed a bit too much as we could easily
figure out KVM only parts and enclose them in ifdefs.

Signed-off-by: Pranith Kumar 
---
 arch/powerpc/kernel/setup_64.c |  7 ++-
 arch/s390/kernel/asm-offsets.c |  7 ++-
 include/linux/notifier.h   | 47 --
 include/linux/srcu.h   |  6 +-
 4 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 4f3cfe1..f55302f 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -65,10 +65,13 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
+#if IS_ENABLED(CONFIG_KVM)
+#include 
+#endif
+
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
 #else
@@ -286,8 +289,10 @@ void __init early_setup(unsigned long dt_ptr)
 */
cpu_ready_for_interrupts();
 
+#if IS_ENABLED(CONFIG_KVM)
/* Reserve large chunks of memory for use by CMA for KVM */
kvm_cma_reserve();
+#endif
 
/*
 * Reserve any gigantic pages requested on the command line.
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index ef279a1..2813a3c 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -7,12 +7,15 @@
 #define ASM_OFFSETS_C
 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#if IS_ENABLED(CONFIG_KVM)
+#include 
+#endif
+
 /*
  * Make sure that the compiler is new enough. We want a compiler that
  * is known to work with the "Q" assembler constraint.
@@ -182,8 +185,10 @@ int main(void)
DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
thread.trap_tdb));
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
+#if IS_ENABLED(CONFIG_KVM)
DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
+#endif /* CONFIG_KVM */
 #endif /* CONFIG_32BIT */
return 0;
 }
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init(&(name)->lock);  \
(name)->head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)->head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct(&(name)->srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-27 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

There are places which include kvm headers and utilize kvm data structures
without checking if KVM is enabled. In two such archs(s390, ppc64), the current
patch makes the uses of KVM conditional on KVM being enabled. The other option,
which is to enable KVM unconditionally seemed a bit too much as we could easily
figure out KVM only parts and enclose them in ifdefs.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
---
 arch/powerpc/kernel/setup_64.c |  7 ++-
 arch/s390/kernel/asm-offsets.c |  7 ++-
 include/linux/notifier.h   | 47 --
 include/linux/srcu.h   |  6 +-
 4 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 4f3cfe1..f55302f 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -65,10 +65,13 @@
 #include asm/kexec.h
 #include asm/mmu_context.h
 #include asm/code-patching.h
-#include asm/kvm_ppc.h
 #include asm/hugetlb.h
 #include asm/epapr_hcalls.h
 
+#if IS_ENABLED(CONFIG_KVM)
+#include asm/kvm_ppc.h
+#endif
+
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
 #else
@@ -286,8 +289,10 @@ void __init early_setup(unsigned long dt_ptr)
 */
cpu_ready_for_interrupts();
 
+#if IS_ENABLED(CONFIG_KVM)
/* Reserve large chunks of memory for use by CMA for KVM */
kvm_cma_reserve();
+#endif
 
/*
 * Reserve any gigantic pages requested on the command line.
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index ef279a1..2813a3c 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -7,12 +7,15 @@
 #define ASM_OFFSETS_C
 
 #include linux/kbuild.h
-#include linux/kvm_host.h
 #include linux/sched.h
 #include asm/idle.h
 #include asm/vdso.h
 #include asm/pgtable.h
 
+#if IS_ENABLED(CONFIG_KVM)
+#include linux/kvm_host.h
+#endif
+
 /*
  * Make sure that the compiler is new enough. We want a compiler that
  * is known to work with the Q assembler constraint.
@@ -182,8 +185,10 @@ int main(void)
DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
thread.trap_tdb));
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
+#if IS_ENABLED(CONFIG_KVM)
DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
+#endif /* CONFIG_KVM */
 #endif /* CONFIG_32BIT */
return 0;
 }
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init((name)-lock);  \
(name)-head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)-head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct((name)-srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int 

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Paul E. McKenney
On Tue, Dec 09, 2014 at 01:48:21PM -0500, Pranith Kumar wrote:
> Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
> there
> is a compile time failure if srcu is used when not enabled. This was decided 
> to
> be better than waiting until link time for a failure to occur.
> 
> Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
> prevents build failures as KVM is dependent on SRCU.
> 
> Signed-off-by: Pranith Kumar 
> CC: Paul E. McKenney 
> CC: Josh Triplett 
> CC: Lai Jiangshan 
> Signed-off-by: Paul E. McKenney 

Queued for testing (finally), replacing the earlier patch.  ;-)

Thanx, Paul

> ---
>  arch/s390/kernel/asm-offsets.c |  7 ++-
>  include/linux/notifier.h   | 47 
> --
>  include/linux/srcu.h   |  6 +-
>  3 files changed, 38 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
> index ef279a1..2813a3c 100644
> --- a/arch/s390/kernel/asm-offsets.c
> +++ b/arch/s390/kernel/asm-offsets.c
> @@ -7,12 +7,15 @@
>  #define ASM_OFFSETS_C
> 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  #include 
> 
> +#if IS_ENABLED(CONFIG_KVM)
> +#include 
> +#endif
> +
>  /*
>   * Make sure that the compiler is new enough. We want a compiler that
>   * is known to work with the "Q" assembler constraint.
> @@ -182,8 +185,10 @@ int main(void)
>   DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
>   DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
> thread.trap_tdb));
>   DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
> +#if IS_ENABLED(CONFIG_KVM)
>   DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
>   DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
> +#endif /* CONFIG_KVM */
>  #endif /* CONFIG_32BIT */
>   return 0;
>  }
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index d14a4c3..fe4f02a 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -47,6 +47,8 @@
>   * runtime initialization.
>   */
> 
> +struct notifier_block;
> +
>  typedef  int (*notifier_fn_t)(struct notifier_block *nb,
>   unsigned long action, void *data);
> 
> @@ -70,12 +72,6 @@ struct raw_notifier_head {
>   struct notifier_block __rcu *head;
>  };
> 
> -struct srcu_notifier_head {
> - struct mutex mutex;
> - struct srcu_struct srcu;
> - struct notifier_block __rcu *head;
> -};
> -
>  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
>   spin_lock_init(&(name)->lock);  \
>   (name)->head = NULL;\
> @@ -88,11 +84,6 @@ struct srcu_notifier_head {
>   (name)->head = NULL;\
>   } while (0)
> 
> -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
> -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> -#define srcu_cleanup_notifier_head(name) \
> - cleanup_srcu_struct(&(name)->srcu);
> -
>  #define ATOMIC_NOTIFIER_INIT(name) { \
>   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
>   .head = NULL }
> @@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
> srcu_notifier_head *nh);
>   .head = NULL }
>  #define RAW_NOTIFIER_INIT(name)  {   \
>   .head = NULL }
> -/* srcu_notifier_heads cannot be initialized statically */
> 
>  #define ATOMIC_NOTIFIER_HEAD(name)   \
>   struct atomic_notifier_head name =  \
> @@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
> - struct notifier_block *nb);
> 
>  extern int blocking_notifier_chain_cond_register(
>   struct blocking_notifier_head *nh,
> @@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
> - struct notifier_block *nb);
> 
>  extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
>   unsigned long val, void *v);
> @@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
> raw_notifier_head *nh,
>   unsigned long val, void *v);
>  extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
>   unsigned long val, void *v, int nr_to_call, int *nr_calls);
> -extern int 

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Mathieu Desnoyers
- Original Message -
> From: "Pranith Kumar" 
> To: "Martin Schwidefsky" , "Heiko Carstens" 
> , "supporter:S390"
> , "Lai Jiangshan" , "Paul E. 
> McKenney" ,
> "Josh Triplett" , "Steven Rostedt" 
> , "Mathieu Desnoyers"
> , "Christian Borntraeger" 
> , "Jens Freimann"
> , "open list:S390" , 
> "open list"
> 
> Sent: Tuesday, December 9, 2014 1:48:21 PM
> Subject: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU
> 
> Isolate the SRCU functions and data structures within CONFIG_SRCU so that
> there
> is a compile time failure if srcu is used when not enabled. This was decided
> to
> be better than waiting until link time for a failure to occur.
> 
> Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
> prevents build failures as KVM is dependent on SRCU.
> 
> Signed-off-by: Pranith Kumar 
> CC: Paul E. McKenney 
> CC: Josh Triplett 
> CC: Lai Jiangshan 
> Signed-off-by: Paul E. McKenney 
> ---
>  arch/s390/kernel/asm-offsets.c |  7 ++-
>  include/linux/notifier.h   | 47
>  --
>  include/linux/srcu.h   |  6 +-
>  3 files changed, 38 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
> index ef279a1..2813a3c 100644
> --- a/arch/s390/kernel/asm-offsets.c
> +++ b/arch/s390/kernel/asm-offsets.c
> @@ -7,12 +7,15 @@
>  #define ASM_OFFSETS_C
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  
> +#if IS_ENABLED(CONFIG_KVM)
> +#include 
> +#endif
> +

Seeing this kind of conditional include makes me cringe. Is there some
way to hide this within linux/kvm_host.h instead ?

Thanks,

Mathieu

>  /*
>   * Make sure that the compiler is new enough. We want a compiler that
>   * is known to work with the "Q" assembler constraint.
> @@ -182,8 +185,10 @@ int main(void)
>   DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
>   DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
> thread.trap_tdb));
>   DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
> +#if IS_ENABLED(CONFIG_KVM)
>   DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
>   DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
> +#endif /* CONFIG_KVM */
>  #endif /* CONFIG_32BIT */
>   return 0;
>  }
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index d14a4c3..fe4f02a 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -47,6 +47,8 @@
>   * runtime initialization.
>   */
>  
> +struct notifier_block;
> +
>  typedef  int (*notifier_fn_t)(struct notifier_block *nb,
>   unsigned long action, void *data);
>  
> @@ -70,12 +72,6 @@ struct raw_notifier_head {
>   struct notifier_block __rcu *head;
>  };
>  
> -struct srcu_notifier_head {
> - struct mutex mutex;
> - struct srcu_struct srcu;
> - struct notifier_block __rcu *head;
> -};
> -
>  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
>   spin_lock_init(&(name)->lock);  \
>   (name)->head = NULL;\
> @@ -88,11 +84,6 @@ struct srcu_notifier_head {
>   (name)->head = NULL;\
>   } while (0)
>  
> -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
> -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> -#define srcu_cleanup_notifier_head(name) \
> - cleanup_srcu_struct(&(name)->srcu);
> -
>  #define ATOMIC_NOTIFIER_INIT(name) { \
>   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
>   .head = NULL }
> @@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct
> srcu_notifier_head *nh);
>   .head = NULL }
>  #define RAW_NOTIFIER_INIT(name)  {   \
>   .head = NULL }
> -/* srcu_notifier_heads cannot be initialized statically */
>  
>  #define ATOMIC_NOTIFIER_HEAD(name)   \
>   struct atomic_notifier_head name =  \
> @@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
> - struct noti

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
prevents build failures as KVM is dependent on SRCU.

Signed-off-by: Pranith Kumar 
CC: Paul E. McKenney 
CC: Josh Triplett 
CC: Lai Jiangshan 
Signed-off-by: Paul E. McKenney 
---
 arch/s390/kernel/asm-offsets.c |  7 ++-
 include/linux/notifier.h   | 47 --
 include/linux/srcu.h   |  6 +-
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index ef279a1..2813a3c 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -7,12 +7,15 @@
 #define ASM_OFFSETS_C
 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#if IS_ENABLED(CONFIG_KVM)
+#include 
+#endif
+
 /*
  * Make sure that the compiler is new enough. We want a compiler that
  * is known to work with the "Q" assembler constraint.
@@ -182,8 +185,10 @@ int main(void)
DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
thread.trap_tdb));
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
+#if IS_ENABLED(CONFIG_KVM)
DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
+#endif /* CONFIG_KVM */
 #endif /* CONFIG_32BIT */
return 0;
 }
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init(&(name)->lock);  \
(name)->head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)->head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct(&(name)->srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
 #define NOTIFY_DONE0x  /* Don't care */
 #define NOTIFY_OK  0x0001  /* Suits me */
@@ -211,5 

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Paul E. McKenney
On Tue, Dec 09, 2014 at 09:16:46AM -0500, Pranith Kumar wrote:
> Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
> there
> is a compile time failure if srcu is used when not enabled. This was decided 
> to
> be better than waiting until link time for a failure to occur.
> 
> Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
> prevents build failures as KVM is dependent on SRCU.

Queued for testing, thank you!

Thanx, Paul

> Signed-off-by: Pranith Kumar 
> Acked-by: Christian Borntraeger  [for s390 parts]
> CC: Josh Triplett 
> CC: Lai Jiangshan 
> CC: Paul E. McKenney 
> ---
>  arch/s390/kernel/asm-offsets.c |  7 ++-
>  include/linux/notifier.h   | 47 
> --
>  include/linux/srcu.h   |  6 +-
>  3 files changed, 38 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
> index ef279a1..055334d 100644
> --- a/arch/s390/kernel/asm-offsets.c
> +++ b/arch/s390/kernel/asm-offsets.c
> @@ -7,12 +7,15 @@
>  #define ASM_OFFSETS_C
> 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  #include 
> 
> +#ifdef CONFIG_KVM
> +#include 
> +#endif
> +
>  /*
>   * Make sure that the compiler is new enough. We want a compiler that
>   * is known to work with the "Q" assembler constraint.
> @@ -182,8 +185,10 @@ int main(void)
>   DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
>   DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
> thread.trap_tdb));
>   DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
> +#ifdef CONFIG_KVM
>   DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
>   DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
> +#endif /* CONFIG_KVM */
>  #endif /* CONFIG_32BIT */
>   return 0;
>  }
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index d14a4c3..fe4f02a 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -47,6 +47,8 @@
>   * runtime initialization.
>   */
> 
> +struct notifier_block;
> +
>  typedef  int (*notifier_fn_t)(struct notifier_block *nb,
>   unsigned long action, void *data);
> 
> @@ -70,12 +72,6 @@ struct raw_notifier_head {
>   struct notifier_block __rcu *head;
>  };
> 
> -struct srcu_notifier_head {
> - struct mutex mutex;
> - struct srcu_struct srcu;
> - struct notifier_block __rcu *head;
> -};
> -
>  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
>   spin_lock_init(&(name)->lock);  \
>   (name)->head = NULL;\
> @@ -88,11 +84,6 @@ struct srcu_notifier_head {
>   (name)->head = NULL;\
>   } while (0)
> 
> -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
> -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> -#define srcu_cleanup_notifier_head(name) \
> - cleanup_srcu_struct(&(name)->srcu);
> -
>  #define ATOMIC_NOTIFIER_INIT(name) { \
>   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
>   .head = NULL }
> @@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
> srcu_notifier_head *nh);
>   .head = NULL }
>  #define RAW_NOTIFIER_INIT(name)  {   \
>   .head = NULL }
> -/* srcu_notifier_heads cannot be initialized statically */
> 
>  #define ATOMIC_NOTIFIER_HEAD(name)   \
>   struct atomic_notifier_head name =  \
> @@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
> - struct notifier_block *nb);
> 
>  extern int blocking_notifier_chain_cond_register(
>   struct blocking_notifier_head *nh,
> @@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
> - struct notifier_block *nb);
> 
>  extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
>   unsigned long val, void *v);
> @@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
> raw_notifier_head *nh,
>   unsigned long val, void *v);
>  extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
>   unsigned long val, void *v, int nr_to_call, int *nr_calls);
> -extern int srcu_notifier_call_chain(struct 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
prevents build failures as KVM is dependent on SRCU.

Signed-off-by: Pranith Kumar 
Acked-by: Christian Borntraeger  [for s390 parts]
CC: Josh Triplett 
CC: Lai Jiangshan 
CC: Paul E. McKenney 
---
 arch/s390/kernel/asm-offsets.c |  7 ++-
 include/linux/notifier.h   | 47 --
 include/linux/srcu.h   |  6 +-
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index ef279a1..055334d 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -7,12 +7,15 @@
 #define ASM_OFFSETS_C
 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#ifdef CONFIG_KVM
+#include 
+#endif
+
 /*
  * Make sure that the compiler is new enough. We want a compiler that
  * is known to work with the "Q" assembler constraint.
@@ -182,8 +185,10 @@ int main(void)
DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
thread.trap_tdb));
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
+#ifdef CONFIG_KVM
DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
+#endif /* CONFIG_KVM */
 #endif /* CONFIG_32BIT */
return 0;
 }
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init(&(name)->lock);  \
(name)->head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)->head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct(&(name)->srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
 #define NOTIFY_DONE0x  /* Don't care */
 #define NOTIFY_OK  0x0001  /* Suits me */
@@ -211,5 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
prevents build failures as KVM is dependent on SRCU.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
Acked-by: Christian Borntraeger borntrae...@de.ibm.com [for s390 parts]
CC: Josh Triplett j...@joshtriplett.org
CC: Lai Jiangshan la...@cn.fujitsu.com
CC: Paul E. McKenney paul...@linux.vnet.ibm.com
---
 arch/s390/kernel/asm-offsets.c |  7 ++-
 include/linux/notifier.h   | 47 --
 include/linux/srcu.h   |  6 +-
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index ef279a1..055334d 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -7,12 +7,15 @@
 #define ASM_OFFSETS_C
 
 #include linux/kbuild.h
-#include linux/kvm_host.h
 #include linux/sched.h
 #include asm/idle.h
 #include asm/vdso.h
 #include asm/pgtable.h
 
+#ifdef CONFIG_KVM
+#include linux/kvm_host.h
+#endif
+
 /*
  * Make sure that the compiler is new enough. We want a compiler that
  * is known to work with the Q assembler constraint.
@@ -182,8 +185,10 @@ int main(void)
DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
thread.trap_tdb));
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
+#ifdef CONFIG_KVM
DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
+#endif /* CONFIG_KVM */
 #endif /* CONFIG_32BIT */
return 0;
 }
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init((name)-lock);  \
(name)-head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)-head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct((name)-srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Paul E. McKenney
On Tue, Dec 09, 2014 at 09:16:46AM -0500, Pranith Kumar wrote:
 Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
 there
 is a compile time failure if srcu is used when not enabled. This was decided 
 to
 be better than waiting until link time for a failure to occur.
 
 Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
 prevents build failures as KVM is dependent on SRCU.

Queued for testing, thank you!

Thanx, Paul

 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 Acked-by: Christian Borntraeger borntrae...@de.ibm.com [for s390 parts]
 CC: Josh Triplett j...@joshtriplett.org
 CC: Lai Jiangshan la...@cn.fujitsu.com
 CC: Paul E. McKenney paul...@linux.vnet.ibm.com
 ---
  arch/s390/kernel/asm-offsets.c |  7 ++-
  include/linux/notifier.h   | 47 
 --
  include/linux/srcu.h   |  6 +-
  3 files changed, 38 insertions(+), 22 deletions(-)
 
 diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
 index ef279a1..055334d 100644
 --- a/arch/s390/kernel/asm-offsets.c
 +++ b/arch/s390/kernel/asm-offsets.c
 @@ -7,12 +7,15 @@
  #define ASM_OFFSETS_C
 
  #include linux/kbuild.h
 -#include linux/kvm_host.h
  #include linux/sched.h
  #include asm/idle.h
  #include asm/vdso.h
  #include asm/pgtable.h
 
 +#ifdef CONFIG_KVM
 +#include linux/kvm_host.h
 +#endif
 +
  /*
   * Make sure that the compiler is new enough. We want a compiler that
   * is known to work with the Q assembler constraint.
 @@ -182,8 +185,10 @@ int main(void)
   DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
   DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
 thread.trap_tdb));
   DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
 +#ifdef CONFIG_KVM
   DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
   DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
 +#endif /* CONFIG_KVM */
  #endif /* CONFIG_32BIT */
   return 0;
  }
 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
 index d14a4c3..fe4f02a 100644
 --- a/include/linux/notifier.h
 +++ b/include/linux/notifier.h
 @@ -47,6 +47,8 @@
   * runtime initialization.
   */
 
 +struct notifier_block;
 +
  typedef  int (*notifier_fn_t)(struct notifier_block *nb,
   unsigned long action, void *data);
 
 @@ -70,12 +72,6 @@ struct raw_notifier_head {
   struct notifier_block __rcu *head;
  };
 
 -struct srcu_notifier_head {
 - struct mutex mutex;
 - struct srcu_struct srcu;
 - struct notifier_block __rcu *head;
 -};
 -
  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
   spin_lock_init((name)-lock);  \
   (name)-head = NULL;\
 @@ -88,11 +84,6 @@ struct srcu_notifier_head {
   (name)-head = NULL;\
   } while (0)
 
 -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
 -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
 -#define srcu_cleanup_notifier_head(name) \
 - cleanup_srcu_struct((name)-srcu);
 -
  #define ATOMIC_NOTIFIER_INIT(name) { \
   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
   .head = NULL }
 @@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
 srcu_notifier_head *nh);
   .head = NULL }
  #define RAW_NOTIFIER_INIT(name)  {   \
   .head = NULL }
 -/* srcu_notifier_heads cannot be initialized statically */
 
  #define ATOMIC_NOTIFIER_HEAD(name)   \
   struct atomic_notifier_head name =  \
 @@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
 
  extern int blocking_notifier_chain_cond_register(
   struct blocking_notifier_head *nh,
 @@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
 
  extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
   unsigned long val, void *v);
 @@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
 raw_notifier_head *nh,
   unsigned long val, void *v);
  extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
   unsigned long val, void *v, int nr_to_call, int 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
prevents build failures as KVM is dependent on SRCU.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
CC: Paul E. McKenney paul...@linux.vnet.ibm.com
CC: Josh Triplett j...@joshtriplett.org
CC: Lai Jiangshan la...@cn.fujitsu.com
Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
---
 arch/s390/kernel/asm-offsets.c |  7 ++-
 include/linux/notifier.h   | 47 --
 include/linux/srcu.h   |  6 +-
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index ef279a1..2813a3c 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -7,12 +7,15 @@
 #define ASM_OFFSETS_C
 
 #include linux/kbuild.h
-#include linux/kvm_host.h
 #include linux/sched.h
 #include asm/idle.h
 #include asm/vdso.h
 #include asm/pgtable.h
 
+#if IS_ENABLED(CONFIG_KVM)
+#include linux/kvm_host.h
+#endif
+
 /*
  * Make sure that the compiler is new enough. We want a compiler that
  * is known to work with the Q assembler constraint.
@@ -182,8 +185,10 @@ int main(void)
DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
thread.trap_tdb));
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
+#if IS_ENABLED(CONFIG_KVM)
DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
+#endif /* CONFIG_KVM */
 #endif /* CONFIG_32BIT */
return 0;
 }
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init((name)-lock);  \
(name)-head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)-head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct((name)-srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Mathieu Desnoyers
- Original Message -
 From: Pranith Kumar bobby.pr...@gmail.com
 To: Martin Schwidefsky schwidef...@de.ibm.com, Heiko Carstens 
 heiko.carst...@de.ibm.com, supporter:S390
 linux...@de.ibm.com, Lai Jiangshan la...@cn.fujitsu.com, Paul E. 
 McKenney paul...@linux.vnet.ibm.com,
 Josh Triplett j...@joshtriplett.org, Steven Rostedt 
 rost...@goodmis.org, Mathieu Desnoyers
 mathieu.desnoy...@efficios.com, Christian Borntraeger 
 borntrae...@de.ibm.com, Jens Freimann
 jf...@linux.vnet.ibm.com, open list:S390 linux-s...@vger.kernel.org, 
 open list
 linux-kernel@vger.kernel.org
 Sent: Tuesday, December 9, 2014 1:48:21 PM
 Subject: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU
 
 Isolate the SRCU functions and data structures within CONFIG_SRCU so that
 there
 is a compile time failure if srcu is used when not enabled. This was decided
 to
 be better than waiting until link time for a failure to occur.
 
 Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
 prevents build failures as KVM is dependent on SRCU.
 
 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 CC: Paul E. McKenney paul...@linux.vnet.ibm.com
 CC: Josh Triplett j...@joshtriplett.org
 CC: Lai Jiangshan la...@cn.fujitsu.com
 Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
 ---
  arch/s390/kernel/asm-offsets.c |  7 ++-
  include/linux/notifier.h   | 47
  --
  include/linux/srcu.h   |  6 +-
  3 files changed, 38 insertions(+), 22 deletions(-)
 
 diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
 index ef279a1..2813a3c 100644
 --- a/arch/s390/kernel/asm-offsets.c
 +++ b/arch/s390/kernel/asm-offsets.c
 @@ -7,12 +7,15 @@
  #define ASM_OFFSETS_C
  
  #include linux/kbuild.h
 -#include linux/kvm_host.h
  #include linux/sched.h
  #include asm/idle.h
  #include asm/vdso.h
  #include asm/pgtable.h
  
 +#if IS_ENABLED(CONFIG_KVM)
 +#include linux/kvm_host.h
 +#endif
 +

Seeing this kind of conditional include makes me cringe. Is there some
way to hide this within linux/kvm_host.h instead ?

Thanks,

Mathieu

  /*
   * Make sure that the compiler is new enough. We want a compiler that
   * is known to work with the Q assembler constraint.
 @@ -182,8 +185,10 @@ int main(void)
   DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
   DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
 thread.trap_tdb));
   DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
 +#if IS_ENABLED(CONFIG_KVM)
   DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
   DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
 +#endif /* CONFIG_KVM */
  #endif /* CONFIG_32BIT */
   return 0;
  }
 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
 index d14a4c3..fe4f02a 100644
 --- a/include/linux/notifier.h
 +++ b/include/linux/notifier.h
 @@ -47,6 +47,8 @@
   * runtime initialization.
   */
  
 +struct notifier_block;
 +
  typedef  int (*notifier_fn_t)(struct notifier_block *nb,
   unsigned long action, void *data);
  
 @@ -70,12 +72,6 @@ struct raw_notifier_head {
   struct notifier_block __rcu *head;
  };
  
 -struct srcu_notifier_head {
 - struct mutex mutex;
 - struct srcu_struct srcu;
 - struct notifier_block __rcu *head;
 -};
 -
  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
   spin_lock_init((name)-lock);  \
   (name)-head = NULL;\
 @@ -88,11 +84,6 @@ struct srcu_notifier_head {
   (name)-head = NULL;\
   } while (0)
  
 -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
 -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
 -#define srcu_cleanup_notifier_head(name) \
 - cleanup_srcu_struct((name)-srcu);
 -
  #define ATOMIC_NOTIFIER_INIT(name) { \
   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
   .head = NULL }
 @@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct
 srcu_notifier_head *nh);
   .head = NULL }
  #define RAW_NOTIFIER_INIT(name)  {   \
   .head = NULL }
 -/* srcu_notifier_heads cannot be initialized statically */
  
  #define ATOMIC_NOTIFIER_HEAD(name)   \
   struct atomic_notifier_head name =  \
 @@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
  
  extern int blocking_notifier_chain_cond_register(
   struct blocking_notifier_head *nh,
 @@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-09 Thread Paul E. McKenney
On Tue, Dec 09, 2014 at 01:48:21PM -0500, Pranith Kumar wrote:
 Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
 there
 is a compile time failure if srcu is used when not enabled. This was decided 
 to
 be better than waiting until link time for a failure to occur.
 
 Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This
 prevents build failures as KVM is dependent on SRCU.
 
 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 CC: Paul E. McKenney paul...@linux.vnet.ibm.com
 CC: Josh Triplett j...@joshtriplett.org
 CC: Lai Jiangshan la...@cn.fujitsu.com
 Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com

Queued for testing (finally), replacing the earlier patch.  ;-)

Thanx, Paul

 ---
  arch/s390/kernel/asm-offsets.c |  7 ++-
  include/linux/notifier.h   | 47 
 --
  include/linux/srcu.h   |  6 +-
  3 files changed, 38 insertions(+), 22 deletions(-)
 
 diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
 index ef279a1..2813a3c 100644
 --- a/arch/s390/kernel/asm-offsets.c
 +++ b/arch/s390/kernel/asm-offsets.c
 @@ -7,12 +7,15 @@
  #define ASM_OFFSETS_C
 
  #include linux/kbuild.h
 -#include linux/kvm_host.h
  #include linux/sched.h
  #include asm/idle.h
  #include asm/vdso.h
  #include asm/pgtable.h
 
 +#if IS_ENABLED(CONFIG_KVM)
 +#include linux/kvm_host.h
 +#endif
 +
  /*
   * Make sure that the compiler is new enough. We want a compiler that
   * is known to work with the Q assembler constraint.
 @@ -182,8 +185,10 @@ int main(void)
   DEFINE(__LC_PGM_TDB, offsetof(struct _lowcore, pgm_tdb));
   DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, 
 thread.trap_tdb));
   DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
 +#if IS_ENABLED(CONFIG_KVM)
   DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
   DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
 +#endif /* CONFIG_KVM */
  #endif /* CONFIG_32BIT */
   return 0;
  }
 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
 index d14a4c3..fe4f02a 100644
 --- a/include/linux/notifier.h
 +++ b/include/linux/notifier.h
 @@ -47,6 +47,8 @@
   * runtime initialization.
   */
 
 +struct notifier_block;
 +
  typedef  int (*notifier_fn_t)(struct notifier_block *nb,
   unsigned long action, void *data);
 
 @@ -70,12 +72,6 @@ struct raw_notifier_head {
   struct notifier_block __rcu *head;
  };
 
 -struct srcu_notifier_head {
 - struct mutex mutex;
 - struct srcu_struct srcu;
 - struct notifier_block __rcu *head;
 -};
 -
  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
   spin_lock_init((name)-lock);  \
   (name)-head = NULL;\
 @@ -88,11 +84,6 @@ struct srcu_notifier_head {
   (name)-head = NULL;\
   } while (0)
 
 -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
 -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
 -#define srcu_cleanup_notifier_head(name) \
 - cleanup_srcu_struct((name)-srcu);
 -
  #define ATOMIC_NOTIFIER_INIT(name) { \
   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
   .head = NULL }
 @@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
 srcu_notifier_head *nh);
   .head = NULL }
  #define RAW_NOTIFIER_INIT(name)  {   \
   .head = NULL }
 -/* srcu_notifier_heads cannot be initialized statically */
 
  #define ATOMIC_NOTIFIER_HEAD(name)   \
   struct atomic_notifier_head name =  \
 @@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
 
  extern int blocking_notifier_chain_cond_register(
   struct blocking_notifier_head *nh,
 @@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
 
  extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
   unsigned long val, void *v);
 @@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
 raw_notifier_head *nh,
   unsigned long val, void *v);
  extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
   unsigned 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-08 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Signed-off-by: Pranith Kumar 
CC: Paul E. McKenney 
CC: Josh Triplett 
CC: Lai Jiangshan 
---
 include/linux/notifier.h | 47 +++
 include/linux/srcu.h |  6 +-
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init(&(name)->lock);  \
(name)->head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)->head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct(&(name)->srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
 #define NOTIFY_DONE0x  /* Don't care */
 #define NOTIFY_OK  0x0001  /* Suits me */
@@ -211,5 +193,30 @@ static inline int notifier_to_errno(int ret)
 
 extern struct blocking_notifier_head reboot_notifier_list;
 
+#ifdef CONFIG_SRCU
+
+struct srcu_notifier_head {
+   struct mutex mutex;
+   struct srcu_struct srcu;
+   struct notifier_block __rcu *head;
+};
+
+/* srcu_notifier_heads must be initialized and cleaned up dynamically
+ * srcu_notifier_heads cannot be initialized statically
+ */
+extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
+#define srcu_cleanup_notifier_head(name) cleanup_srcu_struct(&(name)->srcu)
+
+extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v);
+extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v, int nr_to_call, int *nr_calls);
+
+#endif /* CONFIG_SRCU */
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_NOTIFIER_H */
diff --git a/include/linux/srcu.h 

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-08 Thread Paul E. McKenney
On Mon, Dec 08, 2014 at 10:55:34AM -0500, Pranith Kumar wrote:
> Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
> there
> is a compile time failure if srcu is used when not enabled. This was decided 
> to
> be better than waiting until link time for a failure to occur.

Queued, but the 0day test robot complained, so I dropped it.  Looking
forward to an updated version.  ;-)

Thanx, Paul

> Signed-off-by: Pranith Kumar 
> CC: Paul E. McKenney 
> CC: Josh Triplett 
> CC: Lai Jiangshan 
> ---
>  include/linux/notifier.h | 45 +
>  include/linux/srcu.h |  6 +-
>  2 files changed, 30 insertions(+), 21 deletions(-)
> 
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index d14a4c3..291ecb1 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -70,12 +70,6 @@ struct raw_notifier_head {
>   struct notifier_block __rcu *head;
>  };
> 
> -struct srcu_notifier_head {
> - struct mutex mutex;
> - struct srcu_struct srcu;
> - struct notifier_block __rcu *head;
> -};
> -
>  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
>   spin_lock_init(&(name)->lock);  \
>   (name)->head = NULL;\
> @@ -88,11 +82,6 @@ struct srcu_notifier_head {
>   (name)->head = NULL;\
>   } while (0)
> 
> -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
> -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> -#define srcu_cleanup_notifier_head(name) \
> - cleanup_srcu_struct(&(name)->srcu);
> -
>  #define ATOMIC_NOTIFIER_INIT(name) { \
>   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
>   .head = NULL }
> @@ -101,7 +90,6 @@ extern void srcu_init_notifier_head(struct 
> srcu_notifier_head *nh);
>   .head = NULL }
>  #define RAW_NOTIFIER_INIT(name)  {   \
>   .head = NULL }
> -/* srcu_notifier_heads cannot be initialized statically */
> 
>  #define ATOMIC_NOTIFIER_HEAD(name)   \
>   struct atomic_notifier_head name =  \
> @@ -121,8 +109,6 @@ extern int blocking_notifier_chain_register(struct 
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
> - struct notifier_block *nb);
> 
>  extern int blocking_notifier_chain_cond_register(
>   struct blocking_notifier_head *nh,
> @@ -134,8 +120,6 @@ extern int blocking_notifier_chain_unregister(struct 
> blocking_notifier_head *nh,
>   struct notifier_block *nb);
>  extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
>   struct notifier_block *nb);
> -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
> - struct notifier_block *nb);
> 
>  extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
>   unsigned long val, void *v);
> @@ -149,10 +133,6 @@ extern int raw_notifier_call_chain(struct 
> raw_notifier_head *nh,
>   unsigned long val, void *v);
>  extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
>   unsigned long val, void *v, int nr_to_call, int *nr_calls);
> -extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
> - unsigned long val, void *v);
> -extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
> - unsigned long val, void *v, int nr_to_call, int *nr_calls);
> 
>  #define NOTIFY_DONE  0x  /* Don't care */
>  #define NOTIFY_OK0x0001  /* Suits me */
> @@ -211,5 +191,30 @@ static inline int notifier_to_errno(int ret)
> 
>  extern struct blocking_notifier_head reboot_notifier_list;
> 
> +#ifdef CONFIG_SRCU
> +
> +struct srcu_notifier_head {
> + struct mutex mutex;
> + struct srcu_struct srcu;
> + struct notifier_block __rcu *head;
> +};
> +
> +/* srcu_notifier_heads must be initialized and cleaned up dynamically
> + * srcu_notifier_heads cannot be initialized statically
> + */
> +extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> +#define srcu_cleanup_notifier_head(name) cleanup_srcu_struct(&(name)->srcu)
> +
> +extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
> + struct notifier_block *nb);
> +extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
> + struct notifier_block *nb);
> +extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
> + unsigned long val, void *v);
> +extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
> + unsigned long val, void *v, 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-08 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Signed-off-by: Pranith Kumar 
CC: Paul E. McKenney 
CC: Josh Triplett 
CC: Lai Jiangshan 
---
 include/linux/notifier.h | 45 +
 include/linux/srcu.h |  6 +-
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..291ecb1 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -70,12 +70,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init(&(name)->lock);  \
(name)->head = NULL;\
@@ -88,11 +82,6 @@ struct srcu_notifier_head {
(name)->head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct(&(name)->srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +90,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +109,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +120,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +133,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
 #define NOTIFY_DONE0x  /* Don't care */
 #define NOTIFY_OK  0x0001  /* Suits me */
@@ -211,5 +191,30 @@ static inline int notifier_to_errno(int ret)
 
 extern struct blocking_notifier_head reboot_notifier_list;
 
+#ifdef CONFIG_SRCU
+
+struct srcu_notifier_head {
+   struct mutex mutex;
+   struct srcu_struct srcu;
+   struct notifier_block __rcu *head;
+};
+
+/* srcu_notifier_heads must be initialized and cleaned up dynamically
+ * srcu_notifier_heads cannot be initialized statically
+ */
+extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
+#define srcu_cleanup_notifier_head(name) cleanup_srcu_struct(&(name)->srcu)
+
+extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v);
+extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v, int nr_to_call, int *nr_calls);
+
+#endif /* CONFIG_SRCU */
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_NOTIFIER_H */
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 9cfd962..ed9c389 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -26,6 +26,8 @@
  *
  */
 
+#ifdef CONFIG_SRCU
+
 #ifndef _LINUX_SRCU_H
 #define _LINUX_SRCU_H
 
@@ -249,4 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-08 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
CC: Paul E. McKenney paul...@linux.vnet.ibm.com
CC: Josh Triplett j...@joshtriplett.org
CC: Lai Jiangshan la...@cn.fujitsu.com
---
 include/linux/notifier.h | 45 +
 include/linux/srcu.h |  6 +-
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..291ecb1 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -70,12 +70,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init((name)-lock);  \
(name)-head = NULL;\
@@ -88,11 +82,6 @@ struct srcu_notifier_head {
(name)-head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct((name)-srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +90,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +109,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +120,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +133,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
 #define NOTIFY_DONE0x  /* Don't care */
 #define NOTIFY_OK  0x0001  /* Suits me */
@@ -211,5 +191,30 @@ static inline int notifier_to_errno(int ret)
 
 extern struct blocking_notifier_head reboot_notifier_list;
 
+#ifdef CONFIG_SRCU
+
+struct srcu_notifier_head {
+   struct mutex mutex;
+   struct srcu_struct srcu;
+   struct notifier_block __rcu *head;
+};
+
+/* srcu_notifier_heads must be initialized and cleaned up dynamically
+ * srcu_notifier_heads cannot be initialized statically
+ */
+extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
+#define srcu_cleanup_notifier_head(name) cleanup_srcu_struct((name)-srcu)
+
+extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v);
+extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v, int nr_to_call, int *nr_calls);
+
+#endif /* CONFIG_SRCU */
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_NOTIFIER_H */
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 9cfd962..ed9c389 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -26,6 +26,8 @@
  *
  */
 

Re: [PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-08 Thread Paul E. McKenney
On Mon, Dec 08, 2014 at 10:55:34AM -0500, Pranith Kumar wrote:
 Isolate the SRCU functions and data structures within CONFIG_SRCU so that 
 there
 is a compile time failure if srcu is used when not enabled. This was decided 
 to
 be better than waiting until link time for a failure to occur.

Queued, but the 0day test robot complained, so I dropped it.  Looking
forward to an updated version.  ;-)

Thanx, Paul

 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 CC: Paul E. McKenney paul...@linux.vnet.ibm.com
 CC: Josh Triplett j...@joshtriplett.org
 CC: Lai Jiangshan la...@cn.fujitsu.com
 ---
  include/linux/notifier.h | 45 +
  include/linux/srcu.h |  6 +-
  2 files changed, 30 insertions(+), 21 deletions(-)
 
 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
 index d14a4c3..291ecb1 100644
 --- a/include/linux/notifier.h
 +++ b/include/linux/notifier.h
 @@ -70,12 +70,6 @@ struct raw_notifier_head {
   struct notifier_block __rcu *head;
  };
 
 -struct srcu_notifier_head {
 - struct mutex mutex;
 - struct srcu_struct srcu;
 - struct notifier_block __rcu *head;
 -};
 -
  #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
   spin_lock_init((name)-lock);  \
   (name)-head = NULL;\
 @@ -88,11 +82,6 @@ struct srcu_notifier_head {
   (name)-head = NULL;\
   } while (0)
 
 -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
 -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
 -#define srcu_cleanup_notifier_head(name) \
 - cleanup_srcu_struct((name)-srcu);
 -
  #define ATOMIC_NOTIFIER_INIT(name) { \
   .lock = __SPIN_LOCK_UNLOCKED(name.lock),\
   .head = NULL }
 @@ -101,7 +90,6 @@ extern void srcu_init_notifier_head(struct 
 srcu_notifier_head *nh);
   .head = NULL }
  #define RAW_NOTIFIER_INIT(name)  {   \
   .head = NULL }
 -/* srcu_notifier_heads cannot be initialized statically */
 
  #define ATOMIC_NOTIFIER_HEAD(name)   \
   struct atomic_notifier_head name =  \
 @@ -121,8 +109,6 @@ extern int blocking_notifier_chain_register(struct 
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
 
  extern int blocking_notifier_chain_cond_register(
   struct blocking_notifier_head *nh,
 @@ -134,8 +120,6 @@ extern int blocking_notifier_chain_unregister(struct 
 blocking_notifier_head *nh,
   struct notifier_block *nb);
  extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
   struct notifier_block *nb);
 -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
 - struct notifier_block *nb);
 
  extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
   unsigned long val, void *v);
 @@ -149,10 +133,6 @@ extern int raw_notifier_call_chain(struct 
 raw_notifier_head *nh,
   unsigned long val, void *v);
  extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 -extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
 - unsigned long val, void *v);
 -extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
 - unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
  #define NOTIFY_DONE  0x  /* Don't care */
  #define NOTIFY_OK0x0001  /* Suits me */
 @@ -211,5 +191,30 @@ static inline int notifier_to_errno(int ret)
 
  extern struct blocking_notifier_head reboot_notifier_list;
 
 +#ifdef CONFIG_SRCU
 +
 +struct srcu_notifier_head {
 + struct mutex mutex;
 + struct srcu_struct srcu;
 + struct notifier_block __rcu *head;
 +};
 +
 +/* srcu_notifier_heads must be initialized and cleaned up dynamically
 + * srcu_notifier_heads cannot be initialized statically
 + */
 +extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
 +#define srcu_cleanup_notifier_head(name) cleanup_srcu_struct((name)-srcu)
 +
 +extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
 + struct notifier_block *nb);
 +extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
 + struct notifier_block *nb);
 +extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
 + unsigned long val, void *v);
 +extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
 + unsigned long val, void *v, int nr_to_call, int 

[PATCH] srcu: Isolate srcu sections using CONFIG_SRCU

2014-12-08 Thread Pranith Kumar
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
CC: Paul E. McKenney paul...@linux.vnet.ibm.com
CC: Josh Triplett j...@joshtriplett.org
CC: Lai Jiangshan la...@cn.fujitsu.com
---
 include/linux/notifier.h | 47 +++
 include/linux/srcu.h |  6 +-
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d14a4c3..fe4f02a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -47,6 +47,8 @@
  * runtime initialization.
  */
 
+struct notifier_block;
+
 typedefint (*notifier_fn_t)(struct notifier_block *nb,
unsigned long action, void *data);
 
@@ -70,12 +72,6 @@ struct raw_notifier_head {
struct notifier_block __rcu *head;
 };
 
-struct srcu_notifier_head {
-   struct mutex mutex;
-   struct srcu_struct srcu;
-   struct notifier_block __rcu *head;
-};
-
 #define ATOMIC_INIT_NOTIFIER_HEAD(name) do {   \
spin_lock_init((name)-lock);  \
(name)-head = NULL;\
@@ -88,11 +84,6 @@ struct srcu_notifier_head {
(name)-head = NULL;\
} while (0)
 
-/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
-#define srcu_cleanup_notifier_head(name)   \
-   cleanup_srcu_struct((name)-srcu);
-
 #define ATOMIC_NOTIFIER_INIT(name) {   \
.lock = __SPIN_LOCK_UNLOCKED(name.lock),\
.head = NULL }
@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct 
srcu_notifier_head *nh);
.head = NULL }
 #define RAW_NOTIFIER_INIT(name){   \
.head = NULL }
-/* srcu_notifier_heads cannot be initialized statically */
 
 #define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name =  \
@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int blocking_notifier_chain_cond_register(
struct blocking_notifier_head *nh,
@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct 
blocking_notifier_head *nh,
struct notifier_block *nb);
 extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
-   struct notifier_block *nb);
 
 extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct 
raw_notifier_head *nh,
unsigned long val, void *v);
 extern int __raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v, int nr_to_call, int *nr_calls);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v);
-extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
-   unsigned long val, void *v, int nr_to_call, int *nr_calls);
 
 #define NOTIFY_DONE0x  /* Don't care */
 #define NOTIFY_OK  0x0001  /* Suits me */
@@ -211,5 +193,30 @@ static inline int notifier_to_errno(int ret)
 
 extern struct blocking_notifier_head reboot_notifier_list;
 
+#ifdef CONFIG_SRCU
+
+struct srcu_notifier_head {
+   struct mutex mutex;
+   struct srcu_struct srcu;
+   struct notifier_block __rcu *head;
+};
+
+/* srcu_notifier_heads must be initialized and cleaned up dynamically
+ * srcu_notifier_heads cannot be initialized statically
+ */
+extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
+#define srcu_cleanup_notifier_head(name) cleanup_srcu_struct((name)-srcu)
+
+extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
+   struct notifier_block *nb);
+extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v);
+extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+   unsigned long val, void *v, int nr_to_call, int *nr_calls);
+
+#endif /* CONFIG_SRCU */
+
 #endif /* __KERNEL__ */