mbox series

[net-next,0/4] tcp: increase flexibility of EBPF congestion control initialization

Message ID 20200909181556.2945496-1-ncardwell@google.com
Headers show
Series tcp: increase flexibility of EBPF congestion control initialization | expand

Message

Neal Cardwell Sept. 9, 2020, 6:15 p.m. UTC
This patch series reorganizes TCP congestion control initialization so that if
EBPF code called by tcp_init_transfer() sets the congestion control algorithm
by calling setsockopt(TCP_CONGESTION) then the TCP stack initializes the
congestion control module immediately, instead of having tcp_init_transfer()
later initialize the congestion control module.

This increases flexibility for the EBPF code that runs at connection
establishment time, and simplifies the code.

This has the following benefits:

(1) This allows CC module customizations made by the EBPF called in
    tcp_init_transfer() to persist, and not be wiped out by a later
    call to tcp_init_congestion_control() in tcp_init_transfer().

(2) Does not flip the order of EBPF and CC init, to avoid causing bugs
    for existing code upstream that depends on the current order.

(3) Does not cause 2 initializations for for CC in the case where the
    EBPF called in tcp_init_transfer() wants to set the CC to a new CC
    algorithm.

(4) Allows follow-on simplifications to the code in net/core/filter.c
    and net/ipv4/tcp_cong.c, which currently both have some complexity
    to special-case CC initialization to avoid double CC
    initialization if EBPF sets the CC.

Neal Cardwell (4):
  tcp: only init congestion control if not initialized already
  tcp: simplify EBPF TCP_CONGESTION to always init CC
  tcp: simplify tcp_set_congestion_control(): always reinitialize
  tcp: simplify _bpf_setsockopt(): remove flags argument

 include/net/inet_connection_sock.h |  3 ++-
 include/net/tcp.h                  |  2 +-
 net/core/filter.c                  | 18 ++++--------------
 net/ipv4/tcp.c                     |  3 ++-
 net/ipv4/tcp_cong.c                | 14 ++++----------
 net/ipv4/tcp_input.c               |  4 +++-
 6 files changed, 16 insertions(+), 28 deletions(-)

Comments

Martin KaFai Lau Sept. 10, 2020, 12:36 a.m. UTC | #1
On Wed, Sep 09, 2020 at 02:15:52PM -0400, Neal Cardwell wrote:
> This patch series reorganizes TCP congestion control initialization so that if
> EBPF code called by tcp_init_transfer() sets the congestion control algorithm
> by calling setsockopt(TCP_CONGESTION) then the TCP stack initializes the
> congestion control module immediately, instead of having tcp_init_transfer()
> later initialize the congestion control module.
> 
> This increases flexibility for the EBPF code that runs at connection
> establishment time, and simplifies the code.
> 
> This has the following benefits:
> 
> (1) This allows CC module customizations made by the EBPF called in
>     tcp_init_transfer() to persist, and not be wiped out by a later
>     call to tcp_init_congestion_control() in tcp_init_transfer().
> 
> (2) Does not flip the order of EBPF and CC init, to avoid causing bugs
>     for existing code upstream that depends on the current order.
> 
> (3) Does not cause 2 initializations for for CC in the case where the
>     EBPF called in tcp_init_transfer() wants to set the CC to a new CC
>     algorithm.
> 
> (4) Allows follow-on simplifications to the code in net/core/filter.c
>     and net/ipv4/tcp_cong.c, which currently both have some complexity
>     to special-case CC initialization to avoid double CC
>     initialization if EBPF sets the CC.
Thanks for this work.  Only have one nit in patch 3 for consideration.

