[Devel] [PATCH RHEL7 COMMIT] mm: Add rcu field to struct list_lru_memcg
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Aug 31 18:25:19 MSK 2017
The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.5
------>
commit b3b3ea1125f07f57ea0f95b29ad368934cc7bb53
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Thu Aug 31 18:25:19 2017 +0300
mm: Add rcu field to struct list_lru_memcg
Patchset description:
Make count list_lru_one::nr_items lockless
This series aims to improve scalability of list_lru shrinking
and to make list_lru_count_one() working more effective.
Kirill Tkhai (3):
mm: Add rcu field to struct list_lru_memcg
mm: Make list_lru_node::memcg_lrus RCU protected
mm: Count list_lru_one::nr_items lockless
https://jira.sw.ru/browse/PSBM-69296
=====================
This patch description:
This patch adds the new field and teaches kmalloc()
to allocate memory for it.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Acked-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
include/linux/list_lru.h | 1 +
mm/list_lru.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 2a6b994..7bf4251 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -31,6 +31,7 @@ struct list_lru_one {
};
struct list_lru_memcg {
+ struct rcu_head rcu;
/* array of per cgroup lists, indexed by memcg_cache_id */
struct list_lru_one *lru[0];
};
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 84b4c21..cb53462 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -313,7 +313,8 @@ static int memcg_init_list_lru_node(struct list_lru_node *nlru)
{
int size = memcg_nr_cache_ids;
- nlru->memcg_lrus = kmalloc(size * sizeof(void *), GFP_KERNEL);
+ nlru->memcg_lrus = kmalloc(sizeof(struct list_lru_memcg) +
+ size * sizeof(void *), GFP_KERNEL);
if (!nlru->memcg_lrus)
return -ENOMEM;
@@ -339,7 +340,7 @@ static int memcg_update_list_lru_node(struct list_lru_node *nlru,
BUG_ON(old_size > new_size);
old = nlru->memcg_lrus;
- new = kmalloc(new_size * sizeof(void *), GFP_KERNEL);
+ new = kmalloc(sizeof(*new) + new_size * sizeof(void *), GFP_KERNEL);
if (!new)
return -ENOMEM;
@@ -348,7 +349,7 @@ static int memcg_update_list_lru_node(struct list_lru_node *nlru,
return -ENOMEM;
}
- memcpy(new, old, old_size * sizeof(void *));
+ memcpy(&new->lru, &old->lru, old_size * sizeof(void *));
/*
* The lock guarantees that we won't race with a reader
More information about the Devel
mailing list