From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Abeni Subject: Re: [PATCH net-next 1/3] net/sock: factor out dequeue/peek with offset code Date: Tue, 23 Oct 2018 09:28:03 +0200 Message-ID: <4c94ee8fe77a51d61927bfff46441abc15172193.camel@redhat.com> References: <503e324ecd4085f256474df1a352a92814fd29f4.1494837879.git.pabeni@redhat.com> <20181023044929.guyx7uwf5ndt6hiz@ast-mbp> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , kafai@fb.com To: Alexei Starovoitov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58248 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbeJWPuP (ORCPT ); Tue, 23 Oct 2018 11:50:15 -0400 In-Reply-To: <20181023044929.guyx7uwf5ndt6hiz@ast-mbp> Sender: netdev-owner@vger.kernel.org List-ID: Hi, On Mon, 2018-10-22 at 21:49 -0700, Alexei Starovoitov wrote: > On Mon, May 15, 2017 at 11:01:42AM +0200, Paolo Abeni wrote: > > And update __sk_queue_drop_skb() to work on the specified queue. > > This will help the udp protocol to use an additional private > > rx queue in a later patch. > > > > Signed-off-by: Paolo Abeni > > --- > > include/linux/skbuff.h | 7 ++++ > > include/net/sock.h | 4 +-- > > net/core/datagram.c | 90 ++++++++++++++++++++++++++++---------------------- > > 3 files changed, 60 insertions(+), 41 deletions(-) > > > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > > index a098d95..bfc7892 100644 > > --- a/include/linux/skbuff.h > > +++ b/include/linux/skbuff.h > > @@ -3056,6 +3056,13 @@ static inline void skb_frag_list_init(struct sk_buff *skb) > > > > int __skb_wait_for_more_packets(struct sock *sk, int *err, long *timeo_p, > > const struct sk_buff *skb); > > +struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, > > + struct sk_buff_head *queue, > > + unsigned int flags, > > + void (*destructor)(struct sock *sk, > > + struct sk_buff *skb), > > + int *peeked, int *off, int *err, > > + struct sk_buff **last); > > struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned flags, > > void (*destructor)(struct sock *sk, > > struct sk_buff *skb), > > diff --git a/include/net/sock.h b/include/net/sock.h > > index 66349e4..49d226f 100644 > > --- a/include/net/sock.h > > +++ b/include/net/sock.h > > @@ -2035,8 +2035,8 @@ void sk_reset_timer(struct sock *sk, struct timer_list *timer, > > > > void sk_stop_timer(struct sock *sk, struct timer_list *timer); > > > > -int __sk_queue_drop_skb(struct sock *sk, struct sk_buff *skb, > > - unsigned int flags, > > +int __sk_queue_drop_skb(struct sock *sk, struct sk_buff_head *sk_queue, > > + struct sk_buff *skb, unsigned int flags, > > void (*destructor)(struct sock *sk, > > struct sk_buff *skb)); > > int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); > > diff --git a/net/core/datagram.c b/net/core/datagram.c > > index db1866f2..a4592b4 100644 > > --- a/net/core/datagram.c > > +++ b/net/core/datagram.c > > @@ -161,6 +161,43 @@ static struct sk_buff *skb_set_peeked(struct sk_buff *skb) > > return skb; > > } > > > > +struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, > > + struct sk_buff_head *queue, > > + unsigned int flags, > > + void (*destructor)(struct sock *sk, > > + struct sk_buff *skb), > > + int *peeked, int *off, int *err, > > + struct sk_buff **last) > > +{ > > + struct sk_buff *skb; > > + > > + *last = queue->prev; > > this refactoring changed the behavior. > Now queue->prev is returned as last. > Whereas it was *last = queue before. > > > + skb_queue_walk(queue, skb) { > > and *last = skb assignment is gone too. > > Was this intentional ? Yes. > Is this the right behavior? I think so. queue->prev is the last skb in the queue. With the old code, __skb_try_recv_datagram(), when returning NULL, used the instructions you quoted to overall set 'last' to the last skb in the queue. We did not use 'last' elsewhere. So overall this just reduce the number of instructions inside the loop. (unless I'm missing something). Are you experiencing any specific issues due to the mentioned commit? Thanks, Paolo