From: John Fastabend <john.fastabend@gmail.com>
To: Jesper Dangaard Brouer <brouer@redhat.com>, netdev@vger.kernel.org
Subject: Re: [net-next PATCH] bpf: cpumap micro-optimization in cpu_map_enqueue
Date: Wed, 1 Nov 2017 06:54:46 -0700 [thread overview]
Message-ID: <bcee429e-2f51-b75e-62cb-798e023d0ceb@gmail.com> (raw)
In-Reply-To: <150953668583.30172.5069550217700139382.stgit@firesoul>
On 11/01/2017 04:44 AM, Jesper Dangaard Brouer wrote:
> Discovered that the compiler laid-out asm code in suboptimal way
> when studying perf report during benchmarking of cpumap. Help
> the compiler by the marking unlikely code paths.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
> kernel/bpf/cpumap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index 86e29cbf7827..ce5b669003b2 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -208,7 +208,7 @@ static struct xdp_pkt *convert_to_xdp_pkt(struct xdp_buff *xdp)
> headroom = xdp->data - xdp->data_hard_start;
> metasize = xdp->data - xdp->data_meta;
> metasize = metasize > 0 ? metasize : 0;
> - if ((headroom - metasize) < sizeof(*xdp_pkt))
> + if (unlikely((headroom - metasize) < sizeof(*xdp_pkt)))
> return NULL;
>
> /* Store info in top of packet */
> @@ -656,7 +656,7 @@ int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp,
> struct xdp_pkt *xdp_pkt;
>
> xdp_pkt = convert_to_xdp_pkt(xdp);
> - if (!xdp_pkt)
> + if (unlikely(!xdp_pkt))
> return -EOVERFLOW;
>
> /* Info needed when constructing SKB on remote CPU */
>
Seems OK to me, just curious is this noticeable at pps benchmarks?
Acked-by: John Fastabend <john.fastabend@gmail.com>
next prev parent reply other threads:[~2017-11-01 13:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 11:44 [net-next PATCH] bpf: cpumap micro-optimization in cpu_map_enqueue Jesper Dangaard Brouer
2017-11-01 13:54 ` John Fastabend [this message]
2017-11-01 14:18 ` Jesper Dangaard Brouer
2017-11-01 16:12 ` Alexei Starovoitov
2017-11-02 7:14 ` David Miller
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=bcee429e-2f51-b75e-62cb-798e023d0ceb@gmail.com \
--to=john.fastabend@gmail.com \
--cc=brouer@redhat.com \
--cc=netdev@vger.kernel.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).