All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
@ 2013-05-20  9:14 ` Oskar Andero
  0 siblings, 0 replies; 8+ messages in thread
From: Oskar Andero @ 2013-05-20  9:14 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Radovan Lekanovic, David Rientjes, Oskar Andero, Glauber Costa,
	Dave Chinner, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
potential bug if scan_objects returns a negative other than -1, which
would lead to undefined behaviour.

Cc: Glauber Costa <glommer@openvz.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
---
 mm/vmscan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6bac41e..fbe6742 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
 		ret = shrinker->scan_objects(shrinker, shrinkctl);
 		if (ret == -1)
 			break;
+		BUG_ON(ret < -1);
 		freed += ret;
 
 		count_vm_events(SLABS_SCANNED, nr_to_scan);
-- 
1.8.1.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
@ 2013-05-20  9:14 ` Oskar Andero
  0 siblings, 0 replies; 8+ messages in thread
From: Oskar Andero @ 2013-05-20  9:14 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Radovan Lekanovic, David Rientjes, Oskar Andero, Glauber Costa,
	Dave Chinner, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
potential bug if scan_objects returns a negative other than -1, which
would lead to undefined behaviour.

Cc: Glauber Costa <glommer@openvz.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
---
 mm/vmscan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6bac41e..fbe6742 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
 		ret = shrinker->scan_objects(shrinker, shrinkctl);
 		if (ret == -1)
 			break;
+		BUG_ON(ret < -1);
 		freed += ret;
 
 		count_vm_events(SLABS_SCANNED, nr_to_scan);
-- 
1.8.1.5


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

