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>
This commit is contained in:

committed by
David S. Miller

parent
1033990ac5
commit
9dde27de3e
@@ -6412,13 +6412,15 @@ static int sctp_eat_data(const struct sctp_association *asoc,
|
||||
* in sctp_ulpevent_make_rcvmsg will drop the frame if we grow our
|
||||
* memory usage too much
|
||||
*/
|
||||
if (*sk->sk_prot_creator->memory_pressure) {
|
||||
if (sk_under_memory_pressure(sk)) {
|
||||
if (sctp_tsnmap_has_gap(map) &&
|
||||
(sctp_tsnmap_get_ctsn(map) + 1) == tsn) {
|
||||
pr_debug("%s: under pressure, reneging for tsn:%u\n",
|
||||
__func__, tsn);
|
||||
deliver = SCTP_CMD_RENEGE;
|
||||
}
|
||||
} else {
|
||||
sk_mem_reclaim(sk);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user