* [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL?
@ 2014-08-21 2:52 Zhouyi Zhou
2014-08-21 12:11 ` Florian Westphal
0 siblings, 1 reply; 4+ messages in thread
From: Zhouyi Zhou @ 2014-08-21 2:52 UTC (permalink / raw)
To: pablo, kaber, kadlec, davem, netfilter-devel, coreteam, netdev,
linux-kernel, jbaron
Cc: Zhouyi Zhou
CONFIG_JUMP_LABEL doesn't ensure HAVE_JUMP_LABEL, if it
is not the case use maintainers's own mutex to guard
the modification of global values.
Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
---
include/linux/netfilter.h | 5 +++--
net/netfilter/core.c | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 2077489..83a1952 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -9,6 +9,7 @@
#include <linux/in6.h>
#include <linux/wait.h>
#include <linux/list.h>
+#include <linux/static_key.h>
#include <uapi/linux/netfilter.h>
#ifdef CONFIG_NETFILTER
static inline int NF_DROP_GETERR(int verdict)
@@ -99,8 +100,8 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
extern struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
-#if defined(CONFIG_JUMP_LABEL)
-#include <linux/static_key.h>
+#ifdef HAVE_JUMP_LABEL
+
extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook)
{
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index a93c97f..024a2e2 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS] __read_mostly;
EXPORT_SYMBOL(nf_hooks);
-#if defined(CONFIG_JUMP_LABEL)
+#ifdef HAVE_JUMP_LABEL
struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif
@@ -72,7 +72,7 @@ int nf_register_hook(struct nf_hook_ops *reg)
}
list_add_rcu(®->list, elem->list.prev);
mutex_unlock(&nf_hook_mutex);
-#if defined(CONFIG_JUMP_LABEL)
+#ifdef HAVE_JUMP_LABEL
static_key_slow_inc(&nf_hooks_needed[reg->pf][reg->hooknum]);
#endif
return 0;
@@ -84,7 +84,7 @@ void nf_unregister_hook(struct nf_hook_ops *reg)
mutex_lock(&nf_hook_mutex);
list_del_rcu(®->list);
mutex_unlock(&nf_hook_mutex);
-#if defined(CONFIG_JUMP_LABEL)
+#ifdef HAVE_JUMP_LABEL
static_key_slow_dec(&nf_hooks_needed[reg->pf][reg->hooknum]);
#endif
synchronize_net();
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL?
2014-08-21 2:52 [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL? Zhouyi Zhou
@ 2014-08-21 12:11 ` Florian Westphal
2014-08-21 12:53 ` Zhouyi Zhou
0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2014-08-21 12:11 UTC (permalink / raw)
To: Zhouyi Zhou
Cc: pablo, kaber, kadlec, davem, netfilter-devel, coreteam, netdev,
linux-kernel, jbaron, Zhouyi Zhou
Zhouyi Zhou <zhouzhouyi@gmail.com> wrote:
>
> CONFIG_JUMP_LABEL doesn't ensure HAVE_JUMP_LABEL, if it
> is not the case use maintainers's own mutex to guard
> the modification of global values.
I don't understand this patch.
What is the problem you are fixing?
The intent is to only use static_key infrastructure
if user has enabled CONFIG_JUMP_LABEL.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL?
2014-08-21 12:11 ` Florian Westphal
@ 2014-08-21 12:53 ` Zhouyi Zhou
2014-08-21 15:24 ` Florian Westphal
0 siblings, 1 reply; 4+ messages in thread
From: Zhouyi Zhou @ 2014-08-21 12:53 UTC (permalink / raw)
To: Florian Westphal
Cc: Zhouyi Zhou, pablo, kaber, kadlec, davem, netfilter-devel,
coreteam, netdev, linux-kernel, jbaron
Thanks Florian for reviewing
> -----Original Messages-----
> From: "Florian Westphal" <fw@strlen.de>
>
> Zhouyi Zhou <zhouzhouyi@gmail.com> wrote:
> >
> > CONFIG_JUMP_LABEL doesn't ensure HAVE_JUMP_LABEL, if it
> > is not the case use maintainers's own mutex to guard
> > the modification of global values.
CONFIG_JUMP_LABEL says the user wants to use jump labels.
But we also need the toolchain to support it.
That is reflected in CC_HAVE_ASM_GOTO=y, and if both are
set then HAVE_JUMP_LABEL is set to true.
> I don't understand this patch.
>
> What is the problem you are fixing?
There is basically no real problem here.
This patch only tries to make kernel code that using
static_key infrastructure appears "unified"
>
> The intent is to only use static_key infrastructure
> if user has enabled CONFIG_JUMP_LABEL.
The other parts of kernel either use #ifdef HAVE_JUMP_LABEL,
or use no "#ifdef" at all(the two exceptions are netfilter
and powerpc modules which I send patches to both).
Jason has suggested me to make the patches:
https://lkml.org/lkml/2014/8/20/761
"Unified" is the reason, I guess :-)
so rookies like me can have unified examples to follow
Cheers
Zhouyi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL?
2014-08-21 12:53 ` Zhouyi Zhou
@ 2014-08-21 15:24 ` Florian Westphal
0 siblings, 0 replies; 4+ messages in thread
From: Florian Westphal @ 2014-08-21 15:24 UTC (permalink / raw)
To: Zhouyi Zhou
Cc: Florian Westphal, Zhouyi Zhou, pablo, kaber, kadlec, davem,
netfilter-devel, coreteam, netdev, linux-kernel, jbaron
Zhouyi Zhou <yizhouzhou@ict.ac.cn> wrote:
> > >
> > > CONFIG_JUMP_LABEL doesn't ensure HAVE_JUMP_LABEL, if it
> > > is not the case use maintainers's own mutex to guard
> > > the modification of global values.
>
> CONFIG_JUMP_LABEL says the user wants to use jump labels.
> But we also need the toolchain to support it.
>
> That is reflected in CC_HAVE_ASM_GOTO=y, and if both are
> set then HAVE_JUMP_LABEL is set to true.
Please resubmit and update the changelog to reflect this,
e.g. add something like
Use HAVE_JUMP_LABEL as elsewhere in the kernel to ensure
that the toolchain has the required support in addition to
CONFIG_JUMP_LABEL being set.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-21 15:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-21 2:52 [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL? Zhouyi Zhou
2014-08-21 12:11 ` Florian Westphal
2014-08-21 12:53 ` Zhouyi Zhou
2014-08-21 15:24 ` Florian Westphal
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).