* Re: [PATCH bpf-next] flow_dissector: fix build failure without CONFIG_NET
From: Daniel Borkmann @ 2018-09-19 21:48 UTC (permalink / raw)
To: Willem de Bruijn, netdev; +Cc: ast, rdunlap, Willem de Bruijn
In-Reply-To: <20180918202018.204099-1-willemdebruijn.kernel@gmail.com>
On 09/18/2018 10:20 PM, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
>
> If boolean CONFIG_BPF_SYSCALL is enabled, kernel/bpf/syscall.c will
> call flow_dissector functions from net/core/flow_dissector.c.
>
> This causes this build failure if CONFIG_NET is disabled:
>
> kernel/bpf/syscall.o: In function `__x64_sys_bpf':
> syscall.c:(.text+0x3278): undefined reference to
> `skb_flow_dissector_bpf_prog_attach'
> syscall.c:(.text+0x3310): undefined reference to
> `skb_flow_dissector_bpf_prog_detach'
> kernel/bpf/syscall.o:(.rodata+0x3f0): undefined reference to
> `flow_dissector_prog_ops'
> kernel/bpf/verifier.o:(.rodata+0x250): undefined reference to
> `flow_dissector_verifier_ops'
>
> Analogous to other optional BPF program types in syscall.c, add stubs
> if the relevant functions are not compiled and move the BPF_PROG_TYPE
> definition in the #ifdef CONFIG_NET block.
>
> Fixes: d58e468b1112 ("flow_dissector: implements flow dissector BPF hook")
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
Applied to bpf-next, thanks Willem!
^ permalink raw reply
* Re: [PATCH bpf] tools: bpf: fix license for a compat header file
From: Daniel Borkmann @ 2018-09-19 21:51 UTC (permalink / raw)
To: Jakub Kicinski, alexei.starovoitov; +Cc: netdev, oss-drivers
In-Reply-To: <20180918171359.18750-1-jakub.kicinski@netronome.com>
On 09/18/2018 07:13 PM, Jakub Kicinski wrote:
> libc_compat.h is used by libbpf so make sure it's licensed under
> LGPL or BSD license. The license change should be OK, I'm the only
> author of the file.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Applied to bpf, thanks Jakub!
^ permalink raw reply
* [PATCH 00/22] various dynamic_debug patches
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
To: Jason Baron, Andrew Morton
Cc: linux-kernel, Rasmus Villemoes, Greg Kroah-Hartman, netdev,
Petr Mladek, Steven Rostedt, linux-btrfs, linux-acpi, x86
This started as an experiment to see how hard it would be to change
the four pointers in struct _ddebug into relative offsets, a la
CONFIG_GENERIC_BUG_RELATIVE_POINTERS, thus saving 16 bytes per
pr_debug site (and thus exactly making up for the extra space used by
the introduction of jump labels in 9049fc74). I stumbled on a few
things that are probably worth fixing regardless of whether the latter
half of this series is deemed worthwhile.
Patch relationships: 1-2, 3-4, 5-6 and 15-16 can be applied
individually, though 2, 4 and 6 probably makes most sense in the
context of the final goal of the series.
7-12 I believe make sense on their own. Patch 13 again only makes
sense if we go all the way, and 14 and 17 depend on 13.
18-21 are more preparatory patches, and finally 22 switch over x86-64
to use CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS. I've tested that the
end result boots under virtme and that the dynamic_debug control file
has the expected contents.
Rasmus Villemoes (22):
linux/device.h: use DYNAMIC_DEBUG_BRANCH in dev_dbg_ratelimited
linux/device.h: use unique identifier for each struct _ddebug
linux/net.h: use DYNAMIC_DEBUG_BRANCH in net_dbg_ratelimited
linux/net.h: use unique identifier for each struct _ddebug
linux/printk.h: use DYNAMIC_DEBUG_BRANCH in pr_debug_ratelimited
linux/printk.h: use unique identifier for each struct _ddebug
dynamic_debug: consolidate DEFINE_DYNAMIC_DEBUG_METADATA definitions
dynamic_debug: don't duplicate modname in ddebug_add_module
dynamic_debug: use pointer comparison in ddebug_remove_module
dynamic_debug: remove unused EXPORT_SYMBOLs
dynamic_debug: move pr_err from module.c to ddebug_add_module
dynamic_debug: add static inline stub for ddebug_add_module
dynamic_debug: refactor dynamic_pr_debug and friends
btrfs: implement btrfs_debug* in terms of helper macro
ACPI: use proper DYNAMIC_DEBUG_BRANCH macro
ACPI: remove unused __acpi_handle_debug macro
ACPI: implement acpi_handle_debug in terms of _dynamic_func_call
dynamic_debug: introduce accessors for string members of struct
_ddebug
dynamic_debug: drop use of bitfields in struct _ddebug
dynamic_debug: introduce CONFIG_DYNAMIC_DEBUG_RELATIVE_POINTERS
x86: jump_label: introduce ASM_STATIC_KEY_INIT_{TRUE,FALSE}
x86_64: use relative pointers with dynamic debug
arch/x86/Kconfig | 1 +
arch/x86/include/asm/dynamic_debug.h | 35 +++++++++
arch/x86/include/asm/jump_label.h | 18 +++++
fs/btrfs/ctree.h | 34 +++------
include/linux/acpi.h | 11 +--
include/linux/device.h | 6 +-
include/linux/dynamic_debug.h | 126 +++++++++++++++++++--------------
include/linux/jump_label.h | 2 +
include/linux/net.h | 6 +-
include/linux/printk.h | 6 +-
kernel/module.c | 6 +-
lib/Kconfig.debug | 3 +
lib/dynamic_debug.c | 133 ++++++++++++++++++++++++-----------
13 files changed, 251 insertions(+), 136 deletions(-)
create mode 100644 arch/x86/include/asm/dynamic_debug.h
--
2.16.4
^ permalink raw reply
* [PATCH 04/22] linux/net.h: use unique identifier for each struct _ddebug
From: Rasmus Villemoes @ 2018-09-19 22:04 UTC (permalink / raw)
To: Jason Baron, Andrew Morton; +Cc: linux-kernel, Rasmus Villemoes, netdev
In-Reply-To: <20180919220444.23190-1-linux@rasmusvillemoes.dk>
Changes on x86-64 later in this series require that all struct _ddebug
descriptors in a translation unit uses distinct identifiers. Realize
that for net_dbg_ratelimited by generating such an identifier via
__UNIQUE_ID and pass that to an extra level of macros.
No functional change.
Cc: netdev@vger.kernel.org
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
include/linux/net.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index 651fca72286c..397243a25f56 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -260,7 +260,7 @@ do { \
#define net_info_ratelimited(fmt, ...) \
net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
#if defined(CONFIG_DYNAMIC_DEBUG)
-#define net_dbg_ratelimited(fmt, ...) \
+#define _net_dbg_ratelimited(descriptor, fmt, ...) \
do { \
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
if (DYNAMIC_DEBUG_BRANCH(descriptor) && \
@@ -268,6 +268,8 @@ do { \
__dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
##__VA_ARGS__); \
} while (0)
+#define net_dbg_ratelimited(fmt, ...) \
+ _net_dbg_ratelimited(__UNIQUE_ID(ddebug), fmt, ##__VA_ARGS__)
#elif defined(DEBUG)
#define net_dbg_ratelimited(fmt, ...) \
net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
--
2.16.4
^ permalink raw reply related
* Re: [PATCH net-next v2 05/10] net: sched: use Qdisc rcu API instead of relying on rtnl lock
From: Cong Wang @ 2018-09-19 22:04 UTC (permalink / raw)
To: Vlad Buslov
Cc: Linux Kernel Network Developers, Jamal Hadi Salim, Jiri Pirko,
David Miller, Stephen Hemminger, Kirill Tkhai, Nicolas Dichtel,
Greg KH, mark.rutland, Leon Romanovsky, Paul E. McKenney,
Florian Westphal, David Ahern, christian, lucien xin,
Jakub Kicinski, Jiri Benc
In-Reply-To: <1537168660-24032-6-git-send-email-vladbu@mellanox.com>
On Mon, Sep 17, 2018 at 12:19 AM Vlad Buslov <vladbu@mellanox.com> wrote:
> +static void tcf_qdisc_put(struct Qdisc *q, bool rtnl_held)
> +{
> + if (!q)
> + return;
> +
> + if (rtnl_held)
> + qdisc_put(q);
> + else
> + qdisc_put_unlocked(q);
> +}
This is very ugly. You should know whether RTNL is held or
not when calling it.
What's more, all of your code passes true, so why do you
need a parameter for rtnl_held?
^ permalink raw reply
* Re: [PATCH net-next v2 08/10] net: sched: protect block idr with spinlock
From: Cong Wang @ 2018-09-19 22:09 UTC (permalink / raw)
To: Vlad Buslov
Cc: Linux Kernel Network Developers, Jamal Hadi Salim, Jiri Pirko,
David Miller, Stephen Hemminger, Kirill Tkhai, Nicolas Dichtel,
Greg KH, mark.rutland, Leon Romanovsky, Paul E. McKenney,
Florian Westphal, David Ahern, christian, lucien xin,
Jakub Kicinski, Jiri Benc
In-Reply-To: <1537168660-24032-9-git-send-email-vladbu@mellanox.com>
On Mon, Sep 17, 2018 at 12:19 AM Vlad Buslov <vladbu@mellanox.com> wrote:
> @@ -482,16 +483,25 @@ static int tcf_block_insert(struct tcf_block *block, struct net *net,
> struct netlink_ext_ack *extack)
> {
> struct tcf_net *tn = net_generic(net, tcf_net_id);
> + int err;
> +
> + idr_preload(GFP_KERNEL);
> + spin_lock(&tn->idr_lock);
> + err = idr_alloc_u32(&tn->idr, block, &block->index, block->index,
> + GFP_NOWAIT);
Why GFP_NOWAIT rather than GFP_ATOMIC here?
^ permalink raw reply
* Re: [RESEND PATCH 0/5] net: Use FIELD_SIZEOF directly instead of reimplementing its function
From: David Miller @ 2018-09-20 3:58 UTC (permalink / raw)
To: zhongjiang
Cc: ubraun, jwi, jhs, xiyou.wangcong, Ariel.Elior, everest-linux-l2,
grygorii.strashko, netdev, linux-kernel, borntraeger
In-Reply-To: <1537356734-51676-1-git-send-email-zhongjiang@huawei.com>
From: zhong jiang <zhongjiang@huawei.com>
Date: Wed, 19 Sep 2018 19:32:09 +0800
> The issue is detected with the help of Coccinelle.
Series applied, thank you.
^ permalink raw reply
* [PATCH] isdn/hisax: Remove unnecessary parenthesis
From: Nathan Chancellor @ 2018-09-20 4:05 UTC (permalink / raw)
To: Karsten Keil, David S. Miller
Cc: netdev, linux-kernel, Nick Desaulniers, Nathan Chancellor
Clang warns when more than one set of parentheses are used for single
conditional statements:
drivers/isdn/hisax/w6692.c:627:30: warning: equality comparison with
extraneous parentheses [-Wparentheses-equality]
if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) {
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
drivers/isdn/hisax/w6692.c:627:30: note: remove extraneous parentheses
around the comparison to silence this warning
if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) {
~ ^ ~
drivers/isdn/hisax/w6692.c:627:30: note: use '=' to turn this equality
comparison into an assignment
if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) {
^~
=
1 warning generated.
Remove the parentheses to silence this warning.
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/isdn/hisax/w6692.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index c4be1644f5bb..bb8e4b7e34ea 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -624,7 +624,7 @@ W6692_l1hw(struct PStack *st, int pr, void *arg)
break;
case (HW_RESET | REQUEST):
spin_lock_irqsave(&cs->lock, flags);
- if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) {
+ if (cs->dc.w6692.ph_state == W_L1IND_DRD) {
ph_command(cs, W_L1CMD_ECK);
spin_unlock_irqrestore(&cs->lock, flags);
} else {
--
2.19.0
^ permalink raw reply related
* Re: [PATCH net-next 00/12] net: mvpp2: improve the interrupt usage
From: David Miller @ 2018-09-20 4:13 UTC (permalink / raw)
To: antoine.tenart
Cc: netdev, linux-kernel, thomas.petazzoni, maxime.chevallier,
gregory.clement, miquel.raynal, nadavh, stefanc, ymarkman, mw
In-Reply-To: <20180919092711.22296-1-antoine.tenart@bootlin.com>
From: Antoine Tenart <antoine.tenart@bootlin.com>
Date: Wed, 19 Sep 2018 11:26:59 +0200
> This series aims to improve the interrupts descriptions and usage in the
> Marvell PPv2 driver.
>
> - Before the series interrupts were named after their s/w usage,
> which in fact can be configured. The series rename all those
> interrupts and add a description of the ones left over.
>
> - In PPv2 the interrupts are mapped to vectors. Those vectors were
> directly mapped to a given CPU, and per-cpu accesses were done. While
> this worked on our cases, the registers accesses mapped to the vectors
> are not actually linked to a given CPU. They instead are linked to
> what is called a "s/w thread". The series modify this so that the s/w
> threads are used instead of the CPU numbers, by adding an indirection.
> This means we now can have systems with more CPUs than s/w threads.
>
> This is based on today's net-next, and was tested on various boards
> using both versions of the PPv2 engine.
>
> Two more patches will be coming, to update the device trees describing a
> PPv2 engine. The patches are ready, but will go through a different
> tree. I'll send them once this series will be accepted. This is not an
> issue as the PPv2 driver keeps the dt bindings backward compatibility.
Series applied, thanks Antoine.
^ permalink raw reply
* Re: [PATCH net-next 0/3] net: phy: phylink: ensure the carrier is off when starting phylink
From: David Miller @ 2018-09-20 4:15 UTC (permalink / raw)
To: antoine.tenart
Cc: linux, andrew, f.fainelli, netdev, linux-kernel, thomas.petazzoni,
maxime.chevallier, gregory.clement, miquel.raynal, nadavh,
stefanc, ymarkman, mw
In-Reply-To: <20180919093933.24411-1-antoine.tenart@bootlin.com>
From: Antoine Tenart <antoine.tenart@bootlin.com>
Date: Wed, 19 Sep 2018 11:39:30 +0200
> Hi Russell,
>
> Following the discussion we had regarding the phylink issue related to
> the carrier link state not being off when starting phylink, I sent a fix
> patch a few days ago for the PPv2 driver:
> https://lkml.org/lkml/2018/9/14/633
>
> The idea was to send a patch which could go to the stable branches, but
> a better solution would be to directly call netif_carrier_off() from
> within phylink_start(). This is the aim of this series.
Series applied.
^ permalink raw reply
* Re: [PATCH net-next] net: marvell: fix return type of ndo_start_xmit function
From: David Miller @ 2018-09-20 4:19 UTC (permalink / raw)
To: yuehaibing
Cc: thomas.petazzoni, antoine.tenart, maxime.chevallier, ymarkman,
stefanc, keescook, allen.lkml, linux-kernel, netdev
In-Reply-To: <20180919101926.25036-1-yuehaibing@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Wed, 19 Sep 2018 18:19:26 +0800
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, so make sure the implementation in
> this driver has returns 'netdev_tx_t' value, and change the function
> return type to netdev_tx_t.
>
> Found by coccinelle.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] net: xilinx: fix return type of ndo_start_xmit function
From: David Miller @ 2018-09-20 4:19 UTC (permalink / raw)
To: yuehaibing
Cc: michal.simek, anirudh, John.Linn, linux-kernel, netdev,
linux-arm-kernel
In-Reply-To: <20180919103240.27708-2-yuehaibing@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Wed, 19 Sep 2018 18:32:40 +0800
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, so make sure the implementation in
> this driver has returns 'netdev_tx_t' value, and change the function
> return type to netdev_tx_t.
>
> Found by coccinelle.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] net: broadcom: fix return type of ndo_start_xmit function
From: David Miller @ 2018-09-20 4:19 UTC (permalink / raw)
To: yuehaibing
Cc: f.fainelli, bcm-kernel-feedback-list, jonas.gorski, andrew,
himanshujha199640, keescook, linux-kernel, netdev,
linux-arm-kernel
In-Reply-To: <20180919104512.27068-1-yuehaibing@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Wed, 19 Sep 2018 18:45:12 +0800
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, so make sure the implementation in
> this driver has returns 'netdev_tx_t' value, and change the function
> return type to netdev_tx_t.
>
> Found by coccinelle.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] net: amd: fix return type of ndo_start_xmit function
From: David Miller @ 2018-09-20 4:19 UTC (permalink / raw)
To: yuehaibing
Cc: linux, thomas.lendacky, keescook, allen.lkml, linux-kernel,
netdev, linux-arm-kernel
In-Reply-To: <20180919105017.15304-1-yuehaibing@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Wed, 19 Sep 2018 18:50:17 +0800
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, so make sure the implementation in
> this driver has returns 'netdev_tx_t' value, and change the function
> return type to netdev_tx_t.
>
> Found by coccinelle.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next] net: sun: fix return type of ndo_start_xmit function
From: David Miller @ 2018-09-20 4:19 UTC (permalink / raw)
To: yuehaibing
Cc: shannon.nelson, alexander.h.duyck, yanjun.zhu, jeffrey.t.kirsher,
tklauser, linux-kernel, netdev
In-Reply-To: <20180919112132.26616-1-yuehaibing@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Wed, 19 Sep 2018 19:21:32 +0800
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, but the implementation in this
> driver returns an 'int'.
>
> Found by coccinelle.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied.
^ permalink raw reply
* [PATCH bpf-next 2/3] bpf: emit RECORD_MMAP events for bpf prog load/unload
From: Alexei Starovoitov @ 2018-09-19 22:39 UTC (permalink / raw)
To: David S . Miller; +Cc: daniel, peterz, acme, netdev, kernel-team
In-Reply-To: <20180919223935.999270-1-ast@kernel.org>
use perf_event_mmap_bpf_prog() helper to notify user space
about JITed bpf programs.
Use RECORD_MMAP perf event to tell user space where JITed bpf program was loaded.
Use empty program name as unload indication.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/core.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 3f5bf1af0826..ddf11fdafd36 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -384,7 +384,7 @@ bpf_get_prog_addr_region(const struct bpf_prog *prog,
*symbol_end = addr + hdr->pages * PAGE_SIZE;
}
-static void bpf_get_prog_name(const struct bpf_prog *prog, char *sym)
+static char *bpf_get_prog_name(const struct bpf_prog *prog, char *sym)
{
const char *end = sym + KSYM_NAME_LEN;
@@ -402,9 +402,10 @@ static void bpf_get_prog_name(const struct bpf_prog *prog, char *sym)
sym += snprintf(sym, KSYM_NAME_LEN, "bpf_prog_");
sym = bin2hex(sym, prog->tag, sizeof(prog->tag));
if (prog->aux->name[0])
- snprintf(sym, (size_t)(end - sym), "_%s", prog->aux->name);
+ sym += snprintf(sym, (size_t)(end - sym), "_%s", prog->aux->name);
else
*sym = 0;
+ return sym;
}
static __always_inline unsigned long
@@ -480,23 +481,40 @@ static bool bpf_prog_kallsyms_verify_off(const struct bpf_prog *fp)
void bpf_prog_kallsyms_add(struct bpf_prog *fp)
{
+ unsigned long symbol_start, symbol_end;
+ char buf[KSYM_NAME_LEN], *sym;
+
if (!bpf_prog_kallsyms_candidate(fp) ||
!capable(CAP_SYS_ADMIN))
return;
+ bpf_get_prog_addr_region(fp, &symbol_start, &symbol_end);
+ sym = bpf_get_prog_name(fp, buf);
+ sym++; /* sym - buf is the length of the name including trailing 0 */
+ while (!IS_ALIGNED(sym - buf, sizeof(u64)))
+ *sym++ = 0;
spin_lock_bh(&bpf_lock);
bpf_prog_ksym_node_add(fp->aux);
spin_unlock_bh(&bpf_lock);
+ perf_event_mmap_bpf_prog(symbol_start, symbol_end - symbol_start,
+ buf, sym - buf);
}
void bpf_prog_kallsyms_del(struct bpf_prog *fp)
{
+ unsigned long symbol_start, symbol_end;
+ /* mmap_record.filename cannot be NULL and has to be u64 aligned */
+ char buf[sizeof(u64)] = {};
+
if (!bpf_prog_kallsyms_candidate(fp))
return;
spin_lock_bh(&bpf_lock);
bpf_prog_ksym_node_del(fp->aux);
spin_unlock_bh(&bpf_lock);
+ bpf_get_prog_addr_region(fp, &symbol_start, &symbol_end);
+ perf_event_mmap_bpf_prog(symbol_start, symbol_end - symbol_start,
+ buf, sizeof(buf));
}
static struct bpf_prog *bpf_prog_kallsyms_find(unsigned long addr)
--
2.17.1
^ permalink raw reply related
* [PATCH perf 3/3] tools/perf: recognize and process RECORD_MMAP events for bpf progs
From: Alexei Starovoitov @ 2018-09-19 22:39 UTC (permalink / raw)
To: David S . Miller; +Cc: daniel, peterz, acme, netdev, kernel-team
In-Reply-To: <20180919223935.999270-1-ast@kernel.org>
Recognize JITed bpf prog load/unload events.
Add/remove kernel symbols accordingly.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
tools/perf/util/machine.c | 27 +++++++++++++++++++++++++++
tools/perf/util/symbol.c | 13 +++++++++++++
tools/perf/util/symbol.h | 1 +
3 files changed, 41 insertions(+)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index c4acd2001db0..ae4f8a0fdc7e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -25,6 +25,7 @@
#include "sane_ctype.h"
#include <symbol/kallsyms.h>
#include <linux/mman.h>
+#include <linux/magic.h>
static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock);
@@ -1460,6 +1461,32 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
enum dso_kernel_type kernel_type;
bool is_kernel_mmap;
+ /* process JITed bpf programs load/unload events */
+ if (event->mmap.pid == ~0u && event->mmap.tid == BPF_FS_MAGIC) {
+ struct symbol *sym;
+ u64 ip;
+
+ map = map_groups__find(&machine->kmaps, event->mmap.start);
+ if (!map) {
+ pr_err("No kernel map for IP %lx\n", event->mmap.start);
+ goto out_problem;
+ }
+ ip = event->mmap.start - map->start + map->pgoff;
+ if (event->mmap.filename[0]) {
+ sym = symbol__new(ip, event->mmap.len, 0, 0,
+ event->mmap.filename);
+ dso__insert_symbol(map->dso, sym);
+ } else {
+ if (symbols__erase(&map->dso->symbols, ip)) {
+ pr_err("No bpf prog at IP %lx/%lx\n",
+ event->mmap.start, ip);
+ goto out_problem;
+ }
+ dso__reset_find_symbol_cache(map->dso);
+ }
+ return 0;
+ }
+
/* If we have maps from kcore then we do not need or want any others */
if (machine__uses_kcore(machine))
return 0;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index d188b7588152..0653f313661d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -353,6 +353,19 @@ static struct symbol *symbols__find(struct rb_root *symbols, u64 ip)
return NULL;
}
+int symbols__erase(struct rb_root *symbols, u64 ip)
+{
+ struct symbol *s;
+
+ s = symbols__find(symbols, ip);
+ if (!s)
+ return -ENOENT;
+
+ rb_erase(&s->rb_node, symbols);
+ symbol__delete(s);
+ return 0;
+}
+
static struct symbol *symbols__first(struct rb_root *symbols)
{
struct rb_node *n = rb_first(symbols);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index f25fae4b5743..92ef31953d9a 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -310,6 +310,7 @@ char *dso__demangle_sym(struct dso *dso, int kmodule, const char *elf_name);
void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel);
void symbols__insert(struct rb_root *symbols, struct symbol *sym);
+int symbols__erase(struct rb_root *symbols, u64 ip);
void symbols__fixup_duplicate(struct rb_root *symbols);
void symbols__fixup_end(struct rb_root *symbols);
void map_groups__fixup_end(struct map_groups *mg);
--
2.17.1
^ permalink raw reply related
* [PATCH bpf-next 1/3] perf/core: introduce perf_event_mmap_bpf_prog
From: Alexei Starovoitov @ 2018-09-19 22:39 UTC (permalink / raw)
To: David S . Miller; +Cc: daniel, peterz, acme, netdev, kernel-team
In-Reply-To: <20180919223935.999270-1-ast@kernel.org>
introduce perf_event_mmap_bpf_prog() helper to emit RECORD_MMAP events
into perf ring buffer.
It's used by bpf load/unload logic to notify user space of addresses
and names of JITed bpf programs.
Note that event->mmap.pid == -1 is an existing indicator of kernel event.
In addition use event->mmap.tid == BPF_FS_MAGIC to indicate bpf related
RECORD_MMAP event.
Alternatively it's possible to introduce new 'enum perf_event_type' command
specificially for bpf prog load/unload, but existing RECORD_MMAP
is very close, so the choice made by this patch is to extend it.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/perf_event.h | 1 +
kernel/events/core.c | 44 +++++++++++++++++++++++++++++++++-----
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 53c500f0ca79..0e79af83138f 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1113,6 +1113,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
}
extern void perf_event_mmap(struct vm_area_struct *vma);
+void perf_event_mmap_bpf_prog(u64 start, u64 len, char *name, int size);
extern struct perf_guest_info_callbacks *perf_guest_cbs;
extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2a62b96600ad..c48244ddf993 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7152,7 +7152,7 @@ static int perf_event_mmap_match(struct perf_event *event,
{
struct perf_mmap_event *mmap_event = data;
struct vm_area_struct *vma = mmap_event->vma;
- int executable = vma->vm_flags & VM_EXEC;
+ int executable = !vma || vma->vm_flags & VM_EXEC;
return (!executable && event->attr.mmap_data) ||
(executable && (event->attr.mmap || event->attr.mmap2));
@@ -7165,12 +7165,13 @@ static void perf_event_mmap_output(struct perf_event *event,
struct perf_output_handle handle;
struct perf_sample_data sample;
int size = mmap_event->event_id.header.size;
+ bool bpf_event = !mmap_event->vma;
int ret;
if (!perf_event_mmap_match(event, data))
return;
- if (event->attr.mmap2) {
+ if (event->attr.mmap2 && !bpf_event) {
mmap_event->event_id.header.type = PERF_RECORD_MMAP2;
mmap_event->event_id.header.size += sizeof(mmap_event->maj);
mmap_event->event_id.header.size += sizeof(mmap_event->min);
@@ -7186,12 +7187,14 @@ static void perf_event_mmap_output(struct perf_event *event,
if (ret)
goto out;
- mmap_event->event_id.pid = perf_event_pid(event, current);
- mmap_event->event_id.tid = perf_event_tid(event, current);
+ if (!bpf_event) {
+ mmap_event->event_id.pid = perf_event_pid(event, current);
+ mmap_event->event_id.tid = perf_event_tid(event, current);
+ }
perf_output_put(&handle, mmap_event->event_id);
- if (event->attr.mmap2) {
+ if (event->attr.mmap2 && !bpf_event) {
perf_output_put(&handle, mmap_event->maj);
perf_output_put(&handle, mmap_event->min);
perf_output_put(&handle, mmap_event->ino);
@@ -7448,6 +7451,37 @@ void perf_event_mmap(struct vm_area_struct *vma)
perf_event_mmap_event(&mmap_event);
}
+void perf_event_mmap_bpf_prog(u64 start, u64 len, char *name, int size)
+{
+ struct perf_mmap_event mmap_event;
+
+ if (!atomic_read(&nr_mmap_events))
+ return;
+
+ if (!IS_ALIGNED(size, sizeof(u64))) {
+ WARN_ONCE(1, "size is not aligned\n");
+ return;
+ }
+
+ mmap_event = (struct perf_mmap_event){
+ .file_name = name,
+ .file_size = size,
+ .event_id = {
+ .header = {
+ .type = PERF_RECORD_MMAP,
+ .misc = PERF_RECORD_MISC_KERNEL,
+ .size = sizeof(mmap_event.event_id) + size,
+ },
+ .pid = -1, /* indicates kernel */
+ .tid = BPF_FS_MAGIC, /* bpf mmap event */
+ .start = start,
+ .len = len,
+ .pgoff = start,
+ },
+ };
+ perf_iterate_sb(perf_event_mmap_output, &mmap_event, NULL);
+}
+
void perf_event_aux_event(struct perf_event *event, unsigned long head,
unsigned long size, u64 flags)
{
--
2.17.1
^ permalink raw reply related
* [PATCH bpf-next 0/3] perf, bpf: reveal invisible bpf programs
From: Alexei Starovoitov @ 2018-09-19 22:39 UTC (permalink / raw)
To: David S . Miller; +Cc: daniel, peterz, acme, netdev, kernel-team
Hi All,
this patch set adds kernel and user space support to reveal
short lived bpf programs.
The kernel stores addr+bpf_prog_name information into perf ring buffer.
Later 'perf report' can properly attribute the cpu time to the program.
The following command was run before and after: 'perf record ./test_progs; perf report'
Before patch set:
# Overhead Command Shared Object Symbol
# ........ .......... ................. .......................................
#
10.73% test_progs [kernel.kallsyms] [k] __htab_map_lookup_elem
8.16% test_progs [kernel.kallsyms] [k] bpf_skb_set_tunnel_key
7.90% test_progs [kernel.kallsyms] [k] memcmp
3.10% test_progs [kernel.kallsyms] [k] lookup_nulls_elem_raw
2.57% test_progs [kernel.kallsyms] [k] dst_release
2.45% test_progs [kernel.kallsyms] [k] do_check
1.89% test_progs [kernel.kallsyms] [k] bpf_xdp_adjust_head
1.52% test_progs [kernel.kallsyms] [k] 0x00007fffa002cc5a
1.22% test_progs [kernel.kallsyms] [k] check_helper_mem_access
0.99% test_progs [kernel.kallsyms] [k] 0x00007fffa001a6a8
0.99% test_progs [kernel.kallsyms] [k] kmem_cache_alloc_trace
0.97% test_progs [kernel.kallsyms] [k] 0x00007fffa001a652
0.95% test_progs [kernel.kallsyms] [k] 0x00007fffa0042d52
0.95% test_progs [kernel.kallsyms] [k] read_tsc
0.81% test_progs [kernel.kallsyms] [k] 0x00007fffa001a660
0.77% test_progs [kernel.kallsyms] [k] 0x00007fffa0042d69
0.74% test_progs [kernel.kallsyms] [k] percpu_array_map_lookup_elem
0.69% test_progs [kernel.kallsyms] [k] 0x00007fffa001a64e
After:
# Overhead Command Shared Object Symbol
# ........ .......... ................. .............................................
#
18.13% test_progs [kernel.kallsyms] [k] bpf_prog_1accc788e7f04c38_balancer_ingres
10.73% test_progs [kernel.kallsyms] [k] __htab_map_lookup_elem
7.94% test_progs [kernel.kallsyms] [k] bpf_prog_20a05d8a586cf0e8_F
7.80% test_progs [kernel.kallsyms] [k] bpf_skb_set_tunnel_key
4.64% test_progs [kernel.kallsyms] [k] __sysfs_match_string
3.61% test_progs [kernel.kallsyms] [k] bpf_prog_9d89afa51f1dc0d7_F
3.51% test_progs [kernel.kallsyms] [k] bpf_prog_73b45270911a0294_F
3.41% test_progs [kernel.kallsyms] [k] bpf_prog_79be7b7bad8026bf_F
3.26% test_progs [kernel.kallsyms] [k] memcmp
3.10% test_progs [kernel.kallsyms] [k] lookup_nulls_elem_raw
2.89% test_progs [kernel.kallsyms] [k] bpf_prog_57bf3d413b9b7455_F
2.57% test_progs [kernel.kallsyms] [k] dst_discard
2.45% test_progs [kernel.kallsyms] [k] do_check
2.39% test_progs [kernel.kallsyms] [k] bpf_prog_576cbdaac1a4d2f6_F
1.82% test_progs [kernel.kallsyms] [k] bpf_prog_53ade2ecbddaa85b_F
1.70% test_progs [kernel.kallsyms] [k] bpf_xdp_adjust_head
1.32% test_progs [kernel.kallsyms] [k] bpf_prog_0edc54822404a598_F
Important considerations:
- Before and after the number of cpu samples are the same. No samples are lost.
But perf cannot find the symbol by IP, so a lot of small 0x00007fffa001a64e-like
symbols appear towards the end of 'perf report' and none of them look hot.
In reallity these IP addresses belong to few bpf programs that
were active at that time.
- newly loaded bpf program can be JITed into address space of unloaded prog.
7fffa001aXXX address at time X can belong to a program A, but similar
7fffa001aYYY address at time Y can belong to a different program B.
- event->mmap.pid == -1 is an existing indicator of kernel event.
event->mmap.tid == BPF_FS_MAGIC is an extension to indicate bpf related event.
Alternatively it's possible to introduce new 'enum perf_event_type' command
specificially for bpf prog load/unload, but existing RECORD_MMAP
is very close, so the choice made by this patchset is to extend it.
- steps to land the set:
Patches 1 and 2 need to go via bpf-next tree,
since we're adding support for better program names exactly in the same lines.
Patch 3 can go in parallel into perf tree. It has no effect without kernel
support and kernel support has not effect on old perf.
Peter, Arnaldo, Daniel, please review.
Alexei Starovoitov (3):
perf/core: introduce perf_event_mmap_bpf_prog
bpf: emit RECORD_MMAP events for bpf prog load/unload
tools/perf: recognize and process RECORD_MMAP events for bpf progs
include/linux/perf_event.h | 1 +
kernel/bpf/core.c | 22 +++++++++++++++++--
kernel/events/core.c | 44 +++++++++++++++++++++++++++++++++-----
tools/perf/util/machine.c | 27 +++++++++++++++++++++++
tools/perf/util/symbol.c | 13 +++++++++++
tools/perf/util/symbol.h | 1 +
6 files changed, 101 insertions(+), 7 deletions(-)
--
2.17.1
^ permalink raw reply
* Re: [PATCH net-next 00/12] Fixes, cleanups & minor additions to HNS3 driver
From: David Miller @ 2018-09-20 4:21 UTC (permalink / raw)
To: salil.mehta
Cc: yisen.zhuang, lipeng321, mehta.salil, netdev, linux-kernel,
linuxarm
In-Reply-To: <20180919172958.12992-1-salil.mehta@huawei.com>
From: Salil Mehta <salil.mehta@huawei.com>
Date: Wed, 19 Sep 2018 18:29:46 +0100
> This patch-set present some fixes, cleanups to the HNS£ PF and VF driver.
Series applied, thank you.
^ permalink raw reply
* Re: [PATCH] net: ibm: remove a redundant local variable 'k'
From: David Miller @ 2018-09-20 4:26 UTC (permalink / raw)
To: zhongjiang; +Cc: dougmill, netdev, linux-kernel
In-Reply-To: <1537366995-59168-1-git-send-email-zhongjiang@huawei.com>
From: zhong jiang <zhongjiang@huawei.com>
Date: Wed, 19 Sep 2018 22:23:15 +0800
> The local variable 'k' is never used after being assigned.
> hence it should be redundant adn can be removed.
>
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH] net: ibm: remove redundant local variables 'act_nr_of_entries' and 'act_pages'
From: David Miller @ 2018-09-20 4:26 UTC (permalink / raw)
To: zhongjiang; +Cc: dougmill, netdev, linux-kernel
In-Reply-To: <1537367449-59565-1-git-send-email-zhongjiang@huawei.com>
From: zhong jiang <zhongjiang@huawei.com>
Date: Wed, 19 Sep 2018 22:30:49 +0800
> That local variable are never used after being assigned.
> hence it should be redundant and can be removed.
>
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Applied.
^ permalink raw reply
* [PATCH] netfilter: nf_tables: add SECMARK support
From: Christian Göttsche @ 2018-09-19 23:14 UTC (permalink / raw)
To: pablo, kadlec, fw, davem, netfilter-devel, coreteam, netdev,
linux-kernel, paul, sds, eparis, jmorris, serge, selinux,
linux-security-module
Add the ability to set the security context of packets within the nf_tables framework.
Add a nft_object for holding security contexts in the kernel and manipulating packets on the wire.
The contexts are kept as strings and are evaluated to security identifiers at runtime (packet arrival),
so that the nft_objects do not need to be refreshed after security changes.
The maximum security context length is set to 256.
Based on v4.18.6
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
include/net/netfilter/nf_tables_core.h | 4 +
include/uapi/linux/netfilter/nf_tables.h | 18 ++++-
net/netfilter/nf_tables_core.c | 28 ++++++-
net/netfilter/nft_meta.c | 95 ++++++++++++++++++++++++
4 files changed, 140 insertions(+), 5 deletions(-)
diff --git a/include/net/netfilter/nf_tables_core.h b/include/net/netfilter/nf_tables_core.h
index a0513450..0d1f3b96 100644
--- a/include/net/netfilter/nf_tables_core.h
+++ b/include/net/netfilter/nf_tables_core.h
@@ -16,6 +16,10 @@ extern struct nft_expr_type nft_meta_type;
extern struct nft_expr_type nft_rt_type;
extern struct nft_expr_type nft_exthdr_type;
+#ifdef CONFIG_NETWORK_SECMARK
+extern struct nft_object_type nft_secmark_obj_type;
+#endif
+
int nf_tables_core_module_init(void);
void nf_tables_core_module_exit(void);
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 89438e68..f1527962 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -1169,6 +1169,21 @@ enum nft_quota_attributes {
};
#define NFTA_QUOTA_MAX (__NFTA_QUOTA_MAX - 1)
+/**
+ * enum nft_secmark_attributes - nf_tables secmark object netlink attributes
+ *
+ * @NFTA_SECMARK_CTX: security context (NLA_STRING)
+ */
+enum nft_secmark_attributes {
+ NFTA_SECMARK_UNSPEC,
+ NFTA_SECMARK_CTX,
+ __NFTA_SECMARK_MAX,
+};
+#define NFTA_SECMARK_MAX (__NFTA_SECMARK_MAX - 1)
+
+/* Max security context length */
+#define NFT_SECMARK_CTX_MAXLEN 256
+
/**
* enum nft_reject_types - nf_tables reject expression reject types
*
@@ -1398,7 +1413,8 @@ enum nft_ct_helper_attributes {
#define NFT_OBJECT_CT_HELPER 3
#define NFT_OBJECT_LIMIT 4
#define NFT_OBJECT_CONNLIMIT 5
-#define __NFT_OBJECT_MAX 6
+#define NFT_OBJECT_SECMARK 6
+#define __NFT_OBJECT_MAX 7
#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)
/**
diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index 8de912ca..d59ebba0 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -235,12 +235,24 @@ static struct nft_expr_type *nft_basic_types[] = {
&nft_exthdr_type,
};
+static struct nft_object_type *nft_basic_objects[] = {
+#ifdef CONFIG_NETWORK_SECMARK
+ &nft_secmark_obj_type,
+#endif
+};
+
int __init nf_tables_core_module_init(void)
{
- int err, i;
+ int err, i, j = 0;
+
+ for (i = 0; i < ARRAY_SIZE(nft_basic_objects); i++) {
+ err = nft_register_obj(nft_basic_objects[i]);
+ if (err)
+ goto err;
+ }
- for (i = 0; i < ARRAY_SIZE(nft_basic_types); i++) {
- err = nft_register_expr(nft_basic_types[i]);
+ for (j = 0; j < ARRAY_SIZE(nft_basic_types); j++) {
+ err = nft_register_expr(nft_basic_types[j]);
if (err)
goto err;
}
@@ -248,8 +260,12 @@ int __init nf_tables_core_module_init(void)
return 0;
err:
+ while (j-- > 0)
+ nft_unregister_expr(nft_basic_types[j]);
+
while (i-- > 0)
- nft_unregister_expr(nft_basic_types[i]);
+ nft_unregister_obj(nft_basic_objects[i]);
+
return err;
}
@@ -260,4 +276,8 @@ void nf_tables_core_module_exit(void)
i = ARRAY_SIZE(nft_basic_types);
while (i-- > 0)
nft_unregister_expr(nft_basic_types[i]);
+
+ i = ARRAY_SIZE(nft_basic_objects);
+ while (i-- > 0)
+ nft_unregister_obj(nft_basic_objects[i]);
}
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 1105a23b..26b79a3c 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -540,3 +540,98 @@ struct nft_expr_type nft_meta_type __read_mostly = {
.maxattr = NFTA_META_MAX,
.owner = THIS_MODULE,
};
+
+#ifdef CONFIG_NETWORK_SECMARK
+
+struct nft_secmark {
+ char ctx[NFT_SECMARK_CTX_MAXLEN];
+ int len;
+};
+
+static const struct nla_policy nft_secmark_policy[NFTA_SECMARK_MAX + 1] = {
+ [NFTA_SECMARK_CTX] = { .type = NLA_STRING, .len = NFT_SECMARK_CTX_MAXLEN },
+};
+
+
+static void nft_secmark_obj_eval(struct nft_object *obj, struct nft_regs *regs, const struct nft_pktinfo *pkt)
+{
+ const struct nft_secmark *priv = nft_obj_data(obj);
+ struct sk_buff *skb = pkt->skb;
+ int err;
+ u32 secid = 0;
+
+ /* skip if packet has already a secmark */
+ if (skb->secmark)
+ return;
+
+ err = security_secctx_to_secid(priv->ctx, priv->len, &secid);
+ if (err) {
+ if (err == -EINVAL)
+ pr_notice_ratelimited("invalid security context \'%s\'\n", priv->ctx);
+ else
+ pr_notice_ratelimited("unable to convert security context \'%s\': %d\n", priv->ctx, -err);
+ return;
+ }
+
+ if (!secid) {
+ pr_notice_ratelimited("unable to map security context \'%s\'\n", priv->ctx);
+ return;
+ }
+
+ err = security_secmark_relabel_packet(secid);
+ if (err) {
+ pr_notice_ratelimited("unable to obtain relabeling permission: %d\n", -err);
+ return;
+ }
+
+ skb->secmark = secid;
+}
+
+
+static int nft_secmark_obj_init(const struct nft_ctx *ctx, const struct nlattr * const tb[], struct nft_object *obj)
+{
+ struct nft_secmark *priv = nft_obj_data(obj);
+
+ if (tb[NFTA_SECMARK_CTX] == NULL)
+ return -EINVAL;
+
+ nla_strlcpy(priv->ctx, tb[NFTA_SECMARK_CTX], NFT_SECMARK_CTX_MAXLEN);
+ priv->len = strlen(priv->ctx);
+
+ security_secmark_refcount_inc();
+
+ return 0;
+}
+
+static int nft_secmark_obj_dump(struct sk_buff *skb, struct nft_object *obj, bool reset)
+{
+ const struct nft_secmark *priv = nft_obj_data(obj);
+
+ if (nla_put_string(skb, NFTA_SECMARK_CTX, priv->ctx))
+ return -1;
+
+ return 0;
+}
+
+static void nft_secmark_obj_destroy(const struct nft_ctx *ctx, struct nft_object *obj)
+{
+ security_secmark_refcount_dec();
+}
+
+static const struct nft_object_ops nft_secmark_obj_ops = {
+ .type = &nft_secmark_obj_type,
+ .size = sizeof(struct nft_secmark),
+ .init = nft_secmark_obj_init,
+ .eval = nft_secmark_obj_eval,
+ .dump = nft_secmark_obj_dump,
+ .destroy = nft_secmark_obj_destroy,
+};
+struct nft_object_type nft_secmark_obj_type __read_mostly = {
+ .type = NFT_OBJECT_SECMARK,
+ .ops = &nft_secmark_obj_ops,
+ .maxattr = NFTA_SECMARK_MAX,
+ .policy = nft_secmark_policy,
+ .owner = THIS_MODULE,
+};
+
+#endif /* CONFIG_NETWORK_SECMARK */
--
2.19.0
^ permalink raw reply related
* Re: [PATCH bpf-next 1/3] perf/core: introduce perf_event_mmap_bpf_prog
From: Song Liu @ 2018-09-19 23:30 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: David S . Miller, daniel@iogearbox.net, peterz@infradead.org,
acme@kernel.org, netdev@vger.kernel.org, Kernel Team
In-Reply-To: <20180919223935.999270-2-ast@kernel.org>
> On Sep 19, 2018, at 3:39 PM, Alexei Starovoitov <ast@kernel.org> wrote:
>
> introduce perf_event_mmap_bpf_prog() helper to emit RECORD_MMAP events
> into perf ring buffer.
> It's used by bpf load/unload logic to notify user space of addresses
> and names of JITed bpf programs.
>
> Note that event->mmap.pid == -1 is an existing indicator of kernel event.
> In addition use event->mmap.tid == BPF_FS_MAGIC to indicate bpf related
> RECORD_MMAP event.
>
> Alternatively it's possible to introduce new 'enum perf_event_type' command
> specificially for bpf prog load/unload, but existing RECORD_MMAP
> is very close, so the choice made by this patch is to extend it.
>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
I guess we should also use this for kernel modules load/unload?
> ---
> include/linux/perf_event.h | 1 +
> kernel/events/core.c | 44 +++++++++++++++++++++++++++++++++-----
> 2 files changed, 40 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 53c500f0ca79..0e79af83138f 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -1113,6 +1113,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
> }
>
> extern void perf_event_mmap(struct vm_area_struct *vma);
> +void perf_event_mmap_bpf_prog(u64 start, u64 len, char *name, int size);
> extern struct perf_guest_info_callbacks *perf_guest_cbs;
> extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
> extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 2a62b96600ad..c48244ddf993 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -7152,7 +7152,7 @@ static int perf_event_mmap_match(struct perf_event *event,
> {
> struct perf_mmap_event *mmap_event = data;
> struct vm_area_struct *vma = mmap_event->vma;
> - int executable = vma->vm_flags & VM_EXEC;
> + int executable = !vma || vma->vm_flags & VM_EXEC;
>
> return (!executable && event->attr.mmap_data) ||
> (executable && (event->attr.mmap || event->attr.mmap2));
> @@ -7165,12 +7165,13 @@ static void perf_event_mmap_output(struct perf_event *event,
> struct perf_output_handle handle;
> struct perf_sample_data sample;
> int size = mmap_event->event_id.header.size;
> + bool bpf_event = !mmap_event->vma;
> int ret;
>
> if (!perf_event_mmap_match(event, data))
> return;
>
> - if (event->attr.mmap2) {
> + if (event->attr.mmap2 && !bpf_event) {
> mmap_event->event_id.header.type = PERF_RECORD_MMAP2;
> mmap_event->event_id.header.size += sizeof(mmap_event->maj);
> mmap_event->event_id.header.size += sizeof(mmap_event->min);
> @@ -7186,12 +7187,14 @@ static void perf_event_mmap_output(struct perf_event *event,
> if (ret)
> goto out;
>
> - mmap_event->event_id.pid = perf_event_pid(event, current);
> - mmap_event->event_id.tid = perf_event_tid(event, current);
> + if (!bpf_event) {
> + mmap_event->event_id.pid = perf_event_pid(event, current);
> + mmap_event->event_id.tid = perf_event_tid(event, current);
> + }
>
> perf_output_put(&handle, mmap_event->event_id);
>
> - if (event->attr.mmap2) {
> + if (event->attr.mmap2 && !bpf_event) {
> perf_output_put(&handle, mmap_event->maj);
> perf_output_put(&handle, mmap_event->min);
> perf_output_put(&handle, mmap_event->ino);
> @@ -7448,6 +7451,37 @@ void perf_event_mmap(struct vm_area_struct *vma)
> perf_event_mmap_event(&mmap_event);
> }
>
> +void perf_event_mmap_bpf_prog(u64 start, u64 len, char *name, int size)
> +{
> + struct perf_mmap_event mmap_event;
> +
> + if (!atomic_read(&nr_mmap_events))
> + return;
> +
> + if (!IS_ALIGNED(size, sizeof(u64))) {
> + WARN_ONCE(1, "size is not aligned\n");
> + return;
> + }
> +
> + mmap_event = (struct perf_mmap_event){
> + .file_name = name,
> + .file_size = size,
> + .event_id = {
> + .header = {
> + .type = PERF_RECORD_MMAP,
> + .misc = PERF_RECORD_MISC_KERNEL,
> + .size = sizeof(mmap_event.event_id) + size,
> + },
> + .pid = -1, /* indicates kernel */
> + .tid = BPF_FS_MAGIC, /* bpf mmap event */
> + .start = start,
> + .len = len,
> + .pgoff = start,
> + },
> + };
> + perf_iterate_sb(perf_event_mmap_output, &mmap_event, NULL);
> +}
> +
> void perf_event_aux_event(struct perf_event *event, unsigned long head,
> unsigned long size, u64 flags)
> {
> --
> 2.17.1
>
^ permalink raw reply
* [PATCH iproute2 v2 0/3] testsuite: make alltests fixes
From: Petr Vorel @ 2018-09-19 23:36 UTC (permalink / raw)
To: netdev; +Cc: Petr Vorel, Stephen Hemminger, Phil Sutter, Luca Boccassi
Hi,
here are simply fixes to restore 'make alltests'.
Currently it does not run.
Kind regards,
Petr
Petr Vorel (3):
testsuite: Fix missing generate_nlmsg
testsuite: Generate generate_nlmsg when needed
testsuite: Warn about empty $(IPVERS)
testsuite/Makefile | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
--
2.19.0.rc2
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox