@@ -4598,7 +4598,12 @@ static bool should_run_aging(struct lruvec *lruvec, unsigned long max_seq,
4598
4598
}
4599
4599
4600
4600
/* try to scrape all its memory if this memcg was deleted */
4601
- * nr_to_scan = mem_cgroup_online (memcg ) ? (total >> sc -> priority ) : total ;
4601
+ if (!mem_cgroup_online (memcg )) {
4602
+ * nr_to_scan = total ;
4603
+ return false;
4604
+ }
4605
+
4606
+ * nr_to_scan = total >> sc -> priority ;
4602
4607
4603
4608
/*
4604
4609
* The aging tries to be lazy to reduce the overhead, while the eviction
@@ -4719,22 +4724,17 @@ static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)
4719
4724
bool success ;
4720
4725
unsigned long scanned = sc -> nr_scanned ;
4721
4726
unsigned long reclaimed = sc -> nr_reclaimed ;
4722
- int seg = lru_gen_memcg_seg (lruvec );
4723
4727
struct mem_cgroup * memcg = lruvec_memcg (lruvec );
4724
4728
struct pglist_data * pgdat = lruvec_pgdat (lruvec );
4725
4729
4726
- /* see the comment on MEMCG_NR_GENS */
4727
- if (!lruvec_is_sizable (lruvec , sc ))
4728
- return seg != MEMCG_LRU_TAIL ? MEMCG_LRU_TAIL : MEMCG_LRU_YOUNG ;
4729
-
4730
4730
mem_cgroup_calculate_protection (NULL , memcg );
4731
4731
4732
4732
if (mem_cgroup_below_min (NULL , memcg ))
4733
4733
return MEMCG_LRU_YOUNG ;
4734
4734
4735
4735
if (mem_cgroup_below_low (NULL , memcg )) {
4736
4736
/* see the comment on MEMCG_NR_GENS */
4737
- if (seg != MEMCG_LRU_TAIL )
4737
+ if (lru_gen_memcg_seg ( lruvec ) != MEMCG_LRU_TAIL )
4738
4738
return MEMCG_LRU_TAIL ;
4739
4739
4740
4740
memcg_memory_event (memcg , MEMCG_LOW );
@@ -4750,7 +4750,15 @@ static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)
4750
4750
4751
4751
flush_reclaim_state (sc );
4752
4752
4753
- return success ? MEMCG_LRU_YOUNG : 0 ;
4753
+ if (success && mem_cgroup_online (memcg ))
4754
+ return MEMCG_LRU_YOUNG ;
4755
+
4756
+ if (!success && lruvec_is_sizable (lruvec , sc ))
4757
+ return 0 ;
4758
+
4759
+ /* one retry if offlined or too small */
4760
+ return lru_gen_memcg_seg (lruvec ) != MEMCG_LRU_TAIL ?
4761
+ MEMCG_LRU_TAIL : MEMCG_LRU_YOUNG ;
4754
4762
}
4755
4763
4756
4764
#ifdef CONFIG_MEMCG
0 commit comments