From: Daniel Wagner <wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: 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>,
Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH v2 04/10] cgroup: net_prio: Protect access to task_netprioidx() when built as module
Date: Fri, 24 Aug 2012 16:01:38 +0200 [thread overview]
Message-ID: <1345816904-21745-5-git-send-email-wagi@monom.org> (raw)
In-Reply-To: <1345816904-21745-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
From: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
The module version of task_netprioidex() checks if net_prio_subsys_id
is valid to indentify when it is okay to access the controller.
Instead relying on the net_prio_subsys_id to be set, make it explicit
with a jump label.
Signed-off-by: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Cc: Jamal Hadi Salim <jhs-jkUAjuhPggJWk0Htik3J/w@public.gmane.org>
Cc: John Fastabend <john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
include/net/netprio_cgroup.h | 8 +++++++-
net/core/netprio_cgroup.c | 9 +++++++++
net/core/sock.c | 4 ++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h
index 2719dec..9ff58e4 100644
--- a/include/net/netprio_cgroup.h
+++ b/include/net/netprio_cgroup.h
@@ -16,7 +16,7 @@
#include <linux/cgroup.h>
#include <linux/hardirq.h>
#include <linux/rcupdate.h>
-
+#include <linux/jump_label.h>
struct netprio_map {
struct rcu_head rcu;
@@ -54,12 +54,18 @@ static inline u32 task_netprioidx(struct task_struct *p)
#elif IS_MODULE(CONFIG_NETPRIO_CGROUP)
+extern struct static_key cgroup_netprio_enabled;
+#define netpriocg_enabled static_key_false(&cgroup_netprio_enabled)
+
static inline u32 task_netprioidx(struct task_struct *p)
{
struct cgroup_netprio_state *state;
int subsys_id;
u32 idx = 0;
+ if (!netpriocg_enabled)
+ return 0;
+
rcu_read_lock();
subsys_id = rcu_dereference_index_check(net_prio_subsys_id,
rcu_read_lock_held());
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index c75e3f9..400ab94 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -371,6 +371,10 @@ static int __init init_cgroup_netprio(void)
net_prio_subsys_id = net_prio_subsys.subsys_id;
#endif
+#if IS_MODULE(CONFIG_NETPRIO_CGROUP)
+ static_key_slow_inc(&cgroup_netprio_enabled);
+#endif
+
register_netdevice_notifier(&netprio_device_notifier);
out:
@@ -391,6 +395,11 @@ static void __exit exit_cgroup_netprio(void)
synchronize_rcu();
#endif
+#if IS_MODULE(CONFIG_NETPRIO_CGROUP)
+ static_key_slow_dec(&cgroup_netprio_enabled);
+ rcu_barrier();
+#endif
+
rtnl_lock();
for_each_netdev(&init_net, dev) {
old = rtnl_dereference(dev->priomap);
diff --git a/net/core/sock.c b/net/core/sock.c
index 8106e77..1f119d2 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -331,6 +331,10 @@ EXPORT_SYMBOL(__sk_backlog_rcv);
struct static_key cgroup_cls_enabled = STATIC_KEY_INIT_FALSE;
EXPORT_SYMBOL_GPL(cgroup_cls_enabled);
#endif
+#if IS_MODULE(CONFIG_NETPRIO_CGROUP)
+struct static_key cgroup_netprio_enabled = STATIC_KEY_INIT_FALSE;
+EXPORT_SYMBOL_GPL(cgroup_netprio_enabled);
+#endif
#if !defined(CONFIG_NET_CLS_CGROUP)
int net_cls_subsys_id = -1;
--
1.7.12.rc1.16.g05a20c8
next prev parent reply other threads:[~2012-08-24 14:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 14:01 [PATCH v2 00/10] cgroup: Assign subsystem IDs during compile time Daniel Wagner
2012-08-24 14:01 ` [PATCH v2 01/10] cgroup: net_cls: Use empty task_cls_classid() when !CONFIG_NET_CLS(_MODULE) Daniel Wagner
[not found] ` <1345816904-21745-2-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:22 ` Tejun Heo
2012-08-27 2:32 ` Li Zefan
[not found] ` <1345816904-21745-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 14:01 ` [PATCH v2 02/10] cgroup: net_cls: Move sock_update_classid() decleration to cls_cgroup.h Daniel Wagner
2012-08-24 14:01 ` Daniel Wagner [this message]
[not found] ` <1345816904-21745-5-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:26 ` [PATCH v2 04/10] cgroup: net_prio: Protect access to task_netprioidx() when built as module Tejun Heo
2012-08-24 14:01 ` [PATCH v2 07/10] cgroup: net_cls: Simplify ifdef logic Daniel Wagner
[not found] ` <1345816904-21745-8-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:39 ` Tejun Heo
2012-08-24 14:01 ` [PATCH v2 09/10] cgroup: net_prio: " Daniel Wagner
[not found] ` <1345816904-21745-10-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:42 ` Tejun Heo
2012-08-24 14:01 ` [PATCH v2 10/10] cgroup: net_prio: Merge builtin and module version of task_netprioidx() Daniel Wagner
2012-08-24 15:01 ` [PATCH v2 00/10] cgroup: Assign subsystem IDs during compile time Daniel Wagner
2012-08-24 23:15 ` Tejun Heo
[not found] ` <20120824231528.GO21325-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-25 16:49 ` Daniel Wagner
2012-08-24 14:01 ` [PATCH v2 03/10] cgroup: net_cls: Protect access to task_cls_classid() when built as module Daniel Wagner
[not found] ` <1345816904-21745-4-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:26 ` Tejun Heo
2012-08-25 16:56 ` Daniel Wagner
[not found] ` <503903BD.6020208-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-28 14:47 ` Paul E. McKenney
[not found] ` <20120828144725.GR2961-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2012-08-28 16:41 ` Daniel Wagner
2012-08-24 14:01 ` [PATCH v2 05/10] cgroup: Remove CGROUP_BUILTIN_SUBSYS_COUNT Daniel Wagner
[not found] ` <1345816904-21745-6-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:28 ` Tejun Heo
[not found] ` <20120824232840.GS21325-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-25 16:59 ` Daniel Wagner
[not found] ` <5039046D.1040402-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-09-06 22:23 ` Tejun Heo
2012-08-24 14:01 ` [PATCH v2 06/10] cgroup: Assign subsystem IDs during compile time Daniel Wagner
[not found] ` <1345816904-21745-7-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:38 ` Tejun Heo
[not found] ` <20120824233810.GT21325-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-25 17:11 ` Daniel Wagner
[not found] ` <50390743.2090203-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-09-06 22:32 ` Tejun Heo
2012-08-24 14:01 ` [PATCH v2 08/10] cgroup: net_cls: Merge builtin and module version of task_cls_classid() Daniel Wagner
[not found] ` <1345816904-21745-9-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-24 23:41 ` Tejun Heo
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=1345816904-21745-5-git-send-email-wagi@monom.org \
--to=wagi-kqcpca+x3s7ytjvyw6ydsg@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=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@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).