diff mbox

mm: Cleanup in do_shrink_slab()

Message ID 153201627722.12295.11034132843390627757.stgit@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Kirill Tkhai July 19, 2018, 4:04 p.m. UTC
Group long variables together to minimize number of occupied lines
and place all definitions in back Christmas tree order. Also,
simplify expression around batch_size: use all power of C language!

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 mm/vmscan.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Shakeel Butt July 19, 2018, 4:11 p.m. UTC | #1
On Thu, Jul 19, 2018 at 9:04 AM Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
>
> Group long variables together to minimize number of occupied lines
> and place all definitions in back Christmas tree order. Also,
> simplify expression around batch_size: use all power of C language!
>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>

> ---
>  mm/vmscan.c |   11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 9918bfc1d2f9..636657213b9b 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -445,16 +445,11 @@ EXPORT_SYMBOL(unregister_shrinker);
>  static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
>                                     struct shrinker *shrinker, int priority)
>  {
> -       unsigned long freed = 0;
> +       long total_scan, freeable, nr, new_nr, next_deferred, scanned = 0;
> +       long batch_size = shrinker->batch ? : SHRINK_BATCH;
>         unsigned long long delta;
> -       long total_scan;
> -       long freeable;
> -       long nr;
> -       long new_nr;
>         int nid = shrinkctl->nid;
> -       long batch_size = shrinker->batch ? shrinker->batch
> -                                         : SHRINK_BATCH;
> -       long scanned = 0, next_deferred;
> +       unsigned long freed = 0;
>
>         freeable = shrinker->count_objects(shrinker, shrinkctl);
>         if (freeable == 0 || freeable == SHRINK_EMPTY)
>
David Laight July 19, 2018, 4:21 p.m. UTC | #2
From: Kirill Tkhai

> Sent: 19 July 2018 17:05

> 

> Group long variables together to minimize number of occupied lines

> and place all definitions in back Christmas tree order.


Grouping together unrelated variables doesn't really make the code
any more readable.
IMHO One variable per line is usually best.

> Also, simplify expression around batch_size: use all power of C language!


   foo = bar ? : baz;
Is not part of C, it is a gcc extension.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Kirill Tkhai July 19, 2018, 4:27 p.m. UTC | #3
On 19.07.2018 19:21, David Laight wrote:
> From: Kirill Tkhai
>> Sent: 19 July 2018 17:05
>>
>> Group long variables together to minimize number of occupied lines
>> and place all definitions in back Christmas tree order.
> 
> Grouping together unrelated variables doesn't really make the code
> any more readable.
> IMHO One variable per line is usually best.

>> Also, simplify expression around batch_size: use all power of C language!
> 
>    foo = bar ? : baz;
> Is not part of C, it is a gcc extension.

Then, use all power of GNU extensions.
diff mbox

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9918bfc1d2f9..636657213b9b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -445,16 +445,11 @@  EXPORT_SYMBOL(unregister_shrinker);
 static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
 				    struct shrinker *shrinker, int priority)
 {
-	unsigned long freed = 0;
+	long total_scan, freeable, nr, new_nr, next_deferred, scanned = 0;
+	long batch_size = shrinker->batch ? : SHRINK_BATCH;
 	unsigned long long delta;
-	long total_scan;
-	long freeable;
-	long nr;
-	long new_nr;
 	int nid = shrinkctl->nid;
-	long batch_size = shrinker->batch ? shrinker->batch
-					  : SHRINK_BATCH;
-	long scanned = 0, next_deferred;
+	unsigned long freed = 0;
 
 	freeable = shrinker->count_objects(shrinker, shrinkctl);
 	if (freeable == 0 || freeable == SHRINK_EMPTY)