* __dev_kfree_skb_any() and use of dev_kfree_skb() @ 2018-10-02 20:07 Florian Fainelli 2018-10-02 21:17 ` Eric Dumazet 0 siblings, 1 reply; 6+ messages in thread From: Florian Fainelli @ 2018-10-02 20:07 UTC (permalink / raw) To: netdev, edumazet, nhorman; +Cc: davem Hi Eric, Neil, Should not __dev_kfree_skb_any() call kfree_skb() instead of dev_kfree_skb() which is aliased to consumes_skb() and therefore does not flag the skb with SKB_REASON_DROPPED? If we take the in_irq() || irqs_disabled() branch, we will be calling __dev_kfree_skb_irq() which takes care of setting the skb_free_reason frmo the caller. Is there an implied semantic with dev_kfree_skb() that it means it was freed by the network device and therefore this equals to a consumption (not a drop)? The comment above dev_kfree_skb_any() seems to imply this should be a context unaware replacement for kfree_skb(). Thanks! -- Florian ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: __dev_kfree_skb_any() and use of dev_kfree_skb() 2018-10-02 20:07 __dev_kfree_skb_any() and use of dev_kfree_skb() Florian Fainelli @ 2018-10-02 21:17 ` Eric Dumazet 2018-10-02 21:54 ` Florian Fainelli 0 siblings, 1 reply; 6+ messages in thread From: Eric Dumazet @ 2018-10-02 21:17 UTC (permalink / raw) To: Florian Fainelli; +Cc: netdev, Neil Horman, David Miller On Tue, Oct 2, 2018 at 1:07 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > > Hi Eric, Neil, > > Should not __dev_kfree_skb_any() call kfree_skb() instead of > dev_kfree_skb() which is aliased to consumes_skb() and therefore does > not flag the skb with SKB_REASON_DROPPED? > > If we take the in_irq() || irqs_disabled() branch, we will be calling > __dev_kfree_skb_irq() which takes care of setting the skb_free_reason > frmo the caller. > > Is there an implied semantic with dev_kfree_skb() that it means it was > freed by the network device and therefore this equals to a consumption > (not a drop)? The comment above dev_kfree_skb_any() seems to imply this > should be a context unaware replacement for kfree_skb(). Really the problem here is that we have more than one thousand calls to dev_kfree_skb_any() (compared to ~ 90 calls to dev_consume_skb_any()) So it will be a huge task cleaning all this. (dev_kfree_skb_any() calls were added way before the drop monitor stuff) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: __dev_kfree_skb_any() and use of dev_kfree_skb() 2018-10-02 21:17 ` Eric Dumazet @ 2018-10-02 21:54 ` Florian Fainelli 2018-10-02 22:05 ` Eric Dumazet 0 siblings, 1 reply; 6+ messages in thread From: Florian Fainelli @ 2018-10-02 21:54 UTC (permalink / raw) To: Eric Dumazet; +Cc: netdev, Neil Horman, David Miller On 10/02/2018 02:17 PM, Eric Dumazet wrote: > On Tue, Oct 2, 2018 at 1:07 PM Florian Fainelli <f.fainelli@gmail.com> wrote: >> >> Hi Eric, Neil, >> >> Should not __dev_kfree_skb_any() call kfree_skb() instead of >> dev_kfree_skb() which is aliased to consumes_skb() and therefore does >> not flag the skb with SKB_REASON_DROPPED? >> >> If we take the in_irq() || irqs_disabled() branch, we will be calling >> __dev_kfree_skb_irq() which takes care of setting the skb_free_reason >> frmo the caller. >> >> Is there an implied semantic with dev_kfree_skb() that it means it was >> freed by the network device and therefore this equals to a consumption >> (not a drop)? The comment above dev_kfree_skb_any() seems to imply this >> should be a context unaware replacement for kfree_skb(). > > > Really the problem here is that we have more than one thousand calls > to dev_kfree_skb_any() > (compared to ~ 90 calls to dev_consume_skb_any()) > > So it will be a huge task cleaning all this. So you are kind of saying this is an established behavior, don't change it :) One could argue that if people were happily sprinkling dev_kfree_skb_any() in error or success paths, and all SKB freeing was accounted for as "consumed" instead of "dropped" in non-atomic context, this may not be such a big deal to reverse that and make it "dropped" in all contexts? > > (dev_kfree_skb_any() calls were added way before the drop monitor stuff) > -- Florian ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: __dev_kfree_skb_any() and use of dev_kfree_skb() 2018-10-02 21:54 ` Florian Fainelli @ 2018-10-02 22:05 ` Eric Dumazet 2018-10-02 22:20 ` Florian Fainelli 0 siblings, 1 reply; 6+ messages in thread From: Eric Dumazet @ 2018-10-02 22:05 UTC (permalink / raw) To: Florian Fainelli; +Cc: netdev, Neil Horman, David Miller On Tue, Oct 2, 2018 at 2:54 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > > On 10/02/2018 02:17 PM, Eric Dumazet wrote: > > On Tue, Oct 2, 2018 at 1:07 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > >> > >> Hi Eric, Neil, > >> > >> Should not __dev_kfree_skb_any() call kfree_skb() instead of > >> dev_kfree_skb() which is aliased to consumes_skb() and therefore does > >> not flag the skb with SKB_REASON_DROPPED? > >> > >> If we take the in_irq() || irqs_disabled() branch, we will be calling > >> __dev_kfree_skb_irq() which takes care of setting the skb_free_reason > >> frmo the caller. > >> > >> Is there an implied semantic with dev_kfree_skb() that it means it was > >> freed by the network device and therefore this equals to a consumption > >> (not a drop)? The comment above dev_kfree_skb_any() seems to imply this > >> should be a context unaware replacement for kfree_skb(). > > > > > > Really the problem here is that we have more than one thousand calls > > to dev_kfree_skb_any() > > (compared to ~ 90 calls to dev_consume_skb_any()) > > > > So it will be a huge task cleaning all this. > > So you are kind of saying this is an established behavior, don't change > it :) > > One could argue that if people were happily sprinkling > dev_kfree_skb_any() in error or success paths, and all SKB freeing was > accounted for as "consumed" instead of "dropped" in non-atomic context, > this may not be such a big deal to reverse that and make it "dropped" in > all contexts? > Most of these calls happening on typical hosts are from TX completion path, so they really are consumed, not dropped. So if you intend to pretend they are drops, this will not please people using drop monitor. Really the only way would to review all call sites and perform a cleanup, then propagate the ' reason' properly in the helper. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: __dev_kfree_skb_any() and use of dev_kfree_skb() 2018-10-02 22:05 ` Eric Dumazet @ 2018-10-02 22:20 ` Florian Fainelli 2018-10-03 11:26 ` Neil Horman 0 siblings, 1 reply; 6+ messages in thread From: Florian Fainelli @ 2018-10-02 22:20 UTC (permalink / raw) To: Eric Dumazet; +Cc: netdev, Neil Horman, David Miller On 10/02/2018 03:05 PM, Eric Dumazet wrote: > On Tue, Oct 2, 2018 at 2:54 PM Florian Fainelli <f.fainelli@gmail.com> wrote: >> >> On 10/02/2018 02:17 PM, Eric Dumazet wrote: >>> On Tue, Oct 2, 2018 at 1:07 PM Florian Fainelli <f.fainelli@gmail.com> wrote: >>>> >>>> Hi Eric, Neil, >>>> >>>> Should not __dev_kfree_skb_any() call kfree_skb() instead of >>>> dev_kfree_skb() which is aliased to consumes_skb() and therefore does >>>> not flag the skb with SKB_REASON_DROPPED? >>>> >>>> If we take the in_irq() || irqs_disabled() branch, we will be calling >>>> __dev_kfree_skb_irq() which takes care of setting the skb_free_reason >>>> frmo the caller. >>>> >>>> Is there an implied semantic with dev_kfree_skb() that it means it was >>>> freed by the network device and therefore this equals to a consumption >>>> (not a drop)? The comment above dev_kfree_skb_any() seems to imply this >>>> should be a context unaware replacement for kfree_skb(). >>> >>> >>> Really the problem here is that we have more than one thousand calls >>> to dev_kfree_skb_any() >>> (compared to ~ 90 calls to dev_consume_skb_any()) >>> >>> So it will be a huge task cleaning all this. >> >> So you are kind of saying this is an established behavior, don't change >> it :) >> >> One could argue that if people were happily sprinkling >> dev_kfree_skb_any() in error or success paths, and all SKB freeing was >> accounted for as "consumed" instead of "dropped" in non-atomic context, >> this may not be such a big deal to reverse that and make it "dropped" in >> all contexts? >> > > Most of these calls happening on typical hosts are from TX completion path, > so they really are consumed, not dropped. > > So if you intend to pretend they are drops, this will not please > people using drop monitor. I am not intending to pretend they are drops, just trying to make their behavior consistent depending on the calling context, hence my question whether this was intentional or not because __dev_kfree_skb_irq9() will flag them as dropped correctly. Right now this is not consistent with either the function name nor its comment in include/linux/netdevice.h. > > Really the only way would to review all call sites and perform a > cleanup, then propagate the ' reason' properly > in the helper. > Alright, thanks! -- Florian ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: __dev_kfree_skb_any() and use of dev_kfree_skb() 2018-10-02 22:20 ` Florian Fainelli @ 2018-10-03 11:26 ` Neil Horman 0 siblings, 0 replies; 6+ messages in thread From: Neil Horman @ 2018-10-03 11:26 UTC (permalink / raw) To: Florian Fainelli; +Cc: Eric Dumazet, netdev, David Miller On Tue, Oct 02, 2018 at 03:20:48PM -0700, Florian Fainelli wrote: > On 10/02/2018 03:05 PM, Eric Dumazet wrote: > > On Tue, Oct 2, 2018 at 2:54 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > >> > >> On 10/02/2018 02:17 PM, Eric Dumazet wrote: > >>> On Tue, Oct 2, 2018 at 1:07 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > >>>> > >>>> Hi Eric, Neil, > >>>> > >>>> Should not __dev_kfree_skb_any() call kfree_skb() instead of > >>>> dev_kfree_skb() which is aliased to consumes_skb() and therefore does > >>>> not flag the skb with SKB_REASON_DROPPED? > >>>> > >>>> If we take the in_irq() || irqs_disabled() branch, we will be calling > >>>> __dev_kfree_skb_irq() which takes care of setting the skb_free_reason > >>>> frmo the caller. > >>>> > >>>> Is there an implied semantic with dev_kfree_skb() that it means it was > >>>> freed by the network device and therefore this equals to a consumption > >>>> (not a drop)? The comment above dev_kfree_skb_any() seems to imply this > >>>> should be a context unaware replacement for kfree_skb(). > >>> > >>> > >>> Really the problem here is that we have more than one thousand calls > >>> to dev_kfree_skb_any() > >>> (compared to ~ 90 calls to dev_consume_skb_any()) > >>> > >>> So it will be a huge task cleaning all this. > >> > >> So you are kind of saying this is an established behavior, don't change > >> it :) > >> > >> One could argue that if people were happily sprinkling > >> dev_kfree_skb_any() in error or success paths, and all SKB freeing was > >> accounted for as "consumed" instead of "dropped" in non-atomic context, > >> this may not be such a big deal to reverse that and make it "dropped" in > >> all contexts? > >> > > > > Most of these calls happening on typical hosts are from TX completion path, > > so they really are consumed, not dropped. > > > > So if you intend to pretend they are drops, this will not please > > people using drop monitor. > > I am not intending to pretend they are drops, just trying to make their > behavior consistent depending on the calling context, hence my question > whether this was intentional or not because __dev_kfree_skb_irq9() will > flag them as dropped correctly. Right now this is not consistent with > either the function name nor its comment in include/linux/netdevice.h. > As Eric noted, dev_kfree_skb_any was added before the drop monitor code, and so I don't think much commentary can be made of in the way of 'intent'. The way to reconcile all these code points is to look at each one in turn, determine from the location and the purpose of the call if it is really a drop, or simply the end of the useful life of the skb (a consume), and either change the call to the appropriate one, or decide that whats there is correct. I've done this in the past in several locations, and honestly, its just a tedium. I find that, if you are using drop monitor, and come accross a false positive (or false negative), submit a patch for that location to reconcile it, and slowly they will all get corrected. Neil > > > > Really the only way would to review all call sites and perform a > > cleanup, then propagate the ' reason' properly > > in the helper. > > > > Alright, thanks! > -- > Florian > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-10-03 18:15 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-10-02 20:07 __dev_kfree_skb_any() and use of dev_kfree_skb() Florian Fainelli 2018-10-02 21:17 ` Eric Dumazet 2018-10-02 21:54 ` Florian Fainelli 2018-10-02 22:05 ` Eric Dumazet 2018-10-02 22:20 ` Florian Fainelli 2018-10-03 11:26 ` Neil Horman
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).