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 <sultan@kerneltoast.com> Signed-off-by: priiii1808 <priyanshusinghal0818@gmail.com>
This commit is contained in:
parent
436eb37b50
commit
3764b4f297
1 changed files with 4 additions and 0 deletions
|
@ -174,6 +174,7 @@ EXPORT_SYMBOL_GPL(list_lru_isolate_move);
|
||||||
unsigned long list_lru_count_one(struct list_lru *lru,
|
unsigned long list_lru_count_one(struct list_lru *lru,
|
||||||
int nid, struct mem_cgroup *memcg)
|
int nid, struct mem_cgroup *memcg)
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
|
||||||
struct list_lru_node *nlru = &lru->node[nid];
|
struct list_lru_node *nlru = &lru->node[nid];
|
||||||
struct list_lru_one *l;
|
struct list_lru_one *l;
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
|
@ -184,6 +185,9 @@ unsigned long list_lru_count_one(struct list_lru *lru,
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
#else
|
||||||
|
return READ_ONCE(lru->node[nid].lru.nr_items);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(list_lru_count_one);
|
EXPORT_SYMBOL_GPL(list_lru_count_one);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue