Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1573207 > unrolled thread

Re: [PATCH RT] Align rt_mutex inlining with upstream behavior

Started bySebastian Andrzej Siewior <bigeasy@linutronix.de>
First post2017-02-03 17:00 +0100
Last post2017-02-13 14:30 +0100
Articles 10 — 6 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-02-03 17:00 +0100
    Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Andy Ritger <aritger@nvidia.com> - 2017-02-03 17:50 +0100
      Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Andy Ritger <aritger@nvidia.com> - 2017-02-10 19:20 +0100
        Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-02-10 19:30 +0100
          Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Alex Goins <agoins@nvidia.com> - 2017-02-10 20:20 +0100
          Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Ingo Molnar <mingo@kernel.org> - 2017-02-11 19:00 +0100
            Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Thomas Gleixner <tglx@linutronix.de> - 2017-02-11 21:20 +0100
      Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-02-10 19:30 +0100
        Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Peter Zijlstra <peterz@infradead.org> - 2017-02-13 12:30 +0100
          Re: [PATCH RT] Align rt_mutex inlining with upstream behavior Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-02-13 14:30 +0100

#1573207 — Re: [PATCH RT] Align rt_mutex inlining with upstream behavior

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2017-02-03 17:00 +0100
SubjectRe: [PATCH RT] Align rt_mutex inlining with upstream behavior
Message-ID<t6Org-3Ei-23@gated-at.bofh.it>
On 2017-01-30 09:35:34 [-0800], Andy Ritger wrote:
> The problem is that various static inline functions such as
> reservation_object_fini() indirectly call mutex_destroy.  On DEBUG_MUTEX
> kernels, mutex_destroy is EXPORT_SYMBOL_GPL.

So your problem is simply that your non-GPL module can't link anymore
with -RT.  Would it help you if I simply replace the export for
mutex_destroy with EXPORT_SYMBOL and leave it the function as is?

Sebastian

[toc] | [next] | [standalone]


#1573264

FromAndy Ritger <aritger@nvidia.com>
Date2017-02-03 17:50 +0100
Message-ID<t6PdE-4aP-21@gated-at.bofh.it>
In reply to#1573207
On Fri, Feb 03, 2017 at 04:54:34PM +0100, Sebastian Andrzej Siewior wrote:
> On 2017-01-30 09:35:34 [-0800], Andy Ritger wrote:
> > The problem is that various static inline functions such as
> > reservation_object_fini() indirectly call mutex_destroy.  On DEBUG_MUTEX
> > kernels, mutex_destroy is EXPORT_SYMBOL_GPL.
> 
> So your problem is simply that your non-GPL module can't link anymore
> with -RT.  Would it help you if I simply replace the export for
> mutex_destroy with EXPORT_SYMBOL and leave it the function as is?

Yes, definitely.

Thanks,
- Andy

[toc] | [prev] | [next] | [standalone]


#1578679

FromAndy Ritger <aritger@nvidia.com>
Date2017-02-10 19:20 +0100
Message-ID<t9nXB-6ZO-37@gated-at.bofh.it>
In reply to#1573264
On Fri, Feb 10, 2017 at 06:50:50PM +0100, Sebastian Andrzej Siewior wrote:
> On 2017-02-03 08:49:24 [-0800], Andy Ritger wrote:
> > > So your problem is simply that your non-GPL module can't link anymore
> > > with -RT.  Would it help you if I simply replace the export for
> > > mutex_destroy with EXPORT_SYMBOL and leave it the function as is?
> > 
> > Yes, definitely.
> 
> So this is what I intend to add to the RT patch and I hope Ingo won't
> object:
> 
> Alex Goins reported that mutex_destroy() on RT will force a GPL only symbol
> which won't link and therefore fail on a non-GPL kernel module.
> This does not happen on !RT and is a regression on RT which we would like to
> avoid.
> I try here the easy thing and to not use rt_mutex_destroy() if
> CONFIG_DEBUG_MUTEXES is not enabled. This will still break for the DEBUG
> configs so instead of adding a wrapper around rt_mutex_destroy() (which we have
> for rt_mutex_lock() for instance) I am simply dropping the GPL part from the
> export.

