Skip to content

Commit 845525a

Browse files
Vlad Yasevichdavem330
authored andcommitted
sctp: Update sctp global memory limit allocations.
Update sctp global memory limit allocations to be the same as TCP. Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 336d326 commit 845525a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

net/sctp/protocol.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#include <linux/inetdevice.h>
5353
#include <linux/seq_file.h>
5454
#include <linux/bootmem.h>
55+
#include <linux/highmem.h>
56+
#include <linux/swap.h>
5557
#include <net/net_namespace.h>
5658
#include <net/protocol.h>
5759
#include <net/ip.h>
@@ -1080,6 +1082,7 @@ SCTP_STATIC __init int sctp_init(void)
10801082
int status = -EINVAL;
10811083
unsigned long goal;
10821084
unsigned long limit;
1085+
unsigned long nr_pages;
10831086
int max_share;
10841087
int order;
10851088

@@ -1175,8 +1178,9 @@ SCTP_STATIC __init int sctp_init(void)
11751178
* Note this initalizes the data in sctpv6_prot too
11761179
* Unabashedly stolen from tcp_init
11771180
*/
1178-
limit = min(num_physpages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
1179-
limit = (limit * (num_physpages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
1181+
nr_pages = totalram_pages - totalhigh_pages;
1182+
limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
1183+
limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
11801184
limit = max(limit, 128UL);
11811185
sysctl_sctp_mem[0] = limit / 4 * 3;
11821186
sysctl_sctp_mem[1] = limit;
@@ -1186,7 +1190,7 @@ SCTP_STATIC __init int sctp_init(void)
11861190
limit = (sysctl_sctp_mem[1]) << (PAGE_SHIFT - 7);
11871191
max_share = min(4UL*1024*1024, limit);
11881192

1189-
sysctl_sctp_rmem[0] = PAGE_SIZE; /* give each asoc 1 page min */
1193+
sysctl_sctp_rmem[0] = SK_MEM_QUANTUM; /* give each asoc 1 page min */
11901194
sysctl_sctp_rmem[1] = (1500 *(sizeof(struct sk_buff) + 1));
11911195
sysctl_sctp_rmem[2] = max(sysctl_sctp_rmem[1], max_share);
11921196

0 commit comments

Comments
 (0)