To make the ouptput of memcg_css_release_check_kmem() easier to
read after css_stacks rework (patch "cgroup, memcg: Rework css_stacks 
debugging")
inline some functions so we better see where from css_get()/put()
gets called.

https://jira.sw.ru/browse/PSBM-98148
Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 include/bc/beancounter.h | 54 +++++++++++++++++++++++++++++++++++++++-
 kernel/bc/beancounter.c  | 52 --------------------------------------
 mm/memcontrol.c          |  1 +
 3 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/include/bc/beancounter.h b/include/bc/beancounter.h
index a06d9b6ecfd3..e4c501734c91 100644
--- a/include/bc/beancounter.h
+++ b/include/bc/beancounter.h
@@ -132,9 +132,61 @@ static inline struct user_beancounter *cgroup_ub(struct 
cgroup *cg)
                            struct user_beancounter, css);
 }
 
-extern struct cgroup_subsys_state *
+static __always_inline struct cgroup_subsys_state *
 __ub_get_css(struct user_beancounter *ub, int idx);
 
+static __always_inline void __ub_set_css(struct user_beancounter *ub, int idx,
+                        struct cgroup_subsys_state *css)
+{
+       struct cgroup_subsys_state *old_css;
+       unsigned long flags;
+
+       if (css)
+               css_get(css);
+
+       spin_lock_irqsave(&ub->ub_lock, flags);
+       old_css = ub->ub_bound_css[idx];
+       ACCESS_ONCE(ub->ub_bound_css[idx]) = css;
+       spin_unlock_irqrestore(&ub->ub_lock, flags);
+
+       if (old_css)
+               css_put(old_css);
+}
+
+static __always_inline struct cgroup_subsys_state *__ub_get_css(struct 
user_beancounter *ub, int idx)
+{
+       struct cgroup_subsys_state *css, *root_css;
+       unsigned long flags;
+
+       rcu_read_lock();
+retry:
+       css = ACCESS_ONCE(ub->ub_bound_css[idx]);
+       if (likely(css && css_tryget(css))) {
+               rcu_read_unlock();
+               return css;
+       }
+
+       root_css = ub0.ub_bound_css[idx];
+
+       /* cgroup was removed, fall back to the root */
+       spin_lock_irqsave(&ub->ub_lock, flags);
+       if (unlikely(ub->ub_bound_css[idx] != css)) {
+               /* someone did it for us, retry */
+               spin_unlock_irqrestore(&ub->ub_lock, flags);
+               goto retry;
+       }
+       ACCESS_ONCE(ub->ub_bound_css[idx]) = root_css;
+       spin_unlock_irqrestore(&ub->ub_lock, flags);
+
+       rcu_read_unlock();
+
+       if (css)
+               css_put(css);
+
+       css_get(root_css);
+       return root_css;
+}
+
 static inline struct cgroup_subsys_state *
 ub_get_mem_css(struct user_beancounter *ub)
 {
diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index 87d7fb1079c9..287d4c5440a4 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -92,58 +92,6 @@ static struct vfsmount 
*ub_bound_cgroup_mnt[NR_UB_BOUND_CGROUPS];
 #define blkio_cgroup_mnt       (ub_bound_cgroup_mnt[UB_BLKIO_CGROUP])
 #define pids_cgroup_mnt                (ub_bound_cgroup_mnt[UB_PIDS_CGROUP])
 
-static void __ub_set_css(struct user_beancounter *ub, int idx,
-                        struct cgroup_subsys_state *css)
-{
-       struct cgroup_subsys_state *old_css;
-       unsigned long flags;
-
-       if (css)
-               css_get(css);
-
-       spin_lock_irqsave(&ub->ub_lock, flags);
-       old_css = ub->ub_bound_css[idx];
-       ACCESS_ONCE(ub->ub_bound_css[idx]) = css;
-       spin_unlock_irqrestore(&ub->ub_lock, flags);
-
-       if (old_css)
-               css_put(old_css);
-}
-
-struct cgroup_subsys_state *__ub_get_css(struct user_beancounter *ub, int idx)
-{
-       struct cgroup_subsys_state *css, *root_css;
-       unsigned long flags;
-
-       rcu_read_lock();
-retry:
-       css = ACCESS_ONCE(ub->ub_bound_css[idx]);
-       if (likely(css && css_tryget(css))) {
-               rcu_read_unlock();
-               return css;
-       }
-
-       root_css = ub0.ub_bound_css[idx];
-
-       /* cgroup was removed, fall back to the root */
-       spin_lock_irqsave(&ub->ub_lock, flags);
-       if (unlikely(ub->ub_bound_css[idx] != css)) {
-               /* someone did it for us, retry */
-               spin_unlock_irqrestore(&ub->ub_lock, flags);
-               goto retry;
-       }
-       ACCESS_ONCE(ub->ub_bound_css[idx]) = root_css;
-       spin_unlock_irqrestore(&ub->ub_lock, flags);
-
-       rcu_read_unlock();
-
-       if (css)
-               css_put(css);
-
-       css_get(root_css);
-       return root_css;
-}
-
 static void ub_set_mem_css(struct user_beancounter *ub,
                                  struct cgroup_subsys_state *css)
 {
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6c8989f1260d..313af475e2db 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1436,6 +1436,7 @@ struct mem_cgroup *mem_cgroup_from_task(struct 
task_struct *p)
        return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
 }
 
+__always_inline
 struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
 {
        struct mem_cgroup *memcg = NULL;
-- 
2.26.2

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to