Acked-by: Martin KaFai Lau <kafai@fb.com>
Neal Cardwell Sept. 10, 2020, 3:21 a.m. UTC | #2
On Wed, Sep 9, 2020 at 8:36 PM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Wed, Sep 09, 2020 at 02:15:52PM -0400, Neal Cardwell wrote:
> > This patch series reorganizes TCP congestion control initialization so that if
> > EBPF code called by tcp_init_transfer() sets the congestion control algorithm
> > by calling setsockopt(TCP_CONGESTION) then the TCP stack initializes the
> > congestion control module immediately, instead of having tcp_init_transfer()
> > later initialize the congestion control module.
> >
> > This increases flexibility for the EBPF code that runs at connection
> > establishment time, and simplifies the code.
> >
> > This has the following benefits:
> >
> > (1) This allows CC module customizations made by the EBPF called in
> >     tcp_init_transfer() to persist, and not be wiped out by a later
> >     call to tcp_init_congestion_control() in tcp_init_transfer().
> >
> > (2) Does not flip the order of EBPF and CC init, to avoid causing bugs
> >     for existing code upstream that depends on the current order.
> >
> > (3) Does not cause 2 initializations for for CC in the case where the
> >     EBPF called in tcp_init_transfer() wants to set the CC to a new CC
> >     algorithm.
> >
> > (4) Allows follow-on simplifications to the code in net/core/filter.c
> >     and net/ipv4/tcp_cong.c, which currently both have some complexity
> >     to special-case CC initialization to avoid double CC
> >     initialization if EBPF sets the CC.
> Thanks for this work.  Only have one nit in patch 3 for consideration.
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>

Thanks for the review! I like your suggestion in patch 3 to further
simplify the code. Do you mind submitting your idea for a follow-on
clean-up/refactor as a separate follow-on commit?

thanks,
neal
Martin KaFai Lau Sept. 10, 2020, 5:12 a.m. UTC | #3
On Wed, Sep 09, 2020 at 11:21:50PM -0400, Neal Cardwell wrote:
> On Wed, Sep 9, 2020 at 8:36 PM Martin KaFai Lau <kafai@fb.com> wrote:
> >
> > On Wed, Sep 09, 2020 at 02:15:52PM -0400, Neal Cardwell wrote:
> > > This patch series reorganizes TCP congestion control initialization so that if
> > > EBPF code called by tcp_init_transfer() sets the congestion control algorithm
> > > by calling setsockopt(TCP_CONGESTION) then the TCP stack initializes the
> > > congestion control module immediately, instead of having tcp_init_transfer()
> > > later initialize the congestion control module.
> > >
> > > This increases flexibility for the EBPF code that runs at connection
> > > establishment time, and simplifies the code.
> > >
> > > This has the following benefits:
> > >
> > > (1) This allows CC module customizations made by the EBPF called in
> > >     tcp_init_transfer() to persist, and not be wiped out by a later
> > >     call to tcp_init_congestion_control() in tcp_init_transfer().
> > >
> > > (2) Does not flip the order of EBPF and CC init, to avoid causing bugs
> > >     for existing code upstream that depends on the current order.
> > >
> > > (3) Does not cause 2 initializations for for CC in the case where the
> > >     EBPF called in tcp_init_transfer() wants to set the CC to a new CC
> > >     algorithm.
> > >
> > > (4) Allows follow-on simplifications to the code in net/core/filter.c
> > >     and net/ipv4/tcp_cong.c, which currently both have some complexity
> > >     to special-case CC initialization to avoid double CC
> > >     initialization if EBPF sets the CC.
> > Thanks for this work.  Only have one nit in patch 3 for consideration.
> >
> > Acked-by: Martin KaFai Lau <kafai@fb.com>
> 
> Thanks for the review! I like your suggestion in patch 3 to further
> simplify the code. Do you mind submitting your idea for a follow-on
> clean-up/refactor as a separate follow-on commit?
Sure. will do.
Alexei Starovoitov Sept. 10, 2020, 5:31 a.m. UTC | #4
On Wed, Sep 9, 2020 at 8:24 PM Neal Cardwell <ncardwell@google.com> wrote:
>
> On Wed, Sep 9, 2020 at 8:36 PM Martin KaFai Lau <kafai@fb.com> wrote:
> >
> > On Wed, Sep 09, 2020 at 02:15:52PM -0400, Neal Cardwell wrote:
> > > This patch series reorganizes TCP congestion control initialization so that if
> > > EBPF code called by tcp_init_transfer() sets the congestion control algorithm
> > > by calling setsockopt(TCP_CONGESTION) then the TCP stack initializes the
> > > congestion control module immediately, instead of having tcp_init_transfer()
> > > later initialize the congestion control module.
> > >
> > > This increases flexibility for the EBPF code that runs at connection
> > > establishment time, and simplifies the code.
> > >
> > > This has the following benefits:
> > >
> > > (1) This allows CC module customizations made by the EBPF called in
> > >     tcp_init_transfer() to persist, and not be wiped out by a later
> > >     call to tcp_init_congestion_control() in tcp_init_transfer().
> > >
> > > (2) Does not flip the order of EBPF and CC init, to avoid causing bugs
> > >     for existing code upstream that depends on the current order.
> > >
> > > (3) Does not cause 2 initializations for for CC in the case where the
> > >     EBPF called in tcp_init_transfer() wants to set the CC to a new CC
> > >     algorithm.
> > >
> > > (4) Allows follow-on simplifications to the code in net/core/filter.c
> > >     and net/ipv4/tcp_cong.c, which currently both have some complexity
> > >     to special-case CC initialization to avoid double CC
> > >     initialization if EBPF sets the CC.
> > Thanks for this work.  Only have one nit in patch 3 for consideration.
> >
> > Acked-by: Martin KaFai Lau <kafai@fb.com>
>
> Thanks for the review! I like your suggestion in patch 3 to further
> simplify the code. Do you mind submitting your idea for a follow-on
> clean-up/refactor as a separate follow-on commit?

I think it's better to be folded into this set.
It needs rebase to bpf-next anyway.
Neal Cardwell Sept. 10, 2020, 1:17 p.m. UTC | #5
OK, thanks everyone. I will rebase the series onto bpf-next and
include a patch with Martin's suggested follow-on cleanup. Will
resubmit ASAP.

thanks,
neal


On Thu, Sep 10, 2020 at 1:31 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Wed, Sep 9, 2020 at 8:24 PM Neal Cardwell <ncardwell@google.com> wrote:
> >
> > On Wed, Sep 9, 2020 at 8:36 PM Martin KaFai Lau <kafai@fb.com> wrote:
> > >
> > > On Wed, Sep 09, 2020 at 02:15:52PM -0400, Neal Cardwell wrote:
> > > > This patch series reorganizes TCP congestion control initialization so that if
> > > > EBPF code called by tcp_init_transfer() sets the congestion control algorithm
> > > > by calling setsockopt(TCP_CONGESTION) then the TCP stack initializes the
> > > > congestion control module immediately, instead of having tcp_init_transfer()
> > > > later initialize the congestion control module.
> > > >
> > > > This increases flexibility for the EBPF code that runs at connection
> > > > establishment time, and simplifies the code.
> > > >
> > > > This has the following benefits:
> > > >
> > > > (1) This allows CC module customizations made by the EBPF called in
> > > >     tcp_init_transfer() to persist, and not be wiped out by a later
> > > >     call to tcp_init_congestion_control() in tcp_init_transfer().
> > > >
> > > > (2) Does not flip the order of EBPF and CC init, to avoid causing bugs
> > > >     for existing code upstream that depends on the current order.
> > > >
> > > > (3) Does not cause 2 initializations for for CC in the case where the
> > > >     EBPF called in tcp_init_transfer() wants to set the CC to a new CC
> > > >     algorithm.
> > > >
> > > > (4) Allows follow-on simplifications to the code in net/core/filter.c
> > > >     and net/ipv4/tcp_cong.c, which currently both have some complexity
> > > >     to special-case CC initialization to avoid double CC
> > > >     initialization if EBPF sets the CC.
> > > Thanks for this work.  Only have one nit in patch 3 for consideration.
> > >
> > > Acked-by: Martin KaFai Lau <kafai@fb.com>
> >
> > Thanks for the review! I like your suggestion in patch 3 to further
> > simplify the code. Do you mind submitting your idea for a follow-on
> > clean-up/refactor as a separate follow-on commit?
>
> I think it's better to be folded into this set.
> It needs rebase to bpf-next anyway.