Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void
@ 2020-09-01 8:39 Björn Töpel
2020-09-01 9:16 ` Jesper Dangaard Brouer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Björn Töpel @ 2020-09-01 8:39 UTC (permalink / raw)
To: ast, daniel, bpf
Cc: Björn Töpel, magnus.karlsson, netdev, toke, brouer, dsahern
From: Björn Töpel <bjorn.topel@intel.com>
The functions bq_enqueue(), bq_flush_to_queue(), and bq_xmit_all() in
{cpu,dev}map.c always return zero. Changing the return type from int
to void makes the code easier to follow.
Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
kernel/bpf/cpumap.c | 11 +++--------
kernel/bpf/devmap.c | 15 +++++++--------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index 8d2a8623d2a7..cf548fc88780 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -79,8 +79,6 @@ struct bpf_cpu_map {
static DEFINE_PER_CPU(struct list_head, cpu_map_flush_list);
-static int bq_flush_to_queue(struct xdp_bulk_queue *bq);
-
static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
{
u32 value_size = attr->value_size;
@@ -670,7 +668,7 @@ const struct bpf_map_ops cpu_map_ops = {
.map_btf_id = &cpu_map_btf_id,
};
-static int bq_flush_to_queue(struct xdp_bulk_queue *bq)
+static void bq_flush_to_queue(struct xdp_bulk_queue *bq)
{
struct bpf_cpu_map_entry *rcpu = bq->obj;
unsigned int processed = 0, drops = 0;
@@ -679,7 +677,7 @@ static int bq_flush_to_queue(struct xdp_bulk_queue *bq)
int i;
if (unlikely(!bq->count))
- return 0;
+ return;
q = rcpu->queue;
spin_lock(&q->producer_lock);
@@ -702,13 +700,12 @@ static int bq_flush_to_queue(struct xdp_bulk_queue *bq)
/* Feedback loop via tracepoints */
trace_xdp_cpumap_enqueue(rcpu->map_id, processed, drops, to_cpu);
- return 0;
}
/* Runs under RCU-read-side, plus in softirq under NAPI protection.
* Thus, safe percpu variable access.
*/
-static int bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
+static void bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
{
struct list_head *flush_list = this_cpu_ptr(&cpu_map_flush_list);
struct xdp_bulk_queue *bq = this_cpu_ptr(rcpu->bulkq);
@@ -729,8 +726,6 @@ static int bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
if (!bq->flush_node.prev)
list_add(&bq->flush_node, flush_list);
-
- return 0;
}
int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp,
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index a42052b85c35..2b5ca93c17de 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -341,14 +341,14 @@ bool dev_map_can_have_prog(struct bpf_map *map)
return false;
}
-static int bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
+static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
{
struct net_device *dev = bq->dev;
int sent = 0, drops = 0, err = 0;
int i;
if (unlikely(!bq->count))
- return 0;
+ return;
for (i = 0; i < bq->count; i++) {
struct xdp_frame *xdpf = bq->q[i];
@@ -369,7 +369,7 @@ static int bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, drops, err);
bq->dev_rx = NULL;
__list_del_clearprev(&bq->flush_node);
- return 0;
+ return;
error:
/* If ndo_xdp_xmit fails with an errno, no frames have been
* xmit'ed and it's our responsibility to them free all.
@@ -421,8 +421,8 @@ struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key)
/* Runs under RCU-read-side, plus in softirq under NAPI protection.
* Thus, safe percpu variable access.
*/
-static int bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
- struct net_device *dev_rx)
+static void bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
+ struct net_device *dev_rx)
{
struct list_head *flush_list = this_cpu_ptr(&dev_flush_list);
struct xdp_dev_bulk_queue *bq = this_cpu_ptr(dev->xdp_bulkq);
@@ -441,8 +441,6 @@ static int bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
if (!bq->flush_node.prev)
list_add(&bq->flush_node, flush_list);
-
- return 0;
}
static inline int __xdp_enqueue(struct net_device *dev, struct xdp_buff *xdp,
@@ -462,7 +460,8 @@ static inline int __xdp_enqueue(struct net_device *dev, struct xdp_buff *xdp,
if (unlikely(!xdpf))
return -EOVERFLOW;
- return bq_enqueue(dev, xdpf, dev_rx);
+ bq_enqueue(dev, xdpf, dev_rx);
+ return 0;
}
static struct xdp_buff *dev_map_run_prog(struct net_device *dev,
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void
2020-09-01 8:39 [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void Björn Töpel
@ 2020-09-01 9:16 ` Jesper Dangaard Brouer
2020-09-01 9:30 ` Toke Høiland-Jørgensen
2020-09-01 14:21 ` Daniel Borkmann
2 siblings, 0 replies; 4+ messages in thread
From: Jesper Dangaard Brouer @ 2020-09-01 9:16 UTC (permalink / raw)
To: Björn Töpel
Cc: ast, daniel, bpf, Björn Töpel, magnus.karlsson, netdev,
toke, dsahern, brouer
On Tue, 1 Sep 2020 10:39:28 +0200
Björn Töpel <bjorn.topel@gmail.com> wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
>
> The functions bq_enqueue(), bq_flush_to_queue(), and bq_xmit_all() in
> {cpu,dev}map.c always return zero. Changing the return type from int
> to void makes the code easier to follow.
>
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> ---
> kernel/bpf/cpumap.c | 11 +++--------
> kernel/bpf/devmap.c | 15 +++++++--------
> 2 files changed, 10 insertions(+), 16 deletions(-)
Thanks for the cleanup! :-)
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void
2020-09-01 8:39 [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void Björn Töpel
2020-09-01 9:16 ` Jesper Dangaard Brouer
@ 2020-09-01 9:30 ` Toke Høiland-Jørgensen
2020-09-01 14:21 ` Daniel Borkmann
2 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-09-01 9:30 UTC (permalink / raw)
To: Björn Töpel, ast, daniel, bpf
Cc: Björn Töpel, magnus.karlsson, netdev, brouer, dsahern
Björn Töpel <bjorn.topel@gmail.com> writes:
> From: Björn Töpel <bjorn.topel@intel.com>
>
> The functions bq_enqueue(), bq_flush_to_queue(), and bq_xmit_all() in
> {cpu,dev}map.c always return zero. Changing the return type from int
> to void makes the code easier to follow.
>
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void
2020-09-01 8:39 [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void Björn Töpel
2020-09-01 9:16 ` Jesper Dangaard Brouer
2020-09-01 9:30 ` Toke Høiland-Jørgensen
@ 2020-09-01 14:21 ` Daniel Borkmann
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2020-09-01 14:21 UTC (permalink / raw)
To: Björn Töpel, ast, bpf
Cc: Björn Töpel, magnus.karlsson, netdev, toke, brouer, dsahern
On 9/1/20 10:39 AM, Björn Töpel wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
>
> The functions bq_enqueue(), bq_flush_to_queue(), and bq_xmit_all() in
> {cpu,dev}map.c always return zero. Changing the return type from int
> to void makes the code easier to follow.
>
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-01 14:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 8:39 [PATCH bpf-next v2] bpf: {cpu,dev}map: change various functions return type from int to void Björn Töpel
2020-09-01 9:16 ` Jesper Dangaard Brouer
2020-09-01 9:30 ` Toke Høiland-Jørgensen
2020-09-01 14:21 ` Daniel Borkmann
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).