netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: David Miller <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	oss-drivers@netronome.com,
	Stephen Hemminger <stephen@networkplumber.org>,
	kbuild test robot <lkp@intel.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Ben Hutchings <ben@decadent.org.uk>,
	Simon Horman <simon.horman@netronome.com>
Subject: Re: [PATCH net] net: netem: fix error path for corrupted GSO frames
Date: Thu, 17 Oct 2019 11:10:06 -0700	[thread overview]
Message-ID: <CAM_iQpW=S+UarEKCtL6q_ZyxVn0chVLgXQyfRNP_Kw-P8_Qt+Q@mail.gmail.com> (raw)
In-Reply-To: <20191016162210.5f2a8256@cakuba.netronome.com>

On Wed, Oct 16, 2019 at 4:22 PM Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> On Wed, 16 Oct 2019 15:42:28 -0700, Cong Wang wrote:
> > > @@ -612,7 +613,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
> > >                         }
> > >                         segs = skb2;
> > >                 }
> > > -               qdisc_tree_reduce_backlog(sch, -nb, prev_len - len);
> > > +               qdisc_tree_reduce_backlog(sch, !skb - nb, prev_len - len);
> >
> > Am I the only one has trouble to understand the expression
> > "!skb - nb"?
>
> The backward logic of qdisc_tree_reduce_backlog() always gives me a
> pause :S

Yeah, reducing with a negative value is actually an add. Feel free
to add a wrapper for this if you think it is better.

>
> Is
> -nb + !skb
> any better?

I don't see how they are different. :-/


>
> The point is we have a "credit" for the "head" skb we dropped. If we
> didn't manage to queue any of the segs then the expression becomes
> ...reduce_backlog(sch, 1, prev_len) basically cleaning up after the
> head.
>
> My knee jerk reaction was -> we should return DROP if head got dropped,
> but that just makes things more nasty because we requeue the segs
> directly into netem so if we say DROP we have to special case all the
> segs which succeeded, that gets even more hairy.

Hmm? My understanding is that !skb is either 0 or 1, so you end up
with either "-nb" or "1 - nb". The formal is easy to understand, while
the later is harder as I don't see why you need to plus 1.

>
> I'm open to suggestions.. :(

Why not write the code in a more readable way, for instance with the :?
operator? And, adding a comment in the code?

Thanks.

  reply	other threads:[~2019-10-17 18:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 16:00 [PATCH net] net: netem: fix error path for corrupted GSO frames Jakub Kicinski
2019-10-16 22:42 ` Cong Wang
2019-10-16 23:22   ` Jakub Kicinski
2019-10-17 18:10     ` Cong Wang [this message]
2019-10-17 18:44       ` Jakub Kicinski
2019-10-17 19:28         ` Cong Wang

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='CAM_iQpW=S+UarEKCtL6q_ZyxVn0chVLgXQyfRNP_Kw-P8_Qt+Q@mail.gmail.com' \
    --to=xiyou.wangcong@gmail.com \
    --cc=ben@decadent.org.uk \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=simon.horman@netronome.com \
    --cc=stephen@networkplumber.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).