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


Groups > linux.kernel > #1600992 > unrolled thread

[PATCH 4/7] kref: Remove WARN_ON for NULL release functions

Started byAndi Kleen <andi@firstfloor.org>
First post2017-03-15 03:20 +0100
Last post2017-03-15 13:30 +0100
Articles 3 — 3 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

  [PATCH 4/7] kref: Remove WARN_ON for NULL release functions Andi Kleen <andi@firstfloor.org> - 2017-03-15 03:20 +0100
    Re: [PATCH 4/7] kref: Remove WARN_ON for NULL release functions Greg KH <gregkh@linuxfoundation.org> - 2017-03-15 03:50 +0100
      Re: [PATCH 4/7] kref: Remove WARN_ON for NULL release functions Peter Zijlstra <peterz@infradead.org> - 2017-03-15 13:30 +0100

#1600992 — [PATCH 4/7] kref: Remove WARN_ON for NULL release functions

FromAndi Kleen <andi@firstfloor.org>
Date2017-03-15 03:20 +0100
Subject[PATCH 4/7] kref: Remove WARN_ON for NULL release functions
Message-ID<tl6HD-OK-9@gated-at.bofh.it>
From: Andi Kleen <ak@linux.intel.com>

The kref functions check for NULL release functions.
This WARN_ON seems rather pointless. We will eventually release and
then just crash nicely. It is also somewhat expensive because
these functions are inlined in a lot of places.
Removing the WARN_ONs saves around 2.3k in this kernel
(likely more in others with more drivers)

   text    data     bss     dec     hex filename
9083992 5367600 11116544        25568136        1862388 vmlinux-before-load-avg
9070166 5367600 11116544        25554310        185ed86 vmlinux-load-avg

Cc: gregkh@linuxfoundation.org
Cc: peterz@infradead.org
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 include/linux/kref.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/linux/kref.h b/include/linux/kref.h
index f4156f88f557..29220724bf1c 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -66,8 +66,6 @@ static inline void kref_get(struct kref *kref)
  */
 static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref))
 {
-	WARN_ON(release == NULL);
-
 	if (refcount_dec_and_test(&kref->refcount)) {
 		release(kref);
 		return 1;
@@ -79,8 +77,6 @@ static inline int kref_put_mutex(struct kref *kref,
 				 void (*release)(struct kref *kref),
 				 struct mutex *lock)
 {
-	WARN_ON(release == NULL);
-
 	if (refcount_dec_and_mutex_lock(&kref->refcount, lock)) {
 		release(kref);
 		return 1;
@@ -92,8 +88,6 @@ static inline int kref_put_lock(struct kref *kref,
 				void (*release)(struct kref *kref),
 				spinlock_t *lock)
 {
-	WARN_ON(release == NULL);
-
 	if (refcount_dec_and_lock(&kref->refcount, lock)) {
 		release(kref);
 		return 1;
-- 
2.9.3

[toc] | [next] | [standalone]


#1601007

FromGreg KH <gregkh@linuxfoundation.org>
Date2017-03-15 03:50 +0100
Message-ID<tl7aG-Zf-7@gated-at.bofh.it>
In reply to#1600992
On Tue, Mar 14, 2017 at 07:14:28PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> The kref functions check for NULL release functions.
> This WARN_ON seems rather pointless. We will eventually release and
> then just crash nicely. It is also somewhat expensive because
> these functions are inlined in a lot of places.
> Removing the WARN_ONs saves around 2.3k in this kernel
> (likely more in others with more drivers)
> 
>    text    data     bss     dec     hex filename
> 9083992 5367600 11116544        25568136        1862388 vmlinux-before-load-avg
> 9070166 5367600 11116544        25554310        185ed86 vmlinux-load-avg

WARN_ON() is heavy, didn't realize that.

No objection from me.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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


#1601357

FromPeter Zijlstra <peterz@infradead.org>
Date2017-03-15 13:30 +0100
Message-ID<tlgdY-7yR-3@gated-at.bofh.it>
In reply to#1601007
On Wed, Mar 15, 2017 at 10:46:56AM +0800, Greg KH wrote:
> On Tue, Mar 14, 2017 at 07:14:28PM -0700, Andi Kleen wrote:
> > From: Andi Kleen <ak@linux.intel.com>
> > 
> > The kref functions check for NULL release functions.
> > This WARN_ON seems rather pointless. We will eventually release and
> > then just crash nicely. It is also somewhat expensive because
> > these functions are inlined in a lot of places.
> > Removing the WARN_ONs saves around 2.3k in this kernel
> > (likely more in others with more drivers)
> > 
> >    text    data     bss     dec     hex filename
> > 9083992 5367600 11116544        25568136        1862388 vmlinux-before-load-avg
> > 9070166 5367600 11116544        25554310        185ed86 vmlinux-load-avg
> 
> WARN_ON() is heavy, didn't realize that.

I actually have patches fixing that.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web