* Re: [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
  2013-05-20  9:14 ` Oskar Andero
@ 2013-05-20 13:56   ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2013-05-20 13:56 UTC (permalink / raw)
  To: Oskar Andero
  Cc: linux-kernel, linux-mm, Radovan Lekanovic, David Rientjes,
	Glauber Costa, Dave Chinner, Andrew Morton, Hugh Dickins

On Mon, May 20, 2013 at 11:14:27AM +0200, Oskar Andero wrote:
> Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
> potential bug if scan_objects returns a negative other than -1, which
> would lead to undefined behaviour.

So it's better to crash a machine and keep anyone from using it?
Instead of recovering from an error you found?  Not good.

greg k-h

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
@ 2013-05-20 13:56   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2013-05-20 13:56 UTC (permalink / raw)
  To: Oskar Andero
  Cc: linux-kernel, linux-mm, Radovan Lekanovic, David Rientjes,
	Glauber Costa, Dave Chinner, Andrew Morton, Hugh Dickins

On Mon, May 20, 2013 at 11:14:27AM +0200, Oskar Andero wrote:
> Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
> potential bug if scan_objects returns a negative other than -1, which
> would lead to undefined behaviour.

So it's better to crash a machine and keep anyone from using it?
Instead of recovering from an error you found?  Not good.

greg k-h

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

* Re: [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
  2013-05-20  9:14 ` Oskar Andero
@ 2013-05-20 22:24   ` David Rientjes
  -1 siblings, 0 replies; 8+ messages in thread
From: David Rientjes @ 2013-05-20 22:24 UTC (permalink / raw)
  To: Oskar Andero
  Cc: linux-kernel, linux-mm, Radovan Lekanovic, Glauber Costa,
	Dave Chinner, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

On Mon, 20 May 2013, Oskar Andero wrote:

> Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
> potential bug if scan_objects returns a negative other than -1, which
> would lead to undefined behaviour.
> 
> Cc: Glauber Costa <glommer@openvz.org>
> Cc: Dave Chinner <dchinner@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
> ---
>  mm/vmscan.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 6bac41e..fbe6742 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
>  		ret = shrinker->scan_objects(shrinker, shrinkctl);
>  		if (ret == -1)
>  			break;
> +		BUG_ON(ret < -1);
>  		freed += ret;
>  
>  		count_vm_events(SLABS_SCANNED, nr_to_scan);

Nack, this doesn't fix anything.  I can see the intention, and for that it 
might make sense to turn this into VM_BUG_ON() so that anybody debugging 
an issue related to this with CONFIG_DEBUG_VM would get the indication, 
but I don't think we need to enforce the API with BUG_ON().

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
@ 2013-05-20 22:24   ` David Rientjes
  0 siblings, 0 replies; 8+ messages in thread
From: David Rientjes @ 2013-05-20 22:24 UTC (permalink / raw)
  To: Oskar Andero
  Cc: linux-kernel, linux-mm, Radovan Lekanovic, Glauber Costa,
	Dave Chinner, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

On Mon, 20 May 2013, Oskar Andero wrote:

> Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
> potential bug if scan_objects returns a negative other than -1, which
> would lead to undefined behaviour.
> 
> Cc: Glauber Costa <glommer@openvz.org>
> Cc: Dave Chinner <dchinner@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
> ---
>  mm/vmscan.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 6bac41e..fbe6742 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
>  		ret = shrinker->scan_objects(shrinker, shrinkctl);
>  		if (ret == -1)
>  			break;
> +		BUG_ON(ret < -1);
>  		freed += ret;
>  
>  		count_vm_events(SLABS_SCANNED, nr_to_scan);

Nack, this doesn't fix anything.  I can see the intention, and for that it 
might make sense to turn this into VM_BUG_ON() so that anybody debugging 
an issue related to this with CONFIG_DEBUG_VM would get the indication, 
but I don't think we need to enforce the API with BUG_ON().

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

* Re: [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
  2013-05-20  9:14 ` Oskar Andero
@ 2013-05-21 10:34   ` Dave Chinner
  -1 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2013-05-21 10:34 UTC (permalink / raw)
  To: Oskar Andero
  Cc: linux-kernel, linux-mm, Radovan Lekanovic, David Rientjes,
	Glauber Costa, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

On Mon, May 20, 2013 at 11:14:27AM +0200, Oskar Andero wrote:
> Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
> potential bug if scan_objects returns a negative other than -1, which
> would lead to undefined behaviour.
> 
> Cc: Glauber Costa <glommer@openvz.org>
> Cc: Dave Chinner <dchinner@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
> ---
>  mm/vmscan.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 6bac41e..fbe6742 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
>  		ret = shrinker->scan_objects(shrinker, shrinkctl);
>  		if (ret == -1)
>  			break;
> +		BUG_ON(ret < -1);
>  		freed += ret;
>  
>  		count_vm_events(SLABS_SCANNED, nr_to_scan);

NACK. we've got to fix the damn shrinkers first.

If you want this sort of guard added to the patchset Glauber and I
are working on that does this, then discuss it in the context of
that patch set.

Even if you do, you'll get the same answer: we need to first all the
busted shrinkers before we even consider being nasty about enforcing
the API constraints to prevent furture breakage.

If you want to do something useful, look at all the comments about
broken shrinkers in Glauber's patch set and work with the owners of
the code to understand what they really need and get them fixed.

-Dave.
-- 
Dave Chinner
dchinner@redhat.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects
@ 2013-05-21 10:34   ` Dave Chinner
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2013-05-21 10:34 UTC (permalink / raw)
  To: Oskar Andero
  Cc: linux-kernel, linux-mm, Radovan Lekanovic, David Rientjes,
	Glauber Costa, Andrew Morton, Hugh Dickins, Greg Kroah-Hartman

On Mon, May 20, 2013 at 11:14:27AM +0200, Oskar Andero wrote:
> Add a BUG_ON to catch any illegal value from the shrinkers. This fixes a
> potential bug if scan_objects returns a negative other than -1, which
> would lead to undefined behaviour.
> 
> Cc: Glauber Costa <glommer@openvz.org>
> Cc: Dave Chinner <dchinner@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
> ---
>  mm/vmscan.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 6bac41e..fbe6742 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -293,6 +293,7 @@ shrink_slab_one(struct shrinker *shrinker, struct shrink_control *shrinkctl,
>  		ret = shrinker->scan_objects(shrinker, shrinkctl);
>  		if (ret == -1)
>  			break;
> +		BUG_ON(ret < -1);
>  		freed += ret;
>  
>  		count_vm_events(SLABS_SCANNED, nr_to_scan);

NACK. we've got to fix the damn shrinkers first.

If you want this sort of guard added to the patchset Glauber and I
are working on that does this, then discuss it in the context of
that patch set.

Even if you do, you'll get the same answer: we need to first all the
busted shrinkers before we even consider being nasty about enforcing
the API constraints to prevent furture breakage.

If you want to do something useful, look at all the comments about
broken shrinkers in Glauber's patch set and work with the owners of
the code to understand what they really need and get them fixed.

-Dave.
-- 
Dave Chinner
dchinner@redhat.com

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

end of thread, other threads:[~2013-05-21 10:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-20  9:14 [PATCH] mm: vmscan: add BUG_ON on illegal return values from scan_objects Oskar Andero
2013-05-20  9:14 ` Oskar Andero
2013-05-20 13:56 ` Greg Kroah-Hartman
2013-05-20 13:56   ` Greg Kroah-Hartman
2013-05-20 22:24 ` David Rientjes
2013-05-20 22:24   ` David Rientjes
2013-05-21 10:34 ` Dave Chinner
2013-05-21 10:34   ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.