netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Ranjit Manomohan <ranjitm@google.com>
Cc: davem@davemloft.net, akpm@linux-foundation.org, kaber@trash.net,
	lizf@cn.fujitsu.com, menage@google.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 1/2] Traffic control cgroups subsystem
Date: Thu, 11 Sep 2008 00:01:15 +0200	[thread overview]
Message-ID: <20080910220115.GH20815@postel.suug.ch> (raw)
In-Reply-To: <Pine.LNX.4.64.0809101040280.7050@ranjit.corp.google.com>

* Ranjit Manomohan <ranjitm@google.com> 2008-09-10 10:42
> +void cgroup_tc_set_sock_classid(struct sock *sk)
> +{
> +	if (sk)
> +		sk->sk_cgroup_classid = cgroup_tc_classid(current);
> +}
> +
> @@ -1170,6 +1171,8 @@ static int __sock_create(struct net *net, int family, int type, int protocol,
>  	if (err < 0)
>  		goto out_module_put;
> 
> +	cgroup_tc_set_sock_classid(sock->sk);
> +
>  	/*
>  	 * Now to bump the refcnt of the [loadable] module that owns this
>  	 * socket at sock_release time we decrement its refcnt.
> @@ -1444,6 +1447,8 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
>  	if (err < 0)
>  		goto out_fd;
> 
> +	cgroup_tc_set_sock_classid(newsock->sk);
> +
>  	if (upeer_sockaddr) {
>  		if (newsock->ops->getname(newsock, (struct sockaddr *)address,
>  					  &len, 2) < 0) {

The big disadvantage of this method is that it does not allow to change
the classid for sockets which already exist. It inherits the classid
at socket creation time and then sticks to it. So if you want to follow
this approach I'd suggest to at least store a reference to the cgroup
state and reference count it properly.

As for the locking that you mentioned in the other thread. IMHO it is
not possible to lookup a socket without taking at least one lock, but
I might be wrong there. Actually I think it will take even more locks
as different locks are used to f.e. protect listening and established
tcp sockets.

  reply	other threads:[~2008-09-10 22:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-10 17:42 [PATCH 1/2] Traffic control cgroups subsystem Ranjit Manomohan
2008-09-10 22:01 ` Thomas Graf [this message]
2008-09-10 22:56   ` Ranjit Manomohan
2008-09-10 23:00     ` David Miller
2008-09-10 23:14       ` Ranjit Manomohan
2008-09-10 23:04     ` Paul Menage
2008-09-10 23:24       ` Thomas Graf
2008-09-10 23:31         ` Paul Menage
2008-09-10 23:45           ` Thomas Graf
2008-09-10 23:51             ` Paul Menage
2008-09-11  0:07               ` Thomas Graf
2008-09-11  0:09                 ` Paul Menage
2008-09-10 23:53             ` Paul Menage
  -- strict thread matches above, loose matches on Subject: below --
2008-08-22  0:55 Ranjit Manomohan
2008-08-22  2:11 ` Li Zefan
2008-07-24 23:35 Ranjit Manomohan
2008-07-18 21:28 Ranjit Manomohan
2008-07-21  9:26 ` Li Zefan
2008-07-21 14:04 ` Patrick McHardy

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=20080910220115.GH20815@postel.suug.ch \
    --to=tgraf@suug.ch \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=menage@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=ranjitm@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).