aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/ulpqueue.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2019-04-15 17:15:07 +0800
committerDavid S. Miller <davem@davemloft.net>2019-04-15 13:36:51 -0700
commit9dde27de3e5efa0d032f3c891a0ca833a0d31911 (patch)
treebaba7e7942d6e6a3162db024a2995f306d0afad4 /net/sctp/ulpqueue.c
parentsctp: implement memory accounting on tx path (diff)
downloadlinux-dev-9dde27de3e5efa0d032f3c891a0ca833a0d31911.tar.xz
linux-dev-9dde27de3e5efa0d032f3c891a0ca833a0d31911.zip
sctp: implement memory accounting on rx path
sk_forward_alloc's updating is also done on rx path, but to be consistent we change to use sk_mem_charge() in sctp_skb_set_owner_r(). In sctp_eat_data(), it's not enough to check sctp_memory_pressure only, which doesn't work for mem_cgroup_sockets_enabled, so we change to use sk_under_memory_pressure(). When it's under memory pressure, sk_mem_reclaim() and sk_rmem_schedule() should be called on both RENEGE or CHUNK DELIVERY path exit the memory pressure status as soon as possible. Note that sk_rmem_schedule() is using datalen to make things easy there. Reported-by: Matteo Croce <mcroce@redhat.com> Tested-by: Matteo Croce <mcroce@redhat.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/ulpqueue.c')
-rw-r--r--net/sctp/ulpqueue.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 7cdc3623fa35..a212fe079c07 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -1104,7 +1104,8 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
freed += sctp_ulpq_renege_frags(ulpq, needed - freed);
}
/* If able to free enough room, accept this chunk. */
- if (freed >= needed) {
+ if (sk_rmem_schedule(asoc->base.sk, chunk->skb, needed) &&
+ freed >= needed) {
int retval = sctp_ulpq_tail_data(ulpq, chunk, gfp);
/*
* Enter partial delivery if chunk has not been