All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Ciara Loftus <ciara.loftus@intel.com>,
	Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>,
	"Karlsson, Magnus" <magnus.karlsson@intel.com>
Subject: Re: [PATCH v3 bpf 2/3] libbpf: restore umem state after socket create failure
Date: Tue, 30 Mar 2021 19:21:41 +0200	[thread overview]
Message-ID: <CAJ+HfNh_brhM5C1jModyUPibps2ouPcfGfYscavoqBFCLmWj7Q@mail.gmail.com> (raw)
In-Reply-To: <CAADnVQ+jr2WG4FF3GoPt==tOkOb72bd7Zhkk5iy4omCJ3=qLJQ@mail.gmail.com>

On Tue, 30 Mar 2021 at 17:08, Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Mar 30, 2021 at 5:06 AM Ciara Loftus <ciara.loftus@intel.com> wrote:
> >

[...]

> >         if (--ctx->refcount == 0) {
> > -               err = xsk_get_mmap_offsets(umem->fd, &off);
> > -               if (!err) {
> > -                       munmap(ctx->fill->ring - off.fr.desc,
> > -                              off.fr.desc + umem->config.fill_size *
> > -                              sizeof(__u64));
> > -                       munmap(ctx->comp->ring - off.cr.desc,
> > -                              off.cr.desc + umem->config.comp_size *
> > -                              sizeof(__u64));
> > +               if (unmap) {
> > +                       err = xsk_get_mmap_offsets(umem->fd, &off);
> > +                       if (!err) {
> > +                               munmap(ctx->fill->ring - off.fr.desc,
> > +                                      off.fr.desc + umem->config.fill_size *
> > +                               sizeof(__u64));
> > +                               munmap(ctx->comp->ring - off.cr.desc,
> > +                                      off.cr.desc + umem->config.comp_size *
> > +                               sizeof(__u64));
> > +                       }
>
> The whole function increases indent, since it changes anyway
> could you write it as:
> {
> if (--ctx->refcount)
>   return;
> if (!unmap)
>   goto out_free;
> err = xsk_get
> if (err)
>  goto out_free;
> munmap();
> out_free:
> list_del
> free
> }
>

Yes, please try to reduce the nesting, and while at it try to expand
the as much as possible of the munmap arguments to the full 100 chars.


Björn

  reply	other threads:[~2021-03-30 17:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30 11:34 [PATCH v3 bpf 0/3] AF_XDP Socket Creation Fixes Ciara Loftus
2021-03-30 11:34 ` [PATCH v3 bpf 1/3] libbpf: ensure umem pointer is non-NULL before dereferencing Ciara Loftus
2021-03-30 11:34 ` [PATCH v3 bpf 2/3] libbpf: restore umem state after socket create failure Ciara Loftus
2021-03-30 15:08   ` Alexei Starovoitov
2021-03-30 17:21     ` Björn Töpel [this message]
2021-03-30 11:34 ` [PATCH v3 bpf 3/3] libbpf: only create rx and tx XDP rings when necessary Ciara Loftus
2021-03-30 17:25   ` Björn Töpel

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=CAJ+HfNh_brhM5C1jModyUPibps2ouPcfGfYscavoqBFCLmWj7Q@mail.gmail.com \
    --to=bjorn@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=ciara.loftus@intel.com \
    --cc=magnus.karlsson@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.