Skip to content

Commit 132f9fd

Browse files
kerneltoastRasenkai
authored andcommitted
mm: Omit RCU read lock in list_lru_count_one() when RCU isn't needed
The RCU read lock isn't necessary in list_lru_count_one() when the condition that requires RCU (CONFIG_MEMCG && !CONFIG_SLOB) isn't met. The highly-frequent RCU lock and unlock adds measurable overhead to the shrink_slab() path when it isn't needed. As such, we can simply omit the RCU read lock in this case to improve performance. Signed-off-by: Sultan Alsawaf <[email protected]> Signed-off-by: Kazuki Hashimoto <[email protected]>
1 parent e22ced7 commit 132f9fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mm/list_lru.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ EXPORT_SYMBOL_GPL(list_lru_isolate_move);
178178
unsigned long list_lru_count_one(struct list_lru *lru,
179179
int nid, struct mem_cgroup *memcg)
180180
{
181+
#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
181182
struct list_lru_one *l;
182183
long count;
183184

@@ -190,6 +191,9 @@ unsigned long list_lru_count_one(struct list_lru *lru,
190191
count = 0;
191192

192193
return count;
194+
#else
195+
return READ_ONCE(lru->node[nid].lru.nr_items);
196+
#endif
193197
}
194198
EXPORT_SYMBOL_GPL(list_lru_count_one);
195199

0 commit comments

Comments
 (0)