All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Elena Reshetova <elena.reshetova@intel.com>,
	netdev@vger.kernel.org
Cc: Krzysztof Mazur <krzysiek@podlesie.net>,
	Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>,
	3chas3@gmail.com, Mathias Kresin <dev@kresin.me>
Subject: Re: [PATCH 07/17] net: convert sock.sk_wmem_alloc from atomic_t to refcount_t
Date: Fri, 15 Jun 2018 14:44:43 +0100	[thread overview]
Message-ID: <1529070283.27158.46.camel@infradead.org> (raw)
In-Reply-To: <3cbab0cc-230d-6980-6748-67f777c8ad22@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]



On Fri, 2018-06-15 at 06:39 -0700, Eric Dumazet wrote:
> 
> On 06/15/2018 06:27 AM, Eric Dumazet wrote:
> > 
> > 
> > 
> > On 06/15/2018 05:29 AM, David Woodhouse wrote:
> > > 
> > > On Fri, 2017-06-30 at 13:08 +0300, Elena Reshetova wrote:
> > > > 
> > > > diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
> > > > index c1da539..4d97a89 100644
> > > > --- a/include/linux/atmdev.h
> > > > +++ b/include/linux/atmdev.h
> > > > @@ -254,7 +254,7 @@ static inline void atm_return(struct atm_vcc *vcc,int truesize)
> > > >  
> > > >  static inline int atm_may_send(struct atm_vcc *vcc,unsigned int size)
> > > >  {
> > > > -       return (size + atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) <
> > > > +       return (size + refcount_read(&sk_atm(vcc)->sk_wmem_alloc)) <
> > > >                sk_atm(vcc)->sk_sndbuf;
> > > >  }
> > > 
> > > Hm, this (commit 14afee4b6092fd) may have broken PPPoATM. I did spend a
> > > while staring hard at my own commit 9d02daf754238 which introduced
> > > pppoatm_may_send(), but it's actually atm_may_send() which is never
> > > allowing packets to be pushed.
> > > 
> > > Debugging (which is ongoing) has so far shown that we are accounting
> > > for a packet in pppoatm_send() which has skb->truesize==0x1c0, and
> > > later end up in pppoatm_pop()→atm_raw_pop() with skb->truesize==0x2c0.
> > > 
> > > This was always harmless before, but now it's a refcount_t it appears
> > > to underflow and go into its "screw you" mode and never let any more
> > > packets get sent.
> > > 
> > > I'm staring hard at the special case in pskb_expand_head() to *not*
> > > change skb->truesize under certain circumstances, and wondering if that
> > > (is, should be) covering the case of ATM skbs:
> > > 
> > >         /* It is not generally safe to change skb->truesize.
> > >          * For the moment, we really care of rx path, or
> > >          * when skb is orphaned (not attached to a socket).
> > >          */
> > >         if (!skb->sk || skb->destructor == sock_edemux)
> > >                 skb->truesize += size - osize;
> > > 
> > > Failing that, maybe we should copy the accounted value of skb->truesize 
> > > into the struct skb_atm_data in skb->cb at the time we add it to
> > > sk_wmem_alloc — and then subtract *that* value from sk_wmem_alloc in
> > > atm_raw_pop() instead of the then current value of skb->truesize.
> > > 
> > > Suggestions?
> > > 
> > Maybe ATM should make sure skb->sk is set ?

Yeah... I don't think we want sock_wfree() as a destructor, unless we
also fix up atm_pop_raw() not to do the same refcount_sub() and cope
with some other details, but it could probably be workable with
sufficient caffeine.


> > something like the following :
> > 
> Or simply use a new field in ATM_SKB(skb) to remember a stable
> truesize used in both sides (add/sub)

Right, that was my second suggestion ("copy the accounted value...").

