Re: [PATCH 04/23] hugetlb_cgroup: pass around @hugetlb_cgroup instead of @cgroup

2013-08-02 Thread Michal Hocko
On Thu 01-08-13 17:49:42, Tejun Heo wrote:
> cgroup controller API will be converted to primarily use struct
> cgroup_subsys_state instead of struct cgroup.  In preparation, make
> hugetlb_cgroup functions pass around struct hugetlb_cgroup instead of
> struct cgroup.
> 
> This patch shouldn't cause any behavior differences.
> 
> Signed-off-by: Tejun Heo 
> Cc: Aneesh Kumar K.V 
> Cc: KAMEZAWA Hiroyuki 
> Cc: Michal Hocko 
> Cc: Johannes Weiner 

Reviewed-by: Michal Hocko 

> ---
>  mm/hugetlb_cgroup.c | 22 --
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
> index 50f213f..d2f9fc0 100644
> --- a/mm/hugetlb_cgroup.c
> +++ b/mm/hugetlb_cgroup.c
> @@ -56,17 +56,19 @@ static inline bool hugetlb_cgroup_is_root(struct 
> hugetlb_cgroup *h_cg)
>   return (h_cg == root_h_cgroup);
>  }
>  
> -static inline struct hugetlb_cgroup *parent_hugetlb_cgroup(struct cgroup *cg)
> +static inline struct hugetlb_cgroup *
> +parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg)
>  {
> - if (!cg->parent)
> + struct cgroup *parent = h_cg->css.cgroup->parent;
> +
> + if (!parent)
>   return NULL;
> - return hugetlb_cgroup_from_cgroup(cg->parent);
> + return hugetlb_cgroup_from_cgroup(parent);
>  }
>  
> -static inline bool hugetlb_cgroup_have_usage(struct cgroup *cg)
> +static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg)
>  {
>   int idx;
> - struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cg);
>  
>   for (idx = 0; idx < hugetlb_max_hstate; idx++) {
>   if ((res_counter_read_u64(_cg->hugepage[idx], RES_USAGE)) > 0)
> @@ -115,15 +117,14 @@ static void hugetlb_cgroup_css_free(struct cgroup 
> *cgroup)
>   * page reference and test for page active here. This function
>   * cannot fail.
>   */
> -static void hugetlb_cgroup_move_parent(int idx, struct cgroup *cgroup,
> +static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,
>  struct page *page)
>  {
>   int csize;
>   struct res_counter *counter;
>   struct res_counter *fail_res;
>   struct hugetlb_cgroup *page_hcg;
> - struct hugetlb_cgroup *h_cg   = hugetlb_cgroup_from_cgroup(cgroup);
> - struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(cgroup);
> + struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg);
>  
>   page_hcg = hugetlb_cgroup_from_page(page);
>   /*
> @@ -155,6 +156,7 @@ out:
>   */
>  static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
>  {
> + struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup);
>   struct hstate *h;
>   struct page *page;
>   int idx = 0;
> @@ -163,13 +165,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup 
> *cgroup)
>   for_each_hstate(h) {
>   spin_lock(_lock);
>   list_for_each_entry(page, >hugepage_activelist, lru)
> - hugetlb_cgroup_move_parent(idx, cgroup, page);
> + hugetlb_cgroup_move_parent(idx, h_cg, page);
>  
>   spin_unlock(_lock);
>   idx++;
>   }
>   cond_resched();
> - } while (hugetlb_cgroup_have_usage(cgroup));
> + } while (hugetlb_cgroup_have_usage(h_cg));
>  }
>  
>  int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
> -- 
> 1.8.3.1
> 

-- 
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 04/23] hugetlb_cgroup: pass around @hugetlb_cgroup instead of @cgroup

2013-08-02 Thread Michal Hocko
On Thu 01-08-13 17:49:42, Tejun Heo wrote:
 cgroup controller API will be converted to primarily use struct
 cgroup_subsys_state instead of struct cgroup.  In preparation, make
 hugetlb_cgroup functions pass around struct hugetlb_cgroup instead of
 struct cgroup.
 
 This patch shouldn't cause any behavior differences.
 
 Signed-off-by: Tejun Heo t...@kernel.org
 Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
 Cc: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
 Cc: Michal Hocko mho...@suse.cz
 Cc: Johannes Weiner han...@cmpxchg.org

