Re: [PATCH bpf-next] bpf, sockmap: Bundle psock->sk_redir and redir_ingress into a tagged pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 13, 2023 at 1:14 AM Jakub Sitnicki <jakub@xxxxxxxxxxxxxx> wrote:
>
> On Fri, Nov 10, 2023 at 07:42 AM -08, Alexei Starovoitov wrote:
> > On Fri, Nov 10, 2023 at 1:44 AM Pengcheng Yang <yangpc@xxxxxxxxxx> wrote:
> >>
> >> Like skb->_sk_redir, we bundle the sock redirect pointer and
> >> the ingress bit to manage them together.
> >>
> >> Suggested-by: Jakub Sitnicki <jakub@xxxxxxxxxxxxxx>
> >> Link: https://lore.kernel.org/bpf/87cz97cnz8.fsf@xxxxxxxxxxxxxx
> >> Signed-off-by: Pengcheng Yang <yangpc@xxxxxxxxxx>
> >> ---
> >>  include/linux/skmsg.h | 30 ++++++++++++++++++++++++++++--
> >>  net/core/skmsg.c      | 18 ++++++++++--------
> >>  net/ipv4/tcp_bpf.c    | 13 +++++++------
> >>  net/tls/tls_sw.c      | 11 ++++++-----
> >>  4 files changed, 51 insertions(+), 21 deletions(-)
> >>
> >> diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
> >> index c1637515a8a4..ae021f511f46 100644
> >> --- a/include/linux/skmsg.h
> >> +++ b/include/linux/skmsg.h
> >> @@ -78,11 +78,10 @@ struct sk_psock_work_state {
> >>
> >>  struct sk_psock {
> >>         struct sock                     *sk;
> >> -       struct sock                     *sk_redir;
> >> +       unsigned long                   _sk_redir;
> >
> > Please don't.
> > There is no need to bundle them together.
>
> Seeing how the code turned out, I agree - it didn't work out.
> Code is not any simpler. My gut feeling was wrong here.
>
> I gotta ask for, for the future, though -
> this is not a "no" to tagged pointers in general, right?

In 99% cases there is no need to mix pointers with flags.
When you need to set/unset both pls use a lock.
A lot more obvious to humans and tools.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux