From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Jamie Bainbridge <jamie.bainbridge@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Chris Down <chris@chrisdown.name>,
Stephen Hemminger <stephen@networkplumber.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] tcp: Fix tcp_syn_flood_action() if CONFIG_IPV6=n
Date: Fri, 18 Nov 2022 09:29:13 +0100 [thread overview]
Message-ID: <CAMuHMdVQdax10pAgNBbAVDXgVVTAQC93GR1f_4DuKfdAXngNMA@mail.gmail.com> (raw)
In-Reply-To: <CAAvyFNjHp8-iq_A08O_H2VwEBLZRQe+=LzBm45ekgOZ4afnWqA@mail.gmail.com>
Hi Jamie,
On Fri, Nov 18, 2022 at 2:50 AM Jamie Bainbridge
<jamie.bainbridge@gmail.com> wrote:
> On Thu, 17 Nov 2022 at 08:15, Jakub Kicinski <kuba@kernel.org> wrote:
> > On Thu, 17 Nov 2022 08:39:43 +1100 Jamie Bainbridge wrote:
> > > > if (v6) {
> > > > #ifdef v6
> > > > expensive_call6();
> > > > #endif
> > > > } else {
> > > > expensive_call6();
> > > > }
> > >
> > > These should work, but I expect they cause a comparison which can't be
> > > optimised out at compile time. This is probably why the first style
> > > exists.
> > >
> > > In this SYN flood codepath optimisation doesn't matter because we're
> > > doing ratelimited logging anyway. But if we're breaking with existing
> > > style, then wouldn't the others also have to change to this style? I
> > > haven't reviewed all the other usage to tell if they're in an oft-used
> > > fastpath where such a thing might matter.
> >
> > I think the word style already implies subjectivity.
>
> You are right. Looking further, there are many other ways
> IF_ENABLED(CONFIG_IPV6) is used, including similar to the ways you
> have suggested.
>
> I don't mind Geert's original patch, but if you want a different
> style, I like your suggestion with v4 first:
>
> if (v4) {
> expensive_call4();
> #ifdef v6
> } else {
> expensive_call6();
> #endif
> }
IMHO this is worse, as the #ifdef/#endif is spread across the two branches
of an if-conditional.
Hence this is usually written as:
if (cond1) {
expensive_call1();
}
#ifdef cond2_enabled
else {
expensive_call1();
}
#endif
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2022-11-18 8:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 10:12 [PATCH net-next] tcp: Fix tcp_syn_flood_action() if CONFIG_IPV6=n Geert Uytterhoeven
2022-11-15 11:37 ` Matthieu Baerts
2022-11-16 20:31 ` Jakub Kicinski
2022-11-16 21:39 ` Jamie Bainbridge
2022-11-16 22:15 ` Jakub Kicinski
2022-11-18 1:45 ` Jamie Bainbridge
2022-11-18 8:29 ` Geert Uytterhoeven [this message]
2022-11-18 16:19 ` Jakub Kicinski
2022-11-21 22:44 ` Saeed Mahameed
2022-11-22 3:52 ` Jakub Kicinski
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=CAMuHMdVQdax10pAgNBbAVDXgVVTAQC93GR1f_4DuKfdAXngNMA@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=chris@chrisdown.name \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=jamie.bainbridge@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stephen@networkplumber.org \
--cc=yoshfuji@linux-ipv6.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).