Reviewed-by: Michal Hocko mho...@suse.cz

 ---
  mm/hugetlb_cgroup.c | 22 --
  1 file changed, 12 insertions(+), 10 deletions(-)
 
 diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
 index 50f213f..d2f9fc0 100644
 --- a/mm/hugetlb_cgroup.c
 +++ b/mm/hugetlb_cgroup.c
 @@ -56,17 +56,19 @@ static inline bool hugetlb_cgroup_is_root(struct 
 hugetlb_cgroup *h_cg)
   return (h_cg == root_h_cgroup);
  }
  
 -static inline struct hugetlb_cgroup *parent_hugetlb_cgroup(struct cgroup *cg)
 +static inline struct hugetlb_cgroup *
 +parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg)
  {
 - if (!cg-parent)
 + struct cgroup *parent = h_cg-css.cgroup-parent;
 +
 + if (!parent)
   return NULL;
 - return hugetlb_cgroup_from_cgroup(cg-parent);
 + return hugetlb_cgroup_from_cgroup(parent);
  }
  
 -static inline bool hugetlb_cgroup_have_usage(struct cgroup *cg)
 +static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg)
  {
   int idx;
 - struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cg);
  
   for (idx = 0; idx  hugetlb_max_hstate; idx++) {
   if ((res_counter_read_u64(h_cg-hugepage[idx], RES_USAGE))  0)
 @@ -115,15 +117,14 @@ static void hugetlb_cgroup_css_free(struct cgroup 
 *cgroup)
   * page reference and test for page active here. This function
   * cannot fail.
   */
 -static void hugetlb_cgroup_move_parent(int idx, struct cgroup *cgroup,
 +static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,
  struct page *page)
  {
   int csize;
   struct res_counter *counter;
   struct res_counter *fail_res;
   struct hugetlb_cgroup *page_hcg;
 - struct hugetlb_cgroup *h_cg   = hugetlb_cgroup_from_cgroup(cgroup);
 - struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(cgroup);
 + struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg);
  
   page_hcg = hugetlb_cgroup_from_page(page);
   /*
 @@ -155,6 +156,7 @@ out:
   */
  static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
  {
 + struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup);
   struct hstate *h;
   struct page *page;
   int idx = 0;
 @@ -163,13 +165,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup 
 *cgroup)
   for_each_hstate(h) {
   spin_lock(hugetlb_lock);
   list_for_each_entry(page, h-hugepage_activelist, lru)
 - hugetlb_cgroup_move_parent(idx, cgroup, page);
 + hugetlb_cgroup_move_parent(idx, h_cg, page);
  
   spin_unlock(hugetlb_lock);
   idx++;
   }
   cond_resched();
 - } while (hugetlb_cgroup_have_usage(cgroup));
 + } while (hugetlb_cgroup_have_usage(h_cg));
  }
  
  int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
 -- 
 1.8.3.1
 

-- 
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 04/23] hugetlb_cgroup: pass around @hugetlb_cgroup instead of @cgroup

2013-08-01 Thread Aneesh Kumar K.V
Tejun Heo  writes:

> cgroup controller API will be converted to primarily use struct
> cgroup_subsys_state instead of struct cgroup.  In preparation, make
> hugetlb_cgroup functions pass around struct hugetlb_cgroup instead of
> struct cgroup.
>
> This patch shouldn't cause any behavior differences.
>
> Signed-off-by: Tejun Heo 
> Cc: Aneesh Kumar K.V 
> Cc: KAMEZAWA Hiroyuki 
> Cc: Michal Hocko 
> Cc: Johannes Weiner 

Reviewed-by: Aneesh Kumar K.V 


> ---
>  mm/hugetlb_cgroup.c | 22 --
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
> index 50f213f..d2f9fc0 100644
> --- a/mm/hugetlb_cgroup.c
> +++ b/mm/hugetlb_cgroup.c
> @@ -56,17 +56,19 @@ static inline bool hugetlb_cgroup_is_root(struct 
> hugetlb_cgroup *h_cg)
>   return (h_cg == root_h_cgroup);
>  }
>
> -static inline struct hugetlb_cgroup *parent_hugetlb_cgroup(struct cgroup *cg)
> +static inline struct hugetlb_cgroup *
> +parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg)
>  {
> - if (!cg->parent)
> + struct cgroup *parent = h_cg->css.cgroup->parent;
> +
> + if (!parent)
>   return NULL;
> - return hugetlb_cgroup_from_cgroup(cg->parent);
> + return hugetlb_cgroup_from_cgroup(parent);
>  }
>
> -static inline bool hugetlb_cgroup_have_usage(struct cgroup *cg)
> +static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg)
>  {
>   int idx;
> - struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cg);
>
>   for (idx = 0; idx < hugetlb_max_hstate; idx++) {
>   if ((res_counter_read_u64(_cg->hugepage[idx], RES_USAGE)) > 0)
> @@ -115,15 +117,14 @@ static void hugetlb_cgroup_css_free(struct cgroup 
> *cgroup)
>   * page reference and test for page active here. This function
>   * cannot fail.
>   */
> -static void hugetlb_cgroup_move_parent(int idx, struct cgroup *cgroup,
> +static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,
>  struct page *page)
>  {
>   int csize;
>   struct res_counter *counter;
>   struct res_counter *fail_res;
>   struct hugetlb_cgroup *page_hcg;
> - struct hugetlb_cgroup *h_cg   = hugetlb_cgroup_from_cgroup(cgroup);
> - struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(cgroup);
> + struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg);
>
>   page_hcg = hugetlb_cgroup_from_page(page);
>   /*
> @@ -155,6 +156,7 @@ out:
>   */
>  static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
>  {
> + struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup);
>   struct hstate *h;
>   struct page *page;
>   int idx = 0;
> @@ -163,13 +165,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup 
> *cgroup)
>   for_each_hstate(h) {
>   spin_lock(_lock);
>   list_for_each_entry(page, >hugepage_activelist, lru)
> - hugetlb_cgroup_move_parent(idx, cgroup, page);
> + hugetlb_cgroup_move_parent(idx, h_cg, page);
>
>   spin_unlock(_lock);
>   idx++;
>   }
>   cond_resched();
> - } while (hugetlb_cgroup_have_usage(cgroup));
> + } while (hugetlb_cgroup_have_usage(h_cg));
>  }
>
>  int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
> -- 
> 1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 04/23] hugetlb_cgroup: pass around @hugetlb_cgroup instead of @cgroup

