netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] sock: make lockdep_sock_is_held static inline
@ 2016-04-07 21:53 Hannes Frederic Sowa
  2016-04-07 22:01 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Hannes Frederic Sowa @ 2016-04-07 21:53 UTC (permalink / raw)
  To: netdev

I forgot to add inline to lockdep_sock_is_held, so it generated all
kinds of build warnings if not build with lockdep support.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 include/net/sock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index eb2d7c3e120b25..46b29374df8ed7 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1360,7 +1360,7 @@ do {									\
 	lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);	\
 } while (0)
 
-static bool lockdep_sock_is_held(const struct sock *csk)
+static inline bool lockdep_sock_is_held(const struct sock *csk)
 {
 	struct sock *sk = (struct sock *)csk;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sock: make lockdep_sock_is_held static inline
  2016-04-07 21:53 [PATCH net-next] sock: make lockdep_sock_is_held static inline Hannes Frederic Sowa
@ 2016-04-07 22:01 ` David Miller
  2016-04-07 22:30 ` Eric Dumazet
  2016-04-07 23:35 ` [PATCH net-next v2] sock: make lockdep_sock_is_held inline and conditional on LOCKDEP Hannes Frederic Sowa
  2 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2016-04-07 22:01 UTC (permalink / raw)
  To: hannes; +Cc: netdev

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Thu,  7 Apr 2016 23:53:35 +0200

> I forgot to add inline to lockdep_sock_is_held, so it generated all
> kinds of build warnings if not build with lockdep support.
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Applied, thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sock: make lockdep_sock_is_held static inline
  2016-04-07 21:53 [PATCH net-next] sock: make lockdep_sock_is_held static inline Hannes Frederic Sowa
  2016-04-07 22:01 ` David Miller
@ 2016-04-07 22:30 ` Eric Dumazet
  2016-04-07 22:37   ` Eric Dumazet
  2016-04-07 23:35 ` [PATCH net-next v2] sock: make lockdep_sock_is_held inline and conditional on LOCKDEP Hannes Frederic Sowa
  2 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2016-04-07 22:30 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: netdev

On Thu, 2016-04-07 at 23:53 +0200, Hannes Frederic Sowa wrote:
> I forgot to add inline to lockdep_sock_is_held, so it generated all
> kinds of build warnings if not build with lockdep support.
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
>  include/net/sock.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/sock.h b/include/net/sock.h
> index eb2d7c3e120b25..46b29374df8ed7 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -1360,7 +1360,7 @@ do {									\
>  	lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);	\
>  } while (0)
>  
> -static bool lockdep_sock_is_held(const struct sock *csk)
> +static inline bool lockdep_sock_is_held(const struct sock *csk)
>  {
>  	struct sock *sk = (struct sock *)csk;
>  


But... this wont solve the compiler error ?

include/net/sock.h: In function 'lockdep_sock_is_held':
include/net/sock.h:1367:2: error: implicit declaration of function
'lockdep_is_held' [-Werror=implicit-function-declaration]
In file included from security/lsm_audit.c:20:0:
include/net/sock.h: In function 'lockdep_sock_is_held':
include/net/sock.h:1367:2: error: implicit declaration of function
'lockdep_is_held' [-Werror=implicit-function-declaration]

$ egrep "LOCKDEP|PROVE" .config
CONFIG_LOCKDEP_SUPPORT=y
# CONFIG_PROVE_LOCKING is not set
# CONFIG_PROVE_RCU is not set

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sock: make lockdep_sock_is_held static inline
  2016-04-07 22:30 ` Eric Dumazet
@ 2016-04-07 22:37   ` Eric Dumazet
  2016-04-07 22:47     ` Hannes Frederic Sowa
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2016-04-07 22:37 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: netdev

On Thu, 2016-04-07 at 15:30 -0700, Eric Dumazet wrote:

> But... this wont solve the compiler error ?
> 
> include/net/sock.h: In function 'lockdep_sock_is_held':
> include/net/sock.h:1367:2: error: implicit declaration of function
> 'lockdep_is_held' [-Werror=implicit-function-declaration]
> In file included from security/lsm_audit.c:20:0:
> include/net/sock.h: In function 'lockdep_sock_is_held':
> include/net/sock.h:1367:2: error: implicit declaration of function
> 'lockdep_is_held' [-Werror=implicit-function-declaration]
> 
> $ egrep "LOCKDEP|PROVE" .config
> CONFIG_LOCKDEP_SUPPORT=y
> # CONFIG_PROVE_LOCKING is not set
> # CONFIG_PROVE_RCU is not set
> 

Better use something like :

diff --git a/include/net/sock.h b/include/net/sock.h
index eb2d7c3e120b..ab6b6b9469ad 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1360,13 +1360,15 @@ do {                                                                    \
        lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);     \
 } while (0)
 
-static bool lockdep_sock_is_held(const struct sock *csk)
+#ifdef CONFIG_PROVE_RCU
+static inline bool lockdep_sock_is_held(const struct sock *csk)
 {
        struct sock *sk = (struct sock *)csk;
 
        return lockdep_is_held(&sk->sk_lock) ||
               lockdep_is_held(&sk->sk_lock.slock);
 }
+#endif
 
 void lock_sock_nested(struct sock *sk, int subclass);
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sock: make lockdep_sock_is_held static inline
  2016-04-07 22:37   ` Eric Dumazet
@ 2016-04-07 22:47     ` Hannes Frederic Sowa
  2016-04-07 23:08       ` Eric Dumazet
  0 siblings, 1 reply; 9+ messages in thread
From: Hannes Frederic Sowa @ 2016-04-07 22:47 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev

On 08.04.2016 00:37, Eric Dumazet wrote:
> On Thu, 2016-04-07 at 15:30 -0700, Eric Dumazet wrote:
>
>> But... this wont solve the compiler error ?
>>
>> include/net/sock.h: In function 'lockdep_sock_is_held':
>> include/net/sock.h:1367:2: error: implicit declaration of function
>> 'lockdep_is_held' [-Werror=implicit-function-declaration]
>> In file included from security/lsm_audit.c:20:0:
>> include/net/sock.h: In function 'lockdep_sock_is_held':
>> include/net/sock.h:1367:2: error: implicit declaration of function
>> 'lockdep_is_held' [-Werror=implicit-function-declaration]
>>
>> $ egrep "LOCKDEP|PROVE" .config
>> CONFIG_LOCKDEP_SUPPORT=y
>> # CONFIG_PROVE_LOCKING is not set
>> # CONFIG_PROVE_RCU is not set
>>
>
> Better use something like :
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index eb2d7c3e120b..ab6b6b9469ad 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -1360,13 +1360,15 @@ do {                                                                    \
>          lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);     \
>   } while (0)
>
> -static bool lockdep_sock_is_held(const struct sock *csk)
> +#ifdef CONFIG_PROVE_RCU
> +static inline bool lockdep_sock_is_held(const struct sock *csk)
>   {
>          struct sock *sk = (struct sock *)csk;
>
>          return lockdep_is_held(&sk->sk_lock) ||
>                 lockdep_is_held(&sk->sk_lock.slock);
>   }
> +#endif

I see... hmpf.

Wouldn't it be nicer if I include a helper a la:

#define lockdep_is_held(lock)  1

in lockdep.h in case lockdep is globally not enabled? I do actually have 
already another user for this outside of PROVE_RCU.

Thanks,
Hannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sock: make lockdep_sock_is_held static inline
  2016-04-07 22:47     ` Hannes Frederic Sowa
@ 2016-04-07 23:08       ` Eric Dumazet
  2016-04-07 23:13         ` Hannes Frederic Sowa
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Dumazet @ 2016-04-07 23:08 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: netdev

On Fri, 2016-04-08 at 00:47 +0200, Hannes Frederic Sowa wrote:

> I see... hmpf.
> 
> Wouldn't it be nicer if I include a helper a la:
> 
> #define lockdep_is_held(lock)  1
> 
> in lockdep.h in case lockdep is globally not enabled? I do actually have 
> already another user for this outside of PROVE_RCU.

It probably had been discussed on lkml a long time ago.

My guess is that you can not do that, but am too lazy to tell you why ;)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next] sock: make lockdep_sock_is_held static inline
  2016-04-07 23:08       ` Eric Dumazet
@ 2016-04-07 23:13         ` Hannes Frederic Sowa
  0 siblings, 0 replies; 9+ messages in thread
From: Hannes Frederic Sowa @ 2016-04-07 23:13 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev

On 08.04.2016 01:08, Eric Dumazet wrote:
> On Fri, 2016-04-08 at 00:47 +0200, Hannes Frederic Sowa wrote:
>
>> I see... hmpf.
>>
>> Wouldn't it be nicer if I include a helper a la:
>>
>> #define lockdep_is_held(lock)  1
>>
>> in lockdep.h in case lockdep is globally not enabled? I do actually have
>> already another user for this outside of PROVE_RCU.
>
> It probably had been discussed on lkml a long time ago.
>
> My guess is that you can not do that, but am too lazy to tell you why ;)

I will simply try it and otherwise go with your solution. My other cases 
would need to be ifdefed then as well, but also possible.

Patch is send out and I will now research after your tip that it was 
already tried.

Thanks,
Hannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net-next v2] sock: make lockdep_sock_is_held inline and conditional on LOCKDEP
  2016-04-07 21:53 [PATCH net-next] sock: make lockdep_sock_is_held static inline Hannes Frederic Sowa
  2016-04-07 22:01 ` David Miller
  2016-04-07 22:30 ` Eric Dumazet
@ 2016-04-07 23:35 ` Hannes Frederic Sowa
  2016-04-08  0:40   ` David Miller
  2 siblings, 1 reply; 9+ messages in thread
From: Hannes Frederic Sowa @ 2016-04-07 23:35 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, David Miller

lockdep_is_held is only specified if CONFIG_LOCKDEP is defined, so make
it depending on it.

Also add the missing inline keyword, so no warnings about unused functions
show up during complilation.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 include/net/sock.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index eb2d7c3e120b25..81d6fecec0a2c0 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1360,13 +1360,15 @@ do {									\
 	lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);	\
 } while (0)
 
-static bool lockdep_sock_is_held(const struct sock *csk)
+#ifdef CONFIG_LOCKDEP
+static inline bool lockdep_sock_is_held(const struct sock *csk)
 {
 	struct sock *sk = (struct sock *)csk;
 
 	return lockdep_is_held(&sk->sk_lock) ||
 	       lockdep_is_held(&sk->sk_lock.slock);
 }
+#endif
 
 void lock_sock_nested(struct sock *sk, int subclass);
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next v2] sock: make lockdep_sock_is_held inline and conditional on LOCKDEP
  2016-04-07 23:35 ` [PATCH net-next v2] sock: make lockdep_sock_is_held inline and conditional on LOCKDEP Hannes Frederic Sowa
@ 2016-04-08  0:40   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2016-04-08  0:40 UTC (permalink / raw)
  To: hannes; +Cc: netdev, eric.dumazet

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Fri,  8 Apr 2016 01:35:18 +0200

> lockdep_is_held is only specified if CONFIG_LOCKDEP is defined, so make
> it depending on it.
> 
> Also add the missing inline keyword, so no warnings about unused functions
> show up during complilation.
> 
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: David Miller <davem@davemloft.net>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

I already applied your inline patch, I applied the following:

====================
[PATCH] net: Fix build failure due to lockdep_sock_is_held().

Needs to be protected with CONFIG_LOCKDEP.

Based upon a patch by Hannes Frederic Sowa.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/net/sock.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index 46b2937..81d6fec 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1360,6 +1360,7 @@ do {									\
 	lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);	\
 } while (0)
 
+#ifdef CONFIG_LOCKDEP
 static inline bool lockdep_sock_is_held(const struct sock *csk)
 {
 	struct sock *sk = (struct sock *)csk;
@@ -1367,6 +1368,7 @@ static inline bool lockdep_sock_is_held(const struct sock *csk)
 	return lockdep_is_held(&sk->sk_lock) ||
 	       lockdep_is_held(&sk->sk_lock.slock);
 }
+#endif
 
 void lock_sock_nested(struct sock *sk, int subclass);
 
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-04-08  0:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-07 21:53 [PATCH net-next] sock: make lockdep_sock_is_held static inline Hannes Frederic Sowa
2016-04-07 22:01 ` David Miller
2016-04-07 22:30 ` Eric Dumazet
2016-04-07 22:37   ` Eric Dumazet
2016-04-07 22:47     ` Hannes Frederic Sowa
2016-04-07 23:08       ` Eric Dumazet
2016-04-07 23:13         ` Hannes Frederic Sowa
2016-04-07 23:35 ` [PATCH net-next v2] sock: make lockdep_sock_is_held inline and conditional on LOCKDEP Hannes Frederic Sowa
2016-04-08  0:40   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).