[RHEL7,COMMIT] beancounter, memcg: inline some functions for easier debuging

Submitted by Konstantin Khorenko on May 19, 2020, 6:31 p.m.

Details

Message ID 202005191831.04JIVbJo008298@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko May 19, 2020, 6:31 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.151.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.151.2
------>
commit b49de572d21112f344a994e69f146fca619c7b6b
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Tue May 19 21:31:36 2020 +0300

    beancounter, memcg: inline some functions for easier debuging
    
    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 <aryabinin@virtuozzo.com>
---
 include/bc/beancounter.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++-
 kernel/bc/beancounter.c  | 52 ----------------------------------------------
 mm/memcontrol.c          |  1 +
 3 files changed, 54 insertions(+), 53 deletions(-)

Patch hide | download patch | download mbox

diff --git a/include/bc/beancounter.h b/include/bc/beancounter.h
index a06d9b6ecfd3e..e4c501734c91c 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 87d7fb1079c92..287d4c5440a41 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 6492f7d15b563..2f50b46cc24fc 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;