It's a bit of a hack, and I think that actually *using* sock_wfree()
instead of what's currently in atm_pop_raw() would be the better
solution. Does anyone remember why we didn't do that in the first
place?


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5213 bytes --]

  reply	other threads:[~2018-06-15 13:44 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30 10:07 [PATCH 00/17] v3 net generic subsystem refcount conversions Elena Reshetova
2017-06-30 10:07 ` [Bridge] " Elena Reshetova
2017-06-30 10:07 ` Elena Reshetova
2017-06-30 10:07 ` [PATCH 01/17] net: convert inet_peer.refcnt from atomic_t to refcount_t Elena Reshetova
2017-06-30 10:07   ` [Bridge] " Elena Reshetova
2017-06-30 10:07   ` Elena Reshetova
2017-06-30 10:07 ` [PATCH 02/17] net: convert neighbour.refcnt " Elena Reshetova
2017-06-30 10:07   ` [Bridge] " Elena Reshetova
2017-06-30 10:07   ` Elena Reshetova
2017-06-30 10:07 ` [PATCH 03/17] net: convert neigh_params.refcnt " Elena Reshetova
2017-06-30 10:07   ` [Bridge] " Elena Reshetova
2017-06-30 10:07   ` Elena Reshetova
2017-06-30 10:07 ` [PATCH 04/17] net: convert nf_bridge_info.use " Elena Reshetova
2017-06-30 10:07   ` [Bridge] " Elena Reshetova
2017-06-30 10:07 ` [PATCH 05/17] net: convert sk_buff.users " Elena Reshetova
2017-06-30 10:07   ` [Bridge] " Elena Reshetova
2017-06-30 10:07   ` Elena Reshetova
2017-06-30 10:07 ` [PATCH 06/17] net: convert sk_buff_fclones.fclone_ref " Elena Reshetova
2017-06-30 10:07   ` [Bridge] " Elena Reshetova
2017-06-30 10:07   ` Elena Reshetova
2017-06-30 10:08 ` [PATCH 07/17] net: convert sock.sk_wmem_alloc " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2018-06-15 12:29   ` David Woodhouse
2018-06-15 13:27     ` Eric Dumazet
2018-06-15 13:39       ` Eric Dumazet
2018-06-15 13:44         ` David Woodhouse [this message]
2018-06-15 20:00           ` David Woodhouse
2018-06-15 20:49             ` Kevin Darbyshire-Bryant
2018-06-15 20:57               ` David Woodhouse
2018-06-16  3:44                 ` Kevin Darbyshire-Bryant
2018-06-16 11:30                   ` David Woodhouse
2017-06-30 10:08 ` [PATCH 08/17] net: convert sock.sk_refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 09/17] net: convert ip_mc_list.refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08   ` Elena Reshetova
2017-06-30 10:08 ` [PATCH 10/17] net: convert in_device.refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 11/17] net: convert netpoll_info.refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 12/17] net: convert unix_address.refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 13/17] net: convert fib_rule.refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 14/17] net: convert inet_frag_queue.refcnt " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 15/17] net: convert net.passive " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 16/17] net: convert netlbl_lsm_cache.refcount " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-06-30 10:08 ` [PATCH 17/17] net: convert packet_fanout.sk_ref " Elena Reshetova
2017-06-30 10:08   ` [Bridge] " Elena Reshetova
2017-07-03  9:28 ` [PATCH 00/17] v3 net generic subsystem refcount conversions Eric Dumazet
2017-07-03  9:28   ` [Bridge] " Eric Dumazet
2017-07-03  9:54   ` [PATCH net-next] net: avoid one splat in fib_nl_delrule() Eric Dumazet
2017-07-03 10:29     ` David Miller
2017-07-03  9:57   ` [PATCH 00/17] v3 net generic subsystem refcount conversions Reshetova, Elena
2017-07-03  9:57     ` [Bridge] " Reshetova, Elena
2017-07-03  9:57     ` Reshetova, Elena
2017-07-03 10:30     ` Eric Dumazet
2017-07-03 10:30       ` [Bridge] " Eric Dumazet
2017-07-03 10:30       ` Eric Dumazet
2017-07-08 18:51   ` Levin, Alexander (Sasha Levin)
2017-07-08 18:52     ` [Bridge] " Levin, Alexander (Sasha Levin)
2017-07-08 18:51     ` Levin, Alexander (Sasha Levin)
2017-07-10  7:13     ` Reshetova, Elena
2017-07-10  7:13       ` [Bridge] " Reshetova, Elena
2017-07-10  7:13       ` Reshetova, Elena
  -- strict thread matches above, loose matches on Subject: below --
2017-06-28 11:54 [PATCH 00/17] v2 " Elena Reshetova
2017-06-28 11:54 ` [PATCH 07/17] net: convert sock.sk_wmem_alloc from atomic_t to refcount_t Elena Reshetova
2017-06-28 11:54   ` Elena Reshetova

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=1529070283.27158.46.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=3chas3@gmail.com \
    --cc=dev@kresin.me \
    --cc=elena.reshetova@intel.com \
    --cc=eric.dumazet@gmail.com \
    --cc=kevin@darbyshire-bryant.me.uk \
    --cc=krzysiek@podlesie.net \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.