Skip to contentSkip to conversation

lowmemorykiller: Avoid excessive/redundant calling of LMK

PATCH In review Chintan Pandya 1 participant 2 messages Jan 12, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lowmemorykiller: Avoid excessive/redundant calling of LMK

The global shrinker will invoke lowmem_shrink in a loop. The loop will be run (total_scan_pages/batch_size) times. The default batch_size will be 128 which will make shrinker invoking 100s of times. LMK does meaningful work only during first 2-3 times and then rest of the invocations are just CPU cycle waste. Fix that by giving excessively large batch size so that lowmem_shrink will be called just once and in the same try LMK does the needful.

---
 drivers/staging/android/lowmemorykiller.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/android/lowmemorykiller.c +4 -1
index b545d3d..5bf483f 100644
@@ -110,7 +110,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 	if (min_score_adj == OOM_SCORE_ADJ_MAX + 1) {
 		lowmem_print(5, "lowmem_scan %lu, %x, return 0\n",
 			     sc->nr_to_scan, sc->gfp_mask);
-		return 0;
+		return SHRINK_STOP;
 	}
 
 	selected_oom_score_adj = min_score_adj;
@@ -163,6 +163,9 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		set_tsk_thread_flag(selected, TIF_MEMDIE);
 		send_sig(SIGKILL, selected, 0);
 		rem += selected_tasksize;
+	} else {
+		rcu_read_unlock();
+		return SHRINK_STOP;
 	}
 
 	lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
Signature · 10 lines
Chintan Pandya

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

Please ignore this patch. My extreme bad that I merged commit messages applicable to some very old kernel into this patch. Updating shortly.

Quoted 38 lines · Chintan Pandya

The global shrinker will invoke lowmem_shrink in a loop. The loop will be run (total_scan_pages/batch_size) times. The default batch_size will be 128 which will make shrinker invoking 100s of times. LMK does meaningful work only during first 2-3 times and then rest of the invocations are just CPU cycle waste. Fix that by giving excessively large batch size so that lowmem_shrink will be called just once and in the same try LMK does the needful.

---
  drivers/staging/android/lowmemorykiller.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/android/lowmemorykiller.c +4 -1
index b545d3d..5bf483f 100644
@@ -110,7 +110,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
  	if (min_score_adj == OOM_SCORE_ADJ_MAX + 1) {
  		lowmem_print(5, "lowmem_scan %lu, %x, return 0\n",
  			     sc->nr_to_scan, sc->gfp_mask);
-		return 0;
+		return SHRINK_STOP;
  	}
 
  	selected_oom_score_adj = min_score_adj;
@@ -163,6 +163,9 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
  		set_tsk_thread_flag(selected, TIF_MEMDIE);
  		send_sig(SIGKILL, selected, 0);
  		rem += selected_tasksize;
+	} else {
+		rcu_read_unlock();
+		return SHRINK_STOP;
  	}
 
  	lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
Signature · 10 lines
Chintan Pandya

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

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