[Devel] [PATCH RHEL7 COMMIT] net/af_packet: fix kmem charge/uncharge
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Apr 6 01:54:23 PDT 2017
The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.12
------>
commit 45acf36083a840bdc14aebc55f15cae1f27cc12e
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date: Thu Apr 6 12:54:22 2017 +0400
net/af_packet: fix kmem charge/uncharge
After rebase to rhel7.3 memcg_[un]charge_kmem() takes number of pages
instead of size in bytes. Callers in net/packet/af_packet.c were not
updated, so they still pass bytes which leads to bogus -ENOMEM.
To be merged into: ("bca9734 net: packet: rework rx/tx ring pages accounting")
https://jira.sw.ru/browse/PSBM-63654
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
net/packet/af_packet.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 30ec580..8214b9f 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2508,7 +2508,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
#ifdef CONFIG_MEMCG_KMEM
struct packet_sk_charge {
struct mem_cgroup *memcg;
- unsigned long amt;
+ unsigned long nr_pages;
};
static struct cg_proto *packet_sk_charge(void)
@@ -2532,9 +2532,9 @@ static struct cg_proto *packet_sk_charge(void)
* It's typically not huge and packet sockets are rare guests in
* containers, so we don't disturb the memory consumption much.
*/
- psc->amt = ACCESS_ONCE(sysctl_rmem_max);
+ psc->nr_pages = ACCESS_ONCE(sysctl_rmem_max)/PAGE_SIZE;
- err = memcg_charge_kmem(psc->memcg, GFP_KERNEL, psc->amt);
+ err = memcg_charge_kmem(psc->memcg, GFP_KERNEL, psc->nr_pages);
if (!err)
goto out;
@@ -2559,7 +2559,7 @@ static void packet_sk_uncharge(struct cg_proto *cg)
struct packet_sk_charge *psc = (struct packet_sk_charge *)cg;
if (psc) {
- memcg_uncharge_kmem(psc->memcg, psc->amt);
+ memcg_uncharge_kmem(psc->memcg, psc->nr_pages);
mem_cgroup_put(psc->memcg);
kfree(psc);
}
@@ -3882,13 +3882,13 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
err = -ENOMEM;
order = get_order(req->tp_block_size);
if (psc && memcg_charge_kmem(psc->memcg, GFP_KERNEL,
- (PAGE_SIZE << order) * req->tp_block_nr))
+ (1 << order) * req->tp_block_nr))
goto out;
pg_vec = alloc_pg_vec(req, order);
if (unlikely(!pg_vec)) {
if (psc)
memcg_uncharge_kmem(psc->memcg,
- (PAGE_SIZE << order) * req->tp_block_nr);
+ (1 << order) * req->tp_block_nr);
goto out;
}
switch (po->tp_version) {
@@ -3962,7 +3962,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
if (pg_vec) {
if (psc)
memcg_uncharge_kmem(psc->memcg,
- (PAGE_SIZE << order) * req->tp_block_nr);
+ (1 << order) * req->tp_block_nr);
free_pg_vec(pg_vec, order, req->tp_block_nr);
}
out:
More information about the Devel
mailing list