Skip to content

Commit 57d5f64

Browse files
Parthasarathy Bhuvaragandavem330
authored andcommitted
tipc: allocate user memory with GFP_KERNEL flag
Until now, we allocate memory always with GFP_ATOMIC flag. When the system is under memory pressure and a user tries to send, the send fails due to low memory. However, the user application can wait for free memory if we allocate it using GFP_KERNEL flag. In this commit, we use allocate memory with GFP_KERNEL for all user allocation. Reported-by: Rune Torgersen <[email protected]> Acked-by: Jon Maloy <[email protected]> Signed-off-by: Parthasarathy Bhuvaragan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 34c55cf commit 57d5f64

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

net/tipc/discover.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
169169

170170
/* Send response, if necessary */
171171
if (respond && (mtyp == DSC_REQ_MSG)) {
172-
rskb = tipc_buf_acquire(MAX_H_SIZE);
172+
rskb = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
173173
if (!rskb)
174174
return;
175175
tipc_disc_init_msg(net, rskb, DSC_RESP_MSG, bearer);
@@ -278,7 +278,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b,
278278
req = kmalloc(sizeof(*req), GFP_ATOMIC);
279279
if (!req)
280280
return -ENOMEM;
281-
req->buf = tipc_buf_acquire(MAX_H_SIZE);
281+
req->buf = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
282282
if (!req->buf) {
283283
kfree(req);
284284
return -ENOMEM;

net/tipc/link.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
13951395
msg_set_seqno(hdr, seqno++);
13961396
pktlen = msg_size(hdr);
13971397
msg_set_size(&tnlhdr, pktlen + INT_H_SIZE);
1398-
tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE);
1398+
tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE, GFP_ATOMIC);
13991399
if (!tnlskb) {
14001400
pr_warn("%sunable to send packet\n", link_co_err);
14011401
return;

net/tipc/msg.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ static unsigned int align(unsigned int i)
5858
* NOTE: Headroom is reserved to allow prepending of a data link header.
5959
* There may also be unrequested tailroom present at the buffer's end.
6060
*/
61-
struct sk_buff *tipc_buf_acquire(u32 size)
61+
struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp)
6262
{
6363
struct sk_buff *skb;
6464
unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
6565

66-
skb = alloc_skb_fclone(buf_size, GFP_ATOMIC);
66+
skb = alloc_skb_fclone(buf_size, gfp);
6767
if (skb) {
6868
skb_reserve(skb, BUF_HEADROOM);
6969
skb_put(skb, size);
@@ -95,7 +95,7 @@ struct sk_buff *tipc_msg_create(uint user, uint type,
9595
struct tipc_msg *msg;
9696
struct sk_buff *buf;
9797

98-
buf = tipc_buf_acquire(hdr_sz + data_sz);
98+
buf = tipc_buf_acquire(hdr_sz + data_sz, GFP_ATOMIC);
9999
if (unlikely(!buf))
100100
return NULL;
101101

@@ -261,7 +261,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
261261

262262
/* No fragmentation needed? */
263263
if (likely(msz <= pktmax)) {
264-
skb = tipc_buf_acquire(msz);
264+
skb = tipc_buf_acquire(msz, GFP_KERNEL);
265265
if (unlikely(!skb))
266266
return -ENOMEM;
267267
skb_orphan(skb);
@@ -282,7 +282,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
282282
msg_set_importance(&pkthdr, msg_importance(mhdr));
283283

284284
/* Prepare first fragment */
285-
skb = tipc_buf_acquire(pktmax);
285+
skb = tipc_buf_acquire(pktmax, GFP_KERNEL);
286286
if (!skb)
287287
return -ENOMEM;
288288
skb_orphan(skb);
@@ -313,7 +313,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
313313
pktsz = drem + INT_H_SIZE;
314314
else
315315
pktsz = pktmax;
316-
skb = tipc_buf_acquire(pktsz);
316+
skb = tipc_buf_acquire(pktsz, GFP_KERNEL);
317317
if (!skb) {
318318
rc = -ENOMEM;
319319
goto error;
@@ -448,7 +448,7 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
448448
if (msz > (max / 2))
449449
return false;
450450

451-
_skb = tipc_buf_acquire(max);
451+
_skb = tipc_buf_acquire(max, GFP_ATOMIC);
452452
if (!_skb)
453453
return false;
454454

@@ -496,7 +496,7 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
496496

497497
/* Never return SHORT header; expand by replacing buffer if necessary */
498498
if (msg_short(hdr)) {
499-
*skb = tipc_buf_acquire(BASIC_H_SIZE + dlen);
499+
*skb = tipc_buf_acquire(BASIC_H_SIZE + dlen, GFP_ATOMIC);
500500
if (!*skb)
501501
goto exit;
502502
memcpy((*skb)->data + BASIC_H_SIZE, msg_data(hdr), dlen);

net/tipc/msg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static inline bool msg_is_reset(struct tipc_msg *hdr)
820820
return (msg_user(hdr) == LINK_PROTOCOL) && (msg_type(hdr) == RESET_MSG);
821821
}
822822

823-
struct sk_buff *tipc_buf_acquire(u32 size);
823+
struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp);
824824
bool tipc_msg_validate(struct sk_buff *skb);
825825
bool tipc_msg_reverse(u32 own_addr, struct sk_buff **skb, int err);
826826
void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type,

net/tipc/name_distr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,
6969
u32 dest)
7070
{
7171
struct tipc_net *tn = net_generic(net, tipc_net_id);
72-
struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size);
72+
struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size, GFP_ATOMIC);
7373
struct tipc_msg *msg;
7474

7575
if (buf != NULL) {

0 commit comments

Comments
 (0)