2013-08-01 Thread Aneesh Kumar K.V
Tejun Heo t...@kernel.org writes:

 cgroup controller API will be converted to primarily use struct
 cgroup_subsys_state instead of struct cgroup.  In preparation, make
 hugetlb_cgroup functions pass around struct hugetlb_cgroup instead of
 struct cgroup.

 This patch shouldn't cause any behavior differences.

 Signed-off-by: Tejun Heo t...@kernel.org
 Cc: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
 Cc: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com
 Cc: Michal Hocko mho...@suse.cz
 Cc: Johannes Weiner han...@cmpxchg.org

Reviewed-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com


 ---
  mm/hugetlb_cgroup.c | 22 --
  1 file changed, 12 insertions(+), 10 deletions(-)

 diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
 index 50f213f..d2f9fc0 100644
 --- a/mm/hugetlb_cgroup.c
 +++ b/mm/hugetlb_cgroup.c
 @@ -56,17 +56,19 @@ static inline bool hugetlb_cgroup_is_root(struct 
 hugetlb_cgroup *h_cg)
   return (h_cg == root_h_cgroup);
  }

 -static inline struct hugetlb_cgroup *parent_hugetlb_cgroup(struct cgroup *cg)
 +static inline struct hugetlb_cgroup *
 +parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg)
  {
 - if (!cg-parent)
 + struct cgroup *parent = h_cg-css.cgroup-parent;
 +
 + if (!parent)
   return NULL;
 - return hugetlb_cgroup_from_cgroup(cg-parent);
 + return hugetlb_cgroup_from_cgroup(parent);
  }

 -static inline bool hugetlb_cgroup_have_usage(struct cgroup *cg)
 +static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg)
  {
   int idx;
 - struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cg);

   for (idx = 0; idx  hugetlb_max_hstate; idx++) {
   if ((res_counter_read_u64(h_cg-hugepage[idx], RES_USAGE))  0)
 @@ -115,15 +117,14 @@ static void hugetlb_cgroup_css_free(struct cgroup 
 *cgroup)
   * page reference and test for page active here. This function
   * cannot fail.
   */
 -static void hugetlb_cgroup_move_parent(int idx, struct cgroup *cgroup,
 +static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,
  struct page *page)
  {
   int csize;
   struct res_counter *counter;
   struct res_counter *fail_res;
   struct hugetlb_cgroup *page_hcg;
 - struct hugetlb_cgroup *h_cg   = hugetlb_cgroup_from_cgroup(cgroup);
 - struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(cgroup);
 + struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg);

   page_hcg = hugetlb_cgroup_from_page(page);
   /*
 @@ -155,6 +156,7 @@ out:
   */
  static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
  {
 + struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup);
   struct hstate *h;
   struct page *page;
   int idx = 0;
 @@ -163,13 +165,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup 
 *cgroup)
   for_each_hstate(h) {
   spin_lock(hugetlb_lock);
   list_for_each_entry(page, h-hugepage_activelist, lru)
 - hugetlb_cgroup_move_parent(idx, cgroup, page);
 + hugetlb_cgroup_move_parent(idx, h_cg, page);

   spin_unlock(hugetlb_lock);
   idx++;
   }
   cond_resched();
 - } while (hugetlb_cgroup_have_usage(cgroup));
 + } while (hugetlb_cgroup_have_usage(h_cg));
  }

  int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,
 -- 
 1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/