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 21:00:27 +0100 [thread overview]
Message-ID: <00520334446ffa4671513bb42ebeeecfab4107e7.camel@infradead.org> (raw)
In-Reply-To: <1529070283.27158.46.camel@infradead.org>
On Fri, 2018-06-15 at 14:44 +0100, David Woodhouse wrote:
>
> > 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?
That does end up being quite hairy. I don't think it's worth doing.
This should probably suffice to fix it...
Kevin this is going to conflict with the ifx_atm_alloc_skb() hack in
the tree you're working on, but that needs to be killed with fire
anyway. It's utterly pointless as discussed.
>From 3368eaeb0a2f09138894dde0f26f879e5228005a Mon Sep 17 00:00:00 2001
From: David Woodhouse <dwmw2@infradead.org>
Date: Fri, 15 Jun 2018 20:49:20 +0100
Subject: [PATCH] atm: Preserve value of skb->truesize when accounting to vcc
There's a hack in pskb_expand_head() to avoid adjusting skb->truesize
for certain skbs. Ideally it would cover ATM too. It doesn't. Just
stashing the accounted value and using it in atm_raw_pop() is probably
the easiest way to cope.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
---
include/linux/atmdev.h | 15 +++++++++++++++
net/atm/br2684.c | 3 +--
net/atm/clip.c | 3 +--
net/atm/common.c | 3 +--
net/atm/lec.c | 3 +--
net/atm/mpc.c | 3 +--
net/atm/pppoatm.c | 3 +--
net/atm/raw.c | 4 ++--
8 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 0c27515d2cf6..8124815eb121 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -214,6 +214,7 @@ struct atmphy_ops {
struct atm_skb_data {
struct atm_vcc *vcc; /* ATM VCC */
unsigned long atm_options; /* ATM layer options */
+ unsigned int acct_truesize; /* truesize accounted to vcc */
};
#define VCC_HTABLE_SIZE 32
@@ -241,6 +242,20 @@ void vcc_insert_socket(struct sock *sk);
void atm_dev_release_vccs(struct atm_dev *dev);
+static inline void atm_account_tx(struct atm_vcc *vcc, struct sk_buff *skb)
+{
+ /*
+ * Because ATM skbs may not belong to a sock (and we don't
+ * necessarily want to), skb->truesize may be adjusted,
+ * escaping the hack in pskb_expand_head() which avoids
+ * doing so for some cases. So stash the value of truesize
+ * at the time we accounted it, and atm_pop_raw() can use
+ * that value later, in case it changes.
+ */
+ refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
+ ATM_SKB(skb)->acct_truesize = skb->truesize;
+ ATM_SKB(skb)->atm_options = vcc->atm_options;
+}
static inline void atm_force_charge(struct atm_vcc *vcc,int truesize)
{
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 4e111196f902..bc21f8e8daf2 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -252,8 +252,7 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev,
ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
- refcount_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc);
- ATM_SKB(skb)->atm_options = atmvcc->atm_options;
+ atm_account_tx(atmvcc, skb);
dev->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 65f706e4344c..60920a42f640 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -381,8 +381,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
memcpy(here, llc_oui, sizeof(llc_oui));
((__be16 *) here)[3] = skb->protocol;
}
- refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
- ATM_SKB(skb)->atm_options = vcc->atm_options;
+ atm_account_tx(vcc, skb);
entry->vccs->last_use = jiffies;
pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev);
old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */
diff --git a/net/atm/common.c b/net/atm/common.c
index 8a4f99114cd2..9e812c782a37 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -630,10 +630,9 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size)
goto out;
}
pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize);
- refcount_add(skb->truesize, &sk->sk_wmem_alloc);
+ atm_account_tx(vcc, skb);
skb->dev = NULL; /* for paths shared with net_device interfaces */
- ATM_SKB(skb)->atm_options = vcc->atm_options;
if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) {
kfree_skb(skb);
error = -EFAULT;
diff --git a/net/atm/lec.c b/net/atm/lec.c
index a3d93a1bb133..d7cc165e24e0 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -179,9 +179,8 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
struct net_device *dev = skb->dev;
ATM_SKB(skb)->vcc = vcc;
- ATM_SKB(skb)->atm_options = vcc->atm_options;
+ atm_account_tx(vcc, skb);
- refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
if (vcc->send(vcc, skb) < 0) {
dev->stats.tx_dropped++;
return;
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 5677147209e8..db9a1838687c 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -555,8 +555,7 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc)
sizeof(struct llc_snap_hdr));
}
- refcount_add(skb->truesize, &sk_atm(entry->shortcut)->sk_wmem_alloc);
- ATM_SKB(skb)->atm_options = entry->shortcut->atm_options;
+ atm_account_tx(entry->shortcut, skb);
entry->shortcut->send(entry->shortcut, skb);
entry->packets_fwded++;
mpc->in_ops->put(entry);
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index 21d9d341a619..af8c4b38b746 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -350,8 +350,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb)
return 1;
}
- refcount_add(skb->truesize, &sk_atm(ATM_SKB(skb)->vcc)->sk_wmem_alloc);
- ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options;
+ atm_account_tx(vcc, skb);
pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n",
skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev);
ret = ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb)
diff --git a/net/atm/raw.c b/net/atm/raw.c
index ee10e8d46185..b3ba44aab0ee 100644
--- a/net/atm/raw.c
+++ b/net/atm/raw.c
@@ -35,8 +35,8 @@ static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb)
struct sock *sk = sk_atm(vcc);
pr_debug("(%d) %d -= %d\n",
- vcc->vci, sk_wmem_alloc_get(sk), skb->truesize);
- WARN_ON(refcount_sub_and_test(skb->truesize, &sk->sk_wmem_alloc));
+ vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize);
+ WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc));
dev_kfree_skb_any(skb);
sk->sk_write_space(sk);
}
--
2.17.0
--
dwmw2
next prev parent reply other threads:[~2018-06-15 20:00 UTC|newest]
Thread overview: 35+ 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 ` [PATCH 01/17] net: convert inet_peer.refcnt from atomic_t to refcount_t Elena Reshetova
2017-06-30 10:07 ` [PATCH 02/17] net: convert neighbour.refcnt " Elena Reshetova
2017-06-30 10:07 ` [PATCH 03/17] net: convert neigh_params.refcnt " Elena Reshetova
2017-06-30 10:07 ` [PATCH 04/17] net: convert nf_bridge_info.use " Elena Reshetova
2017-06-30 10:07 ` [PATCH 05/17] net: convert sk_buff.users " Elena Reshetova
2017-06-30 10:07 ` [PATCH 06/17] net: convert sk_buff_fclones.fclone_ref " Elena Reshetova
2017-06-30 10:08 ` [PATCH 07/17] net: convert sock.sk_wmem_alloc " 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
2018-06-15 20:00 ` David Woodhouse [this message]
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 ` [PATCH 09/17] net: convert ip_mc_list.refcnt " Elena Reshetova
2017-06-30 10:08 ` [PATCH 10/17] net: convert in_device.refcnt " Elena Reshetova
2017-06-30 10:08 ` [PATCH 11/17] net: convert netpoll_info.refcnt " Elena Reshetova
2017-06-30 10:08 ` [PATCH 12/17] net: convert unix_address.refcnt " Elena Reshetova
2017-06-30 10:08 ` [PATCH 13/17] net: convert fib_rule.refcnt " Elena Reshetova
2017-06-30 10:08 ` [PATCH 14/17] net: convert inet_frag_queue.refcnt " Elena Reshetova
2017-06-30 10:08 ` [PATCH 15/17] net: convert net.passive " Elena Reshetova
2017-06-30 10:08 ` [PATCH 16/17] net: convert netlbl_lsm_cache.refcount " Elena Reshetova
2017-06-30 10:08 ` [PATCH 17/17] net: convert packet_fanout.sk_ref " Elena Reshetova
2017-07-03 9:28 ` [PATCH 00/17] v3 net generic subsystem refcount conversions 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 10:30 ` Eric Dumazet
2017-07-08 18:51 ` Levin, Alexander (Sasha Levin)
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
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=00520334446ffa4671513bb42ebeeecfab4107e7.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 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).