Is the

    WARN_ON(rt_mutex_is_locked(lock));

in rt_mutex_destroy() valuable in non-CONFIG_DEBUG_MUTEXES kernels,
such that it would be better to always call it, and not noop away mutex_destroy()
non-CONFIG_DEBUG_MUTEXES kernels?  I thought that was your objection to
Alex's original patch.

But, with or without the noop-mutex_destroy diff hunk,

    Reviewed-by: Andy Ritger <aritger@nvidia.com>

Thanks,
- Andy

> Reported-by: Alex Goins <agoins@nvidia.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/mutex_rt.h |    5 +++++
>  kernel/locking/rtmutex.c |    3 +--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> --- a/include/linux/mutex_rt.h
> +++ b/include/linux/mutex_rt.h
> @@ -43,7 +43,12 @@ extern void __lockfunc _mutex_unlock(str
>  #define mutex_lock_killable(l)		_mutex_lock_killable(l)
>  #define mutex_trylock(l)		_mutex_trylock(l)
>  #define mutex_unlock(l)			_mutex_unlock(l)
> +
> +#ifdef CONFIG_DEBUG_MUTEXES
>  #define mutex_destroy(l)		rt_mutex_destroy(&(l)->lock)
> +#else
> +static inline void mutex_destroy(struct mutex *lock) {}
> +#endif
>  
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  # define mutex_lock_nested(l, s)	_mutex_lock_nested(l, s)
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -2027,8 +2027,7 @@ void rt_mutex_destroy(struct rt_mutex *l
>  	lock->magic = NULL;
>  #endif
>  }
> -
> -EXPORT_SYMBOL_GPL(rt_mutex_destroy);
> +EXPORT_SYMBOL(rt_mutex_destroy);
>  
>  /**
>   * __rt_mutex_init - initialize the rt lock
> 
> Sebastian

[toc] | [prev] | [next] | [standalone]


#1578681

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2017-02-10 19:30 +0100
Message-ID<t9o7f-73R-5@gated-at.bofh.it>
In reply to#1578679
On 2017-02-10 10:09:29 [-0800], Andy Ritger wrote:
> Is the
> 
>     WARN_ON(rt_mutex_is_locked(lock));
> 
> in rt_mutex_destroy() valuable in non-CONFIG_DEBUG_MUTEXES kernels,
> such that it would be better to always call it, and not noop away mutex_destroy()
> non-CONFIG_DEBUG_MUTEXES kernels?  I thought that was your objection to
> Alex's original patch.

It kind of was…
So first I removed the GPL symbol. Then I wasn't too happy about it
especially since it was not introduced as part of RT. So I reverted that
changed and aligned with mainline behaviour (the mutex_rt.h hunk). But
then I noticed that with CONFIG_DEBUG_MUTEXES=n and
CONFIG_DEBUG_RT_MUTEXES=y we still have a regression compared to !RT and
this was the initial motivation to fix things.
Then I got curious why mutex_lock() (which is essential rt_mutex_lock())
works and noticed the wrapper around it. And while looking at it I
decided to go back to strip the GPL part from export symbol instead of
adding a wrapper. And here I am.
Then I was looking at the patch and decided to align with mainline (and
keep that one hunk) in case Ingo ask for his GPL symbol.

> Thanks,
> - Andy
Sebastian

[toc] | [prev] | [next] | [standalone]


#1578738

FromAlex Goins <agoins@nvidia.com>
Date2017-02-10 20:20 +0100
Message-ID<t9oTE-7BA-13@gated-at.bofh.it>
In reply to#1578681

[Multipart message — attachments visible in raw view] — view raw

This should work.

    Reviewed-by: Alex Goins <agoins@nvidia.com>

Thanks,
Alex

On Fri, 10 Feb 2017, Sebastian Andrzej Siewior wrote:

> On 2017-02-10 10:09:29 [-0800], Andy Ritger wrote:
> > Is the
> > 
> >     WARN_ON(rt_mutex_is_locked(lock));
> > 
> > in rt_mutex_destroy() valuable in non-CONFIG_DEBUG_MUTEXES kernels,
> > such that it would be better to always call it, and not noop away mutex_destroy()
> > non-CONFIG_DEBUG_MUTEXES kernels?  I thought that was your objection to
> > Alex's original patch.
> 
> It kind of was…
> So first I removed the GPL symbol. Then I wasn't too happy about it
> especially since it was not introduced as part of RT. So I reverted that
> changed and aligned with mainline behaviour (the mutex_rt.h hunk). But
> then I noticed that with CONFIG_DEBUG_MUTEXES=n and
> CONFIG_DEBUG_RT_MUTEXES=y we still have a regression compared to !RT and
> this was the initial motivation to fix things.
> Then I got curious why mutex_lock() (which is essential rt_mutex_lock())
> works and noticed the wrapper around it. And while looking at it I
> decided to go back to strip the GPL part from export symbol instead of
> adding a wrapper. And here I am.
> Then I was looking at the patch and decided to align with mainline (and
> keep that one hunk) in case Ingo ask for his GPL symbol.
> 
> > Thanks,
> > - Andy
> Sebastian
> 

[toc] | [prev] | [next] | [standalone]


#1579057

FromIngo Molnar <mingo@kernel.org>
Date2017-02-11 19:00 +0100
Message-ID<t9K7M-3EI-9@gated-at.bofh.it>
In reply to#1578681
* Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> On 2017-02-10 10:09:29 [-0800], Andy Ritger wrote:
> > Is the
> > 
> >     WARN_ON(rt_mutex_is_locked(lock));
> > 
> > in rt_mutex_destroy() valuable in non-CONFIG_DEBUG_MUTEXES kernels,
> > such that it would be better to always call it, and not noop away mutex_destroy()
> > non-CONFIG_DEBUG_MUTEXES kernels?  I thought that was your objection to
> > Alex's original patch.
> 
> It kind of was…
> So first I removed the GPL symbol. Then I wasn't too happy about it
> especially since it was not introduced as part of RT. So I reverted that
> changed and aligned with mainline behaviour (the mutex_rt.h hunk). But
> then I noticed that with CONFIG_DEBUG_MUTEXES=n and
> CONFIG_DEBUG_RT_MUTEXES=y we still have a regression compared to !RT and
> this was the initial motivation to fix things.
> Then I got curious why mutex_lock() (which is essential rt_mutex_lock())
> works and noticed the wrapper around it. And while looking at it I
> decided to go back to strip the GPL part from export symbol instead of
> adding a wrapper. And here I am.
> Then I was looking at the patch and decided to align with mainline (and
> keep that one hunk) in case Ingo ask for his GPL symbol.

tglx and Peter Zijlstra are main co-authors of kernel/locking/rtmutex.c, and every 
author (copyright holder) has to agree to changing a GPL export of a kernel 
subsystem's API to a non-GPL export.

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1579096

FromThomas Gleixner <tglx@linutronix.de>
Date2017-02-11 21:20 +0100
Message-ID<t9Mjf-5a6-7@gated-at.bofh.it>
In reply to#1579057

[Multipart message — attachments visible in raw view] — view raw

On Sat, 11 Feb 2017, Ingo Molnar wrote:

> 
> * Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> 
> > On 2017-02-10 10:09:29 [-0800], Andy Ritger wrote:
> > > Is the
> > > 
> > >     WARN_ON(rt_mutex_is_locked(lock));
> > > 
> > > in rt_mutex_destroy() valuable in non-CONFIG_DEBUG_MUTEXES kernels,
> > > such that it would be better to always call it, and not noop away mutex_destroy()
> > > non-CONFIG_DEBUG_MUTEXES kernels?  I thought that was your objection to
> > > Alex's original patch.
> > 
> > It kind of was…
> > So first I removed the GPL symbol. Then I wasn't too happy about it
> > especially since it was not introduced as part of RT. So I reverted that
> > changed and aligned with mainline behaviour (the mutex_rt.h hunk). But
> > then I noticed that with CONFIG_DEBUG_MUTEXES=n and
> > CONFIG_DEBUG_RT_MUTEXES=y we still have a regression compared to !RT and
> > this was the initial motivation to fix things.
> > Then I got curious why mutex_lock() (which is essential rt_mutex_lock())
> > works and noticed the wrapper around it. And while looking at it I
> > decided to go back to strip the GPL part from export symbol instead of
> > adding a wrapper. And here I am.
> > Then I was looking at the patch and decided to align with mainline (and
> > keep that one hunk) in case Ingo ask for his GPL symbol.
> 
> tglx and Peter Zijlstra are main co-authors of kernel/locking/rtmutex.c, and every 
> author (copyright holder) has to agree to changing a GPL export of a kernel 
> subsystem's API to a non-GPL export.

I'm fine with that change as it really hurts users and makes RT behave the
same way as mainline.

Acked-by: Thomas Gleixner <tglx@linutronix.de>

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1578690

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2017-02-10 19:30 +0100
Message-ID<t9nXB-6ZO-39@gated-at.bofh.it>
In reply to#1573264
On 2017-02-03 08:49:24 [-0800], Andy Ritger wrote:
> > So your problem is simply that your non-GPL module can't link anymore
> > with -RT.  Would it help you if I simply replace the export for
> > mutex_destroy with EXPORT_SYMBOL and leave it the function as is?
> 
> Yes, definitely.

So this is what I intend to add to the RT patch and I hope Ingo won't
object:

Alex Goins reported that mutex_destroy() on RT will force a GPL only symbol
which won't link and therefore fail on a non-GPL kernel module.
This does not happen on !RT and is a regression on RT which we would like to
avoid.
I try here the easy thing and to not use rt_mutex_destroy() if
CONFIG_DEBUG_MUTEXES is not enabled. This will still break for the DEBUG
configs so instead of adding a wrapper around rt_mutex_destroy() (which we have
for rt_mutex_lock() for instance) I am simply dropping the GPL part from the
export.

Reported-by: Alex Goins <agoins@nvidia.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/mutex_rt.h |    5 +++++
 kernel/locking/rtmutex.c |    3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

--- a/include/linux/mutex_rt.h
+++ b/include/linux/mutex_rt.h
@@ -43,7 +43,12 @@ extern void __lockfunc _mutex_unlock(str
 #define mutex_lock_killable(l)		_mutex_lock_killable(l)
 #define mutex_trylock(l)		_mutex_trylock(l)
 #define mutex_unlock(l)			_mutex_unlock(l)
+
+#ifdef CONFIG_DEBUG_MUTEXES
 #define mutex_destroy(l)		rt_mutex_destroy(&(l)->lock)
+#else
+static inline void mutex_destroy(struct mutex *lock) {}
+#endif
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # define mutex_lock_nested(l, s)	_mutex_lock_nested(l, s)
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -2027,8 +2027,7 @@ void rt_mutex_destroy(struct rt_mutex *l
 	lock->magic = NULL;
 #endif
 }
-
-EXPORT_SYMBOL_GPL(rt_mutex_destroy);
+EXPORT_SYMBOL(rt_mutex_destroy);
 
 /**
  * __rt_mutex_init - initialize the rt lock

Sebastian

[toc] | [prev] | [next] | [standalone]


#1579650

FromPeter Zijlstra <peterz@infradead.org>
Date2017-02-13 12:30 +0100
Message-ID<tamZs-323-19@gated-at.bofh.it>
In reply to#1578690
On Fri, Feb 10, 2017 at 06:50:50PM +0100, Sebastian Andrzej Siewior wrote:
> Alex Goins reported that mutex_destroy() on RT will force a GPL only symbol
> which won't link and therefore fail on a non-GPL kernel module.
> This does not happen on !RT and is a regression on RT which we would like to
> avoid.
> I try here the easy thing and to not use rt_mutex_destroy() if
> CONFIG_DEBUG_MUTEXES is not enabled. This will still break for the DEBUG
> configs so instead of adding a wrapper around rt_mutex_destroy() (which we have
> for rt_mutex_lock() for instance) I am simply dropping the GPL part from the
> export.
> 
> Reported-by: Alex Goins <agoins@nvidia.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/mutex_rt.h |    5 +++++
>  kernel/locking/rtmutex.c |    3 +--
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> --- a/include/linux/mutex_rt.h
> +++ b/include/linux/mutex_rt.h
> @@ -43,7 +43,12 @@ extern void __lockfunc _mutex_unlock(str
>  #define mutex_lock_killable(l)		_mutex_lock_killable(l)
>  #define mutex_trylock(l)		_mutex_trylock(l)
>  #define mutex_unlock(l)			_mutex_unlock(l)
> +
> +#ifdef CONFIG_DEBUG_MUTEXES
>  #define mutex_destroy(l)		rt_mutex_destroy(&(l)->lock)
> +#else
> +static inline void mutex_destroy(struct mutex *lock) {}
> +#endif
>  
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  # define mutex_lock_nested(l, s)	_mutex_lock_nested(l, s)
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -2027,8 +2027,7 @@ void rt_mutex_destroy(struct rt_mutex *l
>  	lock->magic = NULL;
>  #endif
>  }
> -
> -EXPORT_SYMBOL_GPL(rt_mutex_destroy);
> +EXPORT_SYMBOL(rt_mutex_destroy);

I don't understand:

$ git grep "EXPORT_SYMBOL.*mutex_destroy"
kernel/locking/mutex-debug.c:EXPORT_SYMBOL_GPL(mutex_destroy);
kernel/locking/rtmutex.c:EXPORT_SYMBOL_GPL(rt_mutex_destroy);

Your proposed patch makes it different from mainline.

[toc] | [prev] | [next] | [standalone]


#1579760

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2017-02-13 14:30 +0100
Message-ID<taoRz-4fA-3@gated-at.bofh.it>
In reply to#1579650
On 2017-02-13 12:20:52 [+0100], Peter Zijlstra wrote:
> > --- a/include/linux/mutex_rt.h
> > +++ b/include/linux/mutex_rt.h
> > @@ -43,7 +43,12 @@ extern void __lockfunc _mutex_unlock(str
> >  #define mutex_lock_killable(l)		_mutex_lock_killable(l)
> >  #define mutex_trylock(l)		_mutex_trylock(l)
> >  #define mutex_unlock(l)			_mutex_unlock(l)
> > +
> > +#ifdef CONFIG_DEBUG_MUTEXES
> >  #define mutex_destroy(l)		rt_mutex_destroy(&(l)->lock)
> > +#else
> > +static inline void mutex_destroy(struct mutex *lock) {}
> > +#endif
> >  
> >  #ifdef CONFIG_DEBUG_LOCK_ALLOC
> >  # define mutex_lock_nested(l, s)	_mutex_lock_nested(l, s)
> > --- a/kernel/locking/rtmutex.c
> > +++ b/kernel/locking/rtmutex.c
> > @@ -2027,8 +2027,7 @@ void rt_mutex_destroy(struct rt_mutex *l
> >  	lock->magic = NULL;
> >  #endif
> >  }
> > -
> > -EXPORT_SYMBOL_GPL(rt_mutex_destroy);
> > +EXPORT_SYMBOL(rt_mutex_destroy);
> 
> I don't understand:
> 
> $ git grep "EXPORT_SYMBOL.*mutex_destroy"
> kernel/locking/mutex-debug.c:EXPORT_SYMBOL_GPL(mutex_destroy);
> kernel/locking/rtmutex.c:EXPORT_SYMBOL_GPL(rt_mutex_destroy);
> 
> Your proposed patch makes it different from mainline.

as discussed off-list, I will drop that _GPL removal hunk and keep only
the (first) inline hunk.
!GPL users should compile with !CONFIG_DEBUG_MUTEXES and
!CONFIG_DEBUG_RT_MUTEXES so there should be no regression.

Sebastian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web