Skip to contentSkip to conversation

hugetlb/cgroup: Remove unnecessary NULL checks

PATCH In review Aneesh Kumar K.V 2 participants 2 messages Jun 24, 2012 – Jun 25, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hugetlb/cgroup: Remove unnecessary NULL checks

From: "Aneesh Kumar K.V" <[email protected]>

cgroup_subsys_state can never be NULL, so don't check for that in hugetlb_cgroup_from_css. Also current task will always be part of some cgroup. So hugetlb_cgrop_from_task cannot return NULL.

---
 mm/hugetlb_cgroup.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
mm/hugetlb_cgroup.c +1 -6
index db40669..b834e8d 100644
@@ -36,9 +36,7 @@ static struct hugetlb_cgroup *root_h_cgroup __read_mostly;
 static inline
 struct hugetlb_cgroup *hugetlb_cgroup_from_css(struct cgroup_subsys_state *s)
 {
-	if (s)
-		return container_of(s, struct hugetlb_cgroup, css);
-	return NULL;
+	return container_of(s, struct hugetlb_cgroup, css);
 }
 
 static inline
@@ -202,9 +200,6 @@ int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
 again:
 	rcu_read_lock();
 	h_cg = hugetlb_cgroup_from_task(current);
-	if (!h_cg)
-		h_cg = root_h_cgroup;
-
 	if (!css_tryget(&h_cg->css)) {
 		rcu_read_unlock();
 		goto again;
Signature · 7 lines
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

cgroup_subsys_state can never be NULL, so don't check for that in hugetlb_cgroup_from_css. Also current task will always be part of some cgroup. So hugetlb_cgrop_from_task cannot return NULL.

Quoted 32 lines
---
 mm/hugetlb_cgroup.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
mm/hugetlb_cgroup.c +1 -6
index db40669..b834e8d 100644
@@ -36,9 +36,7 @@ static struct hugetlb_cgroup *root_h_cgroup __read_mostly;
 static inline
 struct hugetlb_cgroup *hugetlb_cgroup_from_css(struct cgroup_subsys_state *s)
 {
-	if (s)
-		return container_of(s, struct hugetlb_cgroup, css);
-	return NULL;
+	return container_of(s, struct hugetlb_cgroup, css);
 }
 
 static inline
@@ -202,9 +200,6 @@ int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
 again:
 	rcu_read_lock();
 	h_cg = hugetlb_cgroup_from_task(current);
-	if (!h_cg)
-		h_cg = root_h_cgroup;
-
 	if (!css_tryget(&h_cg->css)) {
 		rcu_read_unlock();
 		goto again;
Signature · 1 line
1.7.10
Signature · 12 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>