Skip to contentSkip to conversation

LMK: Optimize lowmem_shrink

PATCH In review Leon Ma 3 participants 5 messages Aug 20, 2013 – Aug 21, 2013 Staging

lore
Share & tools
lore

Leon Ma

author
#0 lore raw

PATCH 1/1 LMK: Optimize lowmem_shrink

From: Leon Ma <[email protected]>
Date: Mon, 19 Aug 2013 14:22:38 +0800
Subject: [PATCH] LMK: Optimize lowmem_shrink.

By comparing with selected_oom_score_adj instead of min_score_adj, we may do less calculation.

---
 drivers/staging/android/lowmemorykiller.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/android/lowmemorykiller.c
index f6c05c9..cb944c5 100644

drivers/staging/android/lowmemorykiller.c +0 -0
@@ -126,7 +126,7 @@ static int lowmem_shrink(struct shrinker *s, struct

shrink_control *sc)
return 0;
}
oom_score_adj = p->signal->oom_score_adj;
- if (oom_score_adj < min_score_adj) {
+ if (oom_score_adj < selected_oom_score_adj) {
task_unlock(p);
continue;
}
@@ -134,13 +134,9 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
task_unlock(p);
if (tasksize <= 0)
continue;
- if (selected) {
- if (oom_score_adj < selected_oom_score_adj)
- continue;
- if (oom_score_adj == selected_oom_score_adj &&
- tasksize <= selected_tasksize)
- continue;
- }
+ if (selected && oom_score_adj == selected_oom_score_adj &&
+ tasksize <= selected_tasksize)
+ continue;
selected = p;
selected_tasksize = tasksize; selected_oom_score_adj = oom_score_adj;

Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 18 lines · Leon Ma

From: Leon Ma <[email protected]>
Date: Mon, 19 Aug 2013 14:22:38 +0800
Subject: [PATCH] LMK: Optimize lowmem_shrink.

By comparing with selected_oom_score_adj instead of min_score_adj, we may do less calculation.

---
 drivers/staging/android/lowmemorykiller.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/staging/android/lowmemorykiller.c +0 -0
index f6c05c9..cb944c5 100644

drivers/staging/android/lowmemorykiller.c static int lowmem_shrink(struct shrinker *s, struct · line 130

Quoted 6 lines
drivers/staging/android/lowmemorykiller.c +1 -1
@@ -126,7 +126,7 @@ static int lowmem_shrink(struct shrinker *s, struct
 shrink_control *sc)
                        return 0;
                }
                oom_score_adj = p->signal->oom_score_adj;
-               if (oom_score_adj < min_score_adj) {
+               if (oom_score_adj < selected_oom_score_adj) {

This needs to be oom_score_adj <= selected_oom_score_adj.

Quoted 26 lines
drivers/staging/android/lowmemorykiller.c +0 -0
                        task_unlock(p);
                        continue;
                }
drivers/staging/android/lowmemorykiller.c +3 -7
@@ -134,13 +134,9 @@ static int lowmem_shrink(struct shrinker *s, struct
 shrink_control *sc)
                task_unlock(p);
                if (tasksize <= 0)
                        continue;
-               if (selected) {
-                       if (oom_score_adj < selected_oom_score_adj)
-                               continue;
-                       if (oom_score_adj == selected_oom_score_adj &&
-                           tasksize <= selected_tasksize)
-                               continue;
-               }
+               if (selected && oom_score_adj == selected_oom_score_adj &&
+                       tasksize <= selected_tasksize)
+                       continue;
                selected = p;
                selected_tasksize = tasksize;
                selected_oom_score_adj = oom_score_adj;

--
1.7.4.1

#2 lore raw
Quoted 13 lines · Colin Cross
Quoted 12 lines · Leon Ma

From: Leon Ma <[email protected]>
Date: Mon, 19 Aug 2013 14:22:38 +0800
Subject: [PATCH] LMK: Optimize lowmem_shrink.

By comparing with selected_oom_score_adj instead of min_score_adj, we may do less calculation.

---
 drivers/staging/android/lowmemorykiller.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
Quoted 14 lines

drivers/staging/android/lowmemorykiller.c static int lowmem_shrink(struct shrinker *s, struct · line 130

Quoted 12 lines
drivers/staging/android/lowmemorykiller.c +1 -1
index f6c05c9..cb944c5 100644
@@ -126,7 +126,7 @@ static int lowmem_shrink(struct shrinker *s, struct
 shrink_control *sc)
                        return 0;
                }
                oom_score_adj = p->signal->oom_score_adj;
-               if (oom_score_adj < min_score_adj) {
+               if (oom_score_adj < selected_oom_score_adj) {

This needs to be oom_score_adj <= selected_oom_score_adj.

Sorry, got the logic inverted, yours is correct.

Quoted 26 lines
Quoted 26 lines
drivers/staging/android/lowmemorykiller.c +0 -0
                        task_unlock(p);
                        continue;
                }
drivers/staging/android/lowmemorykiller.c +3 -7
@@ -134,13 +134,9 @@ static int lowmem_shrink(struct shrinker *s, struct
 shrink_control *sc)
                task_unlock(p);
                if (tasksize <= 0)
                        continue;
-               if (selected) {
-                       if (oom_score_adj < selected_oom_score_adj)
-                               continue;
-                       if (oom_score_adj == selected_oom_score_adj &&
-                           tasksize <= selected_tasksize)
-                               continue;
-               }
+               if (selected && oom_score_adj == selected_oom_score_adj &&
+                       tasksize <= selected_tasksize)
+                       continue;
                selected = p;
                selected_tasksize = tasksize;
                selected_oom_score_adj = oom_score_adj;

--
1.7.4.1

#3 lore raw
In reply to Leon Ma
Quoted 7 lines · Leon Ma

From: Leon Ma <[email protected]>
Date: Mon, 19 Aug 2013 14:22:38 +0800
Subject: [PATCH] LMK: Optimize lowmem_shrink.

By comparing with selected_oom_score_adj instead of min_score_adj, we may do less calculation.

The patch is line wrapped and doesn't apply.
Read Documentation/email-clients.txt. Send it to yourself first. Save the whole email as raw text (including headers and everything). cat email.txt | git am.
When that works, then resend.

regards,
dan carpenter

#4 lore raw
Quoted 18 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Tuesday, August 20, 2013 4:30 PM
To: Ma, Xindong
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] LMK: Optimize lowmem_shrink

Quoted 7 lines · Leon Ma

From: Leon Ma <[email protected]>
Date: Mon, 19 Aug 2013 14:22:38 +0800
Subject: [PATCH] LMK: Optimize lowmem_shrink.

By comparing with selected_oom_score_adj instead of min_score_adj, we may do less calculation.

Quoted 5 lines

The patch is line wrapped and doesn't apply.
Read Documentation/email-clients.txt. Send it to yourself first. Save the whole email as raw text (including headers and everything). cat email.txt | git am.
When that works, then resend.

Sorry for the trouble. I forgot to click "Prefomatted" in Evolution. I've resend the patch
https://lkml.org/lkml/2013/8/20/754
Please have a review.

Quoted 3 lines

regards,
dan carpenter