From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Daniel Wagner <wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
Cc: <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Daniel Wagner
<daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>,
Jamal Hadi Salim <jhs-jkUAjuhPggJWk0Htik3J/w@public.gmane.org>,
John Fastabend
<john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH v0 3/5] cgroup: Protect access to task_cls_classid() when built as module
Date: Fri, 17 Aug 2012 15:35:27 +0800 [thread overview]
Message-ID: <502DF43F.9010209@huawei.com> (raw)
In-Reply-To: <1345126336-20755-4-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
> +#if IS_ENABLED(CONFIG_NET_CLS_CGROUP)
> +extern struct static_key cgroup_cls_enabled;
> +#define clscg_enabled static_key_false(&cgroup_cls_enabled)
> +#endif
> +
If it's built-in, clscg_enabled is always true (after we call cgroup_subsys_init at
boot), so we don't need jump label at all.
> extern void sock_update_classid(struct sock *sk);
>
> #if IS_BUILTIN(CONFIG_NET_CLS_CGROUP)
> @@ -52,7 +58,7 @@ static inline u32 task_cls_classid(struct task_struct *p)
> int id;
> u32 classid = 0;
>
> - if (in_interrupt())
> + if (!clscg_enabled || in_interrupt())
> return 0;
>
> rcu_read_lock();
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 8f67ced..8d3a400 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -327,6 +327,11 @@ int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
> EXPORT_SYMBOL(__sk_backlog_rcv);
>
> #if defined(CONFIG_CGROUPS)
> +#if IS_ENABLED(CONFIG_NET_CLS_CGROUP)
> +struct static_key cgroup_cls_enabled = STATIC_KEY_INIT_FALSE;
> +EXPORT_SYMBOL_GPL(cgroup_cls_enabled);
> +#endif
> +
> #if !defined(CONFIG_NET_CLS_CGROUP)
> int net_cls_subsys_id = -1;
> EXPORT_SYMBOL_GPL(net_cls_subsys_id);
> diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
> index 7743ea8..f40086b 100644
> --- a/net/sched/cls_cgroup.c
> +++ b/net/sched/cls_cgroup.c
> @@ -44,12 +44,17 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
>
> if (cgrp->parent)
> cs->classid = cgrp_cls_state(cgrp->parent)->classid;
> + else if (!clscg_enabled)
> + static_key_slow_inc(&cgroup_cls_enabled);
It's not necessary to check if !clsg_enabled.
>
> return &cs->css;
> }
>
> static void cgrp_destroy(struct cgroup *cgrp)
> {
> + if (!cgrp->parent && clscg_enabled)
> + static_key_slow_dec(&cgroup_cls_enabled);
> +
ditto.
> kfree(cgrp_cls_state(cgrp));
> }
>
>
next prev parent reply other threads:[~2012-08-17 7:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-16 14:12 [PATCH v0 0/5] cgroup: Assign subsystem IDs during compile time Daniel Wagner
2012-08-16 14:12 ` [PATCH v0 2/5] cgroup: Move sock_update_classid() decleration to cls_cgroup.h Daniel Wagner
2012-08-16 14:12 ` [PATCH v0 3/5] cgroup: Protect access to task_cls_classid() when built as module Daniel Wagner
[not found] ` <1345126336-20755-4-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-17 7:35 ` Li Zefan [this message]
[not found] ` <502DF43F.9010209-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2012-08-17 7:55 ` Daniel Wagner
[not found] ` <1345126336-20755-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-16 14:12 ` [PATCH v0 1/5] cgroup: Use empty task_cls_classid() when !CONFIG_NET_CLS(_MODULE) Daniel Wagner
2012-08-16 14:12 ` [PATCH v0 4/5] cgroup: Protect access to task_netprioidx() when built as module Daniel Wagner
2012-08-16 14:12 ` [PATCH v0 5/5] cgroup: Assign subsystem IDs during compile time Daniel Wagner
[not found] ` <1345126336-20755-6-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-16 23:20 ` Tejun Heo
[not found] ` <20120816232010.GJ24861-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-17 7:25 ` Li Zefan
2012-08-17 8:48 ` Daniel Wagner
[not found] ` <502E0552.3080602-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-20 17:51 ` Tejun Heo
2012-08-16 19:05 ` [PATCH v0 0/5] " Neil Horman
[not found] ` <20120816190542.GA8203-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2012-08-16 20:25 ` Daniel Wagner
[not found] ` <502D5737.1010604-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-16 22:37 ` John Fastabend
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=502DF43F.9010209@huawei.com \
--to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org \
--cc=jhs-jkUAjuhPggJWk0Htik3J/w@public.gmane.org \
--cc=john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org \
/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).