* [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
@ 2016-08-25 15:10 Anson Jacob
2016-08-25 15:26 ` Andrey Utkin
0 siblings, 1 reply; 7+ messages in thread
From: Anson Jacob @ 2016-08-25 15:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, arve, riandrews; +Cc: Kernel List, Staging List
Fix checkpatch.pl 'line over 80 characters' warning
Signed-off-by: Anson Jacob <ansonjacob.aj@gmail.com>
---
drivers/staging/android/lowmemorykiller.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 45a1b4e..80d7adf 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
int array_size = ARRAY_SIZE(lowmem_adj);
int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
int other_file = global_node_page_state(NR_FILE_PAGES) -
- global_node_page_state(NR_SHMEM) -
- total_swapcache_pages();
+ global_node_page_state(NR_SHMEM) -
+ total_swapcache_pages();
if (lowmem_adj_size < array_size)
array_size = lowmem_adj_size;
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
2016-08-25 15:10 [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning Anson Jacob
@ 2016-08-25 15:26 ` Andrey Utkin
2016-09-01 15:36 ` Greg Kroah-Hartman
0 siblings, 1 reply; 7+ messages in thread
From: Andrey Utkin @ 2016-08-25 15:26 UTC (permalink / raw)
To: Anson Jacob
Cc: Greg Kroah-Hartman, arve, riandrews, Staging List, Kernel List
On Thu, Aug 25, 2016 at 11:10:25AM -0400, Anson Jacob wrote:
> Fix checkpatch.pl 'line over 80 characters' warning
>
> Signed-off-by: Anson Jacob <ansonjacob.aj@gmail.com>
> ---
> drivers/staging/android/lowmemorykiller.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> index 45a1b4e..80d7adf 100644
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ b/drivers/staging/android/lowmemorykiller.c
> @@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> int array_size = ARRAY_SIZE(lowmem_adj);
> int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> int other_file = global_node_page_state(NR_FILE_PAGES) -
> - global_node_page_state(NR_SHMEM) -
> - total_swapcache_pages();
> + global_node_page_state(NR_SHMEM) -
> + total_swapcache_pages();
>
> if (lowmem_adj_size < array_size)
> array_size = lowmem_adj_size;
Indeed original alignment on opening brace here doesn't make sense.
I don't mind if your patch gets accepted, but out of curiosity I have opened
this file in vim with kernel coding style plugin loaded
(https://github.com/vivien/vim-linux-coding-style), selected the affected
lines, and reindented the selection by pressing 'gq'. It ended up with this,
being both shorter and simpler:
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 45a1b4e..3aef467 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -92,8 +92,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
int array_size = ARRAY_SIZE(lowmem_adj);
int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
int other_file = global_node_page_state(NR_FILE_PAGES) -
- global_node_page_state(NR_SHMEM) -
- total_swapcache_pages();
+ global_node_page_state(NR_SHMEM) - total_swapcache_pages();
if (lowmem_adj_size < array_size)
array_size = lowmem_adj_size;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
2016-08-25 15:26 ` Andrey Utkin
@ 2016-09-01 15:36 ` Greg Kroah-Hartman
2016-09-01 18:19 ` Joe Perches
0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2016-09-01 15:36 UTC (permalink / raw)
To: Andrey Utkin; +Cc: Anson Jacob, Staging List, arve, riandrews, Kernel List
On Thu, Aug 25, 2016 at 06:26:48PM +0300, Andrey Utkin wrote:
> On Thu, Aug 25, 2016 at 11:10:25AM -0400, Anson Jacob wrote:
> > Fix checkpatch.pl 'line over 80 characters' warning
> >
> > Signed-off-by: Anson Jacob <ansonjacob.aj@gmail.com>
> > ---
> > drivers/staging/android/lowmemorykiller.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> > index 45a1b4e..80d7adf 100644
> > --- a/drivers/staging/android/lowmemorykiller.c
> > +++ b/drivers/staging/android/lowmemorykiller.c
> > @@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > int array_size = ARRAY_SIZE(lowmem_adj);
> > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > - global_node_page_state(NR_SHMEM) -
> > - total_swapcache_pages();
> > + global_node_page_state(NR_SHMEM) -
> > + total_swapcache_pages();
> >
> > if (lowmem_adj_size < array_size)
> > array_size = lowmem_adj_size;
>
> Indeed original alignment on opening brace here doesn't make sense.
> I don't mind if your patch gets accepted, but out of curiosity I have opened
> this file in vim with kernel coding style plugin loaded
> (https://github.com/vivien/vim-linux-coding-style), selected the affected
> lines, and reindented the selection by pressing 'gq'. It ended up with this,
> being both shorter and simpler:
>
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> index 45a1b4e..3aef467 100644
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ b/drivers/staging/android/lowmemorykiller.c
> @@ -92,8 +92,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> int array_size = ARRAY_SIZE(lowmem_adj);
> int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> int other_file = global_node_page_state(NR_FILE_PAGES) -
> - global_node_page_state(NR_SHMEM) -
> - total_swapcache_pages();
> + global_node_page_state(NR_SHMEM) - total_swapcache_pages();
The original patch here is nicer to read, don't you think?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
2016-09-01 15:36 ` Greg Kroah-Hartman
@ 2016-09-01 18:19 ` Joe Perches
2016-09-01 18:33 ` Greg Kroah-Hartman
0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2016-09-01 18:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Andrey Utkin
Cc: Anson Jacob, Staging List, arve, riandrews, Kernel List
On Thu, 2016-09-01 at 17:36 +0200, Greg Kroah-Hartman wrote:
> On Thu, Aug 25, 2016 at 06:26:48PM +0300, Andrey Utkin wrote:
> >
> > On Thu, Aug 25, 2016 at 11:10:25AM -0400, Anson Jacob wrote:
> > >
> > > Fix checkpatch.pl 'line over 80 characters' warning
> > >
> > > Signed-off-by: Anson Jacob <ansonjacob.aj@gmail.com>
> > > ---
> > > drivers/staging/android/lowmemorykiller.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> > > index 45a1b4e..80d7adf 100644
> > > --- a/drivers/staging/android/lowmemorykiller.c
> > > +++ b/drivers/staging/android/lowmemorykiller.c
> > > @@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > > int array_size = ARRAY_SIZE(lowmem_adj);
> > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > > - global_node_page_state(NR_SHMEM) -
> > > - total_swapcache_pages();
> > > + global_node_page_state(NR_SHMEM) -
> > > + total_swapcache_pages();
> > >
> > > if (lowmem_adj_size < array_size)
> > > array_size = lowmem_adj_size;
> > Indeed original alignment on opening brace here doesn't make sense.
> > I don't mind if your patch gets accepted, but out of curiosity I have opened
> > this file in vim with kernel coding style plugin loaded
> > (https://github.com/vivien/vim-linux-coding-style), selected the affected
> > lines, and reindented the selection by pressing 'gq'. It ended up with this,
> > being both shorter and simpler:
> >
> > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> > index 45a1b4e..3aef467 100644
> > --- a/drivers/staging/android/lowmemorykiller.c
> > +++ b/drivers/staging/android/lowmemorykiller.c
> > @@ -92,8 +92,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > int array_size = ARRAY_SIZE(lowmem_adj);
> > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > - global_node_page_state(NR_SHMEM) -
> > - total_swapcache_pages();
> > + global_node_page_state(NR_SHMEM) - total_swapcache_pages();
> The original patch here is nicer to read, don't you think?
Strictly, these should probably be unsigned long instead of int
as that's the return type of global_[node_]page_state().
Maybe something like the below, but then maybe other_free/file
should become unsigned long too.
---
drivers/staging/android/lowmemorykiller.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 45a1b4e..e8e1eaf 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -90,10 +90,11 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
int selected_tasksize = 0;
short selected_oom_score_adj;
int array_size = ARRAY_SIZE(lowmem_adj);
- int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
- int other_file = global_node_page_state(NR_FILE_PAGES) -
- global_node_page_state(NR_SHMEM) -
- total_swapcache_pages();
+ unsigned long nr_free = global_page_state(NR_FREE_PAGES);
+ unsigned long nr_file = global_node_page_state(NR_FILE_PAGES);
+ unsigned long nr_shmem = global_node_page_state(NR_SHMEM);
+ int other_free = nr_free - totalreserve_pages;
+ int other_file = nr_file - nr_shmem - total_swapcache_pages();
if (lowmem_adj_size < array_size)
array_size = lowmem_adj_size;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
2016-09-01 18:19 ` Joe Perches
@ 2016-09-01 18:33 ` Greg Kroah-Hartman
2016-09-01 18:42 ` Joe Perches
0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2016-09-01 18:33 UTC (permalink / raw)
To: Joe Perches
Cc: Andrey Utkin, Anson Jacob, Staging List, arve, riandrews, Kernel List
On Thu, Sep 01, 2016 at 11:19:41AM -0700, Joe Perches wrote:
> On Thu, 2016-09-01 at 17:36 +0200, Greg Kroah-Hartman wrote:
> > On Thu, Aug 25, 2016 at 06:26:48PM +0300, Andrey Utkin wrote:
> > >
> > > On Thu, Aug 25, 2016 at 11:10:25AM -0400, Anson Jacob wrote:
> > > >
> > > > Fix checkpatch.pl 'line over 80 characters' warning
> > > >
> > > > Signed-off-by: Anson Jacob <ansonjacob.aj@gmail.com>
> > > > ---
> > > > drivers/staging/android/lowmemorykiller.c | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> > > > index 45a1b4e..80d7adf 100644
> > > > --- a/drivers/staging/android/lowmemorykiller.c
> > > > +++ b/drivers/staging/android/lowmemorykiller.c
> > > > @@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > > > int array_size = ARRAY_SIZE(lowmem_adj);
> > > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > > > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > > > - global_node_page_state(NR_SHMEM) -
> > > > - total_swapcache_pages();
> > > > + global_node_page_state(NR_SHMEM) -
> > > > + total_swapcache_pages();
> > > >
> > > > if (lowmem_adj_size < array_size)
> > > > array_size = lowmem_adj_size;
> > > Indeed original alignment on opening brace here doesn't make sense.
> > > I don't mind if your patch gets accepted, but out of curiosity I have opened
> > > this file in vim with kernel coding style plugin loaded
> > > (https://github.com/vivien/vim-linux-coding-style), selected the affected
> > > lines, and reindented the selection by pressing 'gq'. It ended up with this,
> > > being both shorter and simpler:
> > >
> > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> > > index 45a1b4e..3aef467 100644
> > > --- a/drivers/staging/android/lowmemorykiller.c
> > > +++ b/drivers/staging/android/lowmemorykiller.c
> > > @@ -92,8 +92,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > > int array_size = ARRAY_SIZE(lowmem_adj);
> > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > > - global_node_page_state(NR_SHMEM) -
> > > - total_swapcache_pages();
> > > + global_node_page_state(NR_SHMEM) - total_swapcache_pages();
> > The original patch here is nicer to read, don't you think?
>
> Strictly, these should probably be unsigned long instead of int
> as that's the return type of global_[node_]page_state().
>
> Maybe something like the below, but then maybe other_free/file
> should become unsigned long too.
> ---
> drivers/staging/android/lowmemorykiller.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> index 45a1b4e..e8e1eaf 100644
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ b/drivers/staging/android/lowmemorykiller.c
> @@ -90,10 +90,11 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> int selected_tasksize = 0;
> short selected_oom_score_adj;
> int array_size = ARRAY_SIZE(lowmem_adj);
> - int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> - int other_file = global_node_page_state(NR_FILE_PAGES) -
> - global_node_page_state(NR_SHMEM) -
> - total_swapcache_pages();
> + unsigned long nr_free = global_page_state(NR_FREE_PAGES);
> + unsigned long nr_file = global_node_page_state(NR_FILE_PAGES);
> + unsigned long nr_shmem = global_node_page_state(NR_SHMEM);
> + int other_free = nr_free - totalreserve_pages;
> + int other_file = nr_file - nr_shmem - total_swapcache_pages();
>
> if (lowmem_adj_size < array_size)
> array_size = lowmem_adj_size;
I like it, much easier to follow. Care to resend it in a patch form I
can apply it in?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
2016-09-01 18:33 ` Greg Kroah-Hartman
@ 2016-09-01 18:42 ` Joe Perches
2016-09-01 21:19 ` Arve Hjønnevåg
0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2016-09-01 18:42 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Andrey Utkin, Anson Jacob, Staging List, arve, riandrews, Kernel List
On Thu, 2016-09-01 at 20:33 +0200, Greg Kroah-Hartman wrote:
> On Thu, Sep 01, 2016 at 11:19:41AM -0700, Joe Perches wrote:
> > On Thu, 2016-09-01 at 17:36 +0200, Greg Kroah-Hartman wrote:
> > > On Thu, Aug 25, 2016 at 06:26:48PM +0300, Andrey Utkin wrote:
> > > > On Thu, Aug 25, 2016 at 11:10:25AM -0400, Anson Jacob wrote:
> > > > > Fix checkpatch.pl 'line over 80 characters' warning
[]
> > > > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
[]
> > > > > @@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > > > > int array_size = ARRAY_SIZE(lowmem_adj);
> > > > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > > > > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > > > > - global_node_page_state(NR_SHMEM) -
> > > > > - total_swapcache_pages();
> > > > > + global_node_page_state(NR_SHMEM) -
> > > > > + total_swapcache_pages();
> > > > >
> > > > > if (lowmem_adj_size < array_size)
> > > > > array_size = lowmem_adj_size;
> > > > Indeed original alignment on opening brace here doesn't make sense.
> > > > I don't mind if your patch gets accepted, but out of curiosity I have opened
> > > > this file in vim with kernel coding style plugin loaded
> > > > (https://github.com/vivien/vim-linux-coding-style), selected the affected
> > > > lines, and reindented the selection by pressing 'gq'. It ended up with this,
> > > > being both shorter and simpler:
> > > >
> > > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
[]
> > > > @@ -92,8 +92,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > > > int array_size = ARRAY_SIZE(lowmem_adj);
> > > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > > > int other_file = global_node_page_state(NR_FILE_PAGES) -
> > > > - global_node_page_state(NR_SHMEM) -
> > > > - total_swapcache_pages();
> > > > + global_node_page_state(NR_SHMEM) - total_swapcache_pages();
> > > The original patch here is nicer to read, don't you think?
> > Strictly, these should probably be unsigned long instead of int
> > as that's the return type of global_[node_]page_state().
> >
> > Maybe something like the below, but then maybe other_free/file
> > should become unsigned long too.
[]
> > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
[]
> > @@ -90,10 +90,11 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> > int selected_tasksize = 0;
> > short selected_oom_score_adj;
> > int array_size = ARRAY_SIZE(lowmem_adj);
> > - int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> > - int other_file = global_node_page_state(NR_FILE_PAGES) -
> > - global_node_page_state(NR_SHMEM) -
> > - total_swapcache_pages();
> > + unsigned long nr_free = global_page_state(NR_FREE_PAGES);
> > + unsigned long nr_file = global_node_page_state(NR_FILE_PAGES);
> > + unsigned long nr_shmem = global_node_page_state(NR_SHMEM);
> > + int other_free = nr_free - totalreserve_pages;
> > + int other_file = nr_file - nr_shmem - total_swapcache_pages();
> >
> > if (lowmem_adj_size < array_size)
> > array_size = lowmem_adj_size;
> I like it, much easier to follow. Care to resend it in a patch form I
> can apply it in?
I think the android folk should figure out what the right thing
to do with the int/unsigned long calculation is first.
Arve? Riley?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning
2016-09-01 18:42 ` Joe Perches
@ 2016-09-01 21:19 ` Arve Hjønnevåg
0 siblings, 0 replies; 7+ messages in thread
From: Arve Hjønnevåg @ 2016-09-01 21:19 UTC (permalink / raw)
To: Joe Perches
Cc: Greg Kroah-Hartman, Andrey Utkin, Anson Jacob, Staging List,
Riley Andrews, Kernel List
On Thu, Sep 1, 2016 at 11:42 AM, Joe Perches <joe@perches.com> wrote:
> On Thu, 2016-09-01 at 20:33 +0200, Greg Kroah-Hartman wrote:
>> On Thu, Sep 01, 2016 at 11:19:41AM -0700, Joe Perches wrote:
>> > On Thu, 2016-09-01 at 17:36 +0200, Greg Kroah-Hartman wrote:
>> > > On Thu, Aug 25, 2016 at 06:26:48PM +0300, Andrey Utkin wrote:
>> > > > On Thu, Aug 25, 2016 at 11:10:25AM -0400, Anson Jacob wrote:
>> > > > > Fix checkpatch.pl 'line over 80 characters' warning
> []
>> > > > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> []
>> > > > > @@ -92,8 +92,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
>> > > > > int array_size = ARRAY_SIZE(lowmem_adj);
>> > > > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
>> > > > > int other_file = global_node_page_state(NR_FILE_PAGES) -
>> > > > > - global_node_page_state(NR_SHMEM) -
>> > > > > - total_swapcache_pages();
>> > > > > + global_node_page_state(NR_SHMEM) -
>> > > > > + total_swapcache_pages();
>> > > > >
>> > > > > if (lowmem_adj_size < array_size)
>> > > > > array_size = lowmem_adj_size;
>> > > > Indeed original alignment on opening brace here doesn't make sense.
>> > > > I don't mind if your patch gets accepted, but out of curiosity I have opened
>> > > > this file in vim with kernel coding style plugin loaded
>> > > > (https://github.com/vivien/vim-linux-coding-style), selected the affected
>> > > > lines, and reindented the selection by pressing 'gq'. It ended up with this,
>> > > > being both shorter and simpler:
>> > > >
>> > > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> []
>> > > > @@ -92,8 +92,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
>> > > > int array_size = ARRAY_SIZE(lowmem_adj);
>> > > > int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
>> > > > int other_file = global_node_page_state(NR_FILE_PAGES) -
>> > > > - global_node_page_state(NR_SHMEM) -
>> > > > - total_swapcache_pages();
>> > > > + global_node_page_state(NR_SHMEM) - total_swapcache_pages();
>> > > The original patch here is nicer to read, don't you think?
>> > Strictly, these should probably be unsigned long instead of int
>> > as that's the return type of global_[node_]page_state().
>> >
>> > Maybe something like the below, but then maybe other_free/file
>> > should become unsigned long too.
> []
>> > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> []
>> > @@ -90,10 +90,11 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
>> > int selected_tasksize = 0;
>> > short selected_oom_score_adj;
>> > int array_size = ARRAY_SIZE(lowmem_adj);
>> > - int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
>> > - int other_file = global_node_page_state(NR_FILE_PAGES) -
>> > - global_node_page_state(NR_SHMEM) -
>> > - total_swapcache_pages();
>> > + unsigned long nr_free = global_page_state(NR_FREE_PAGES);
>> > + unsigned long nr_file = global_node_page_state(NR_FILE_PAGES);
>> > + unsigned long nr_shmem = global_node_page_state(NR_SHMEM);
>> > + int other_free = nr_free - totalreserve_pages;
>> > + int other_file = nr_file - nr_shmem - total_swapcache_pages();
>> >
>> > if (lowmem_adj_size < array_size)
>> > array_size = lowmem_adj_size;
>> I like it, much easier to follow. Care to resend it in a patch form I
>> can apply it in?
>
> I think the android folk should figure out what the right thing
> to do with the int/unsigned long calculation is first.
>
> Arve? Riley?
>
I think the end result is the same if you store it in an int. If you
store the result in a long it will work better, but I don't know of
anyone using lowmemorykilller on a system with more than 8TB of
memory.
--
Arve Hjønnevåg
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-09-01 21:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25 15:10 [PATCH] staging: android: lowmemorykiller.c: Fix checkpatch warning Anson Jacob
2016-08-25 15:26 ` Andrey Utkin
2016-09-01 15:36 ` Greg Kroah-Hartman
2016-09-01 18:19 ` Joe Perches
2016-09-01 18:33 ` Greg Kroah-Hartman
2016-09-01 18:42 ` Joe Perches
2016-09-01 21:19 ` Arve Hjønnevåg
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.