android_kernel_oneplus_msm8998/net/rds
Zhu Yanjun eded0b11c7 net: rds: fix memory leak in rds_ib_flush_mr_pool
[ Upstream commit 85cb928787eab6a2f4ca9d2a798b6f3bed53ced1 ]

When the following tests last for several hours, the problem will occur.

Server:
    rds-stress -r 1.1.1.16 -D 1M
Client:
    rds-stress -r 1.1.1.14 -s 1.1.1.16 -D 1M -T 30

The following will occur.

"
Starting up....
tsks   tx/s   rx/s  tx+rx K/s    mbi K/s    mbo K/s tx us/c   rtt us cpu
%
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
"
>From vmcore, we can find that clean_list is NULL.

>From the source code, rds_mr_flushd calls rds_ib_mr_pool_flush_worker.
Then rds_ib_mr_pool_flush_worker calls
"
 rds_ib_flush_mr_pool(pool, 0, NULL);
"
Then in function
"
int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *pool,
                         int free_all, struct rds_ib_mr **ibmr_ret)
"
ibmr_ret is NULL.

In the source code,
"
...
list_to_llist_nodes(pool, &unmap_list, &clean_nodes, &clean_tail);
if (ibmr_ret)
        *ibmr_ret = llist_entry(clean_nodes, struct rds_ib_mr, llnode);

/* more than one entry in llist nodes */
if (clean_nodes->next)
        llist_add_batch(clean_nodes->next, clean_tail, &pool->clean_list);
...
"
When ibmr_ret is NULL, llist_entry is not executed. clean_nodes->next
instead of clean_nodes is added in clean_list.
So clean_nodes is discarded. It can not be used again.
The workqueue is executed periodically. So more and more clean_nodes are
discarded. Finally the clean_list is NULL.
Then this problem will occur.

Fixes: 1bc144b625 ("net, rds, Replace xlist in net/rds/xlist.h with llist")
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 12:24:12 +02:00
..
af_rds.c
bind.c rds; Reset rs->rs_bound_addr in rds_add_bound() failure path 2018-04-13 19:50:13 +02:00
cong.c
connection.c
ib.c RDS: IB: Fix null pointer issue 2018-05-30 07:48:56 +02:00
ib.h
ib_cm.c rds: ib: add error handle 2017-10-08 10:14:19 +02:00
ib_rdma.c net: rds: fix memory leak in rds_ib_flush_mr_pool 2019-06-11 12:24:12 +02:00
ib_recv.c
ib_ring.c
ib_send.c RDS: RDMA: Fix the composite message user notification 2017-10-08 10:14:16 +02:00
ib_stats.c
ib_sysctl.c
info.c
info.h
iw.c
iw.h
iw_cm.c
iw_rdma.c
iw_recv.c
iw_ring.c
iw_send.c
iw_stats.c
iw_sysctl.c
Kconfig
loop.c rds: avoid unenecessary cong_update in loop transport 2018-07-22 14:25:54 +02:00
loop.h
Makefile
message.c
page.c
rdma.c RDS: null pointer dereference in rds_atomic_free_op 2018-01-17 09:35:29 +01:00
rdma_transport.c
rdma_transport.h
rds.h rds: avoid unenecessary cong_update in loop transport 2018-07-22 14:25:54 +02:00
recv.c rds: avoid unenecessary cong_update in loop transport 2018-07-22 14:25:54 +02:00
send.c RDS: RDMA: return appropriate error on rdma map failures 2017-11-30 08:37:25 +00:00
stats.c
sysctl.c
tcp.c net: rds: force to destroy connection if t_sock is NULL in rds_tcp_kill_sock(). 2019-04-27 09:33:54 +02:00
tcp.h
tcp_connect.c
tcp_listen.c
tcp_recv.c
tcp_send.c
tcp_stats.c
threads.c
transport.c