LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH] mm: swap: use mem_cgroup_is_root() instead of deferencing css->parent
@ 2019-01-11 18:55 Yang Shi
  2019-01-11 19:11 ` Michal Hocko
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Shi @ 2019-01-11 18:55 UTC (permalink / raw)
  To: ying.huang, tim.c.chen, akpm; +Cc: yang.shi, linux-mm, linux-kernel

mem_cgroup_is_root() is preferred API to check if memcg is root or not.
Use it instead of deferencing css->parent.

Cc: Huang Ying <ying.huang@intel.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
 include/linux/swap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index a8f6d5d..8739063 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -623,7 +623,7 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)
 		return vm_swappiness;
 
 	/* root ? */
-	if (mem_cgroup_disabled() || !memcg->css.parent)
+	if (mem_cgroup_disabled() || mem_cgroup_is_root(memcg))
 		return vm_swappiness;
 
 	return memcg->swappiness;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: swap: use mem_cgroup_is_root() instead of deferencing css->parent
  2019-01-11 18:55 [PATCH] mm: swap: use mem_cgroup_is_root() instead of deferencing css->parent Yang Shi
@ 2019-01-11 19:11 ` Michal Hocko
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2019-01-11 19:11 UTC (permalink / raw)
  To: Yang Shi; +Cc: ying.huang, tim.c.chen, akpm, linux-mm, linux-kernel

On Sat 12-01-19 02:55:13, Yang Shi wrote:
> mem_cgroup_is_root() is preferred API to check if memcg is root or not.
> Use it instead of deferencing css->parent.
> 
> Cc: Huang Ying <ying.huang@intel.com>
> Cc: Tim Chen <tim.c.chen@intel.com>
> Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>

Yes, this is more readable.

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  include/linux/swap.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index a8f6d5d..8739063 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -623,7 +623,7 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)
>  		return vm_swappiness;
>  
>  	/* root ? */
> -	if (mem_cgroup_disabled() || !memcg->css.parent)
> +	if (mem_cgroup_disabled() || mem_cgroup_is_root(memcg))
>  		return vm_swappiness;
>  
>  	return memcg->swappiness;
> -- 
> 1.8.3.1

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 18:55 [PATCH] mm: swap: use mem_cgroup_is_root() instead of deferencing css->parent Yang Shi
2019-01-11 19:11 ` Michal Hocko

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox