All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Paul Menage <menage@google.com>
Cc: akpm@linux-foundation.org, davem@davemloft.net, tgraf@suug.ch,
	linux-kernel@vger.kernel.org, linux-net@vger.kernel.org
Subject: Re: [PATCH] cls_cgroup: read classid atomically in classifier
Date: Thu, 21 May 2009 08:49:10 +0800	[thread overview]
Message-ID: <4A14A506.2000601@cn.fujitsu.com> (raw)
In-Reply-To: <20090520173426.15291.93021.stgit@menage.mtv.corp.google.com>

(better CC netdev)

Paul Menage wrote:
> cls_cgroup: read classid atomically in classifier
> 
> Avoid reading the unsynchronized value cs->classid multiple times,
> since it could change concurrently from non-zero to zero; this would
> result in the classifier returning a positive result with a bogus
> (zero) classid.
> 

This patch looks nice. It also narrows rcu read section.

Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>

> Signed-off-by: Paul Menage <menage@google.com>
> 
> ---
> 
>  net/sched/cls_cgroup.c |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
> index 1ab4542..4ece6e0 100644
> --- a/net/sched/cls_cgroup.c
> +++ b/net/sched/cls_cgroup.c
> @@ -98,8 +98,7 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
>  			       struct tcf_result *res)
>  {
>  	struct cls_cgroup_head *head = tp->root;
> -	struct cgroup_cls_state *cs;
> -	int ret = 0;
> +        u32 classid;
>  
>  	/*
>  	 * Due to the nature of the classifier it is required to ignore all
> @@ -115,17 +114,18 @@ static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp,
>  		return -1;
>  
>  	rcu_read_lock();
> -	cs = task_cls_state(current);
> -	if (cs->classid && tcf_em_tree_match(skb, &head->ematches, NULL)) {
> -		res->classid = cs->classid;
> -		res->class = 0;
> -		ret = tcf_exts_exec(skb, &head->exts, res);
> -	} else
> -		ret = -1;
> -
> +	classid = task_cls_state(current)->classid;
>  	rcu_read_unlock();
>  
> -	return ret;
> +	if (!classid)
> +		return -1;
> +
> +	if (!tcf_em_tree_match(skb, &head->ematches, NULL))
> +		return -1;
> +
> +	res->classid = classid;
> +	res->class = 0;
> +	return tcf_exts_exec(skb, &head->exts, res);
>  }
>  
>  static unsigned long cls_cgroup_get(struct tcf_proto *tp, u32 handle)
> 
> 
> 

  reply	other threads:[~2009-05-21  0:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-20 17:34 [PATCH] cls_cgroup: read classid atomically in classifier Paul Menage
2009-05-21  0:49 ` Li Zefan [this message]
2009-05-21  3:40   ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2009-05-21 18:31 Paul Menage
2009-05-21 19:44 ` Jiri Pirko
2009-05-21 22:22   ` David Miller
2009-05-26 19:59 Paul Menage
2009-05-26 21:04 ` Andrew Morton
2009-05-26 21:39   ` Paul Menage
2009-05-27  3:47 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A14A506.2000601@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    --cc=menage@google.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.