]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
treewide: convert PF_MEMALLOC manipulations to new helpers
authorVlastimil Babka <vbabka@suse.cz>
Mon, 8 May 2017 22:59:53 +0000 (15:59 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 May 2017 00:15:15 +0000 (17:15 -0700)
We now have memalloc_noreclaim_{save,restore} helpers for robust setting
and clearing of PF_MEMALLOC.  Let's convert the code which was using the
generic tsk_restore_flags().  No functional change.

[vbabka@suse.cz: in net/core/sock.c the hunk is missing]
Link: http://lkml.kernel.org/r/20170405074700.29871-4-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Josef Bacik <jbacik@fb.com>
Cc: Lee Duncan <lduncan@suse.com>
Cc: Chris Leech <cleech@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Wouter Verhelst <w@uter.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/block/nbd.c
drivers/scsi/iscsi_tcp.c
net/core/dev.c
net/core/sock.c

index e9e2a9e95a66479ae780a785b3410469ed41451e..9a7bb2c2944772cad8124a965bacc17d0aa8f935 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/sched/mm.h>
 #include <linux/fs.h>
 #include <linux/bio.h>
 #include <linux/stat.h>
@@ -347,7 +348,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send,
        struct socket *sock = config->socks[index]->sock;
        int result;
        struct msghdr msg;
-       unsigned long pflags = current->flags;
+       unsigned int noreclaim_flag;
 
        if (unlikely(!sock)) {
                dev_err_ratelimited(disk_to_dev(nbd->disk),
@@ -358,7 +359,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send,
 
        msg.msg_iter = *iter;
 
-       current->flags |= PF_MEMALLOC;
+       noreclaim_flag = memalloc_noreclaim_save();
        do {
                sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC;
                msg.msg_name = NULL;
@@ -381,7 +382,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send,
                        *sent += result;
        } while (msg_data_left(&msg));
 
-       current_restore_flags(pflags, PF_MEMALLOC);
+       memalloc_noreclaim_restore(noreclaim_flag);
 
        return result;
 }
index bbea8eac9abb737b7be67366ab9cdcde89830609..4842fc0e809d1cf6846ba531165953f1dd11f993 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/types.h>
 #include <linux/inet.h>
 #include <linux/slab.h>
+#include <linux/sched/mm.h>
 #include <linux/file.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
@@ -371,10 +372,10 @@ static inline int iscsi_sw_tcp_xmit_qlen(struct iscsi_conn *conn)
 static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task)
 {
        struct iscsi_conn *conn = task->conn;
-       unsigned long pflags = current->flags;
+       unsigned int noreclaim_flag;
        int rc = 0;
 
-       current->flags |= PF_MEMALLOC;
+       noreclaim_flag = memalloc_noreclaim_save();
 
        while (iscsi_sw_tcp_xmit_qlen(conn)) {
                rc = iscsi_sw_tcp_xmit(conn);
@@ -387,7 +388,7 @@ static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task)
                rc = 0;
        }
 
-       current_restore_flags(pflags, PF_MEMALLOC);
+       memalloc_noreclaim_restore(noreclaim_flag);
        return rc;
 }
 
index 99924d16f2bd3f94e738c296c233ae0535d1f7ff..96cf83da0d66b2db07d5504c4c3aec7da735ea46 100644 (file)
@@ -81,6 +81,7 @@
 #include <linux/hash.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/sched/mm.h>
 #include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/mm.h>
@@ -4235,7 +4236,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
        int ret;
 
        if (sk_memalloc_socks() && skb_pfmemalloc(skb)) {
-               unsigned long pflags = current->flags;
+               unsigned int noreclaim_flag;
 
                /*
                 * PFMEMALLOC skbs are special, they should
@@ -4246,9 +4247,9 @@ static int __netif_receive_skb(struct sk_buff *skb)
                 * Use PF_MEMALLOC as this saves us from propagating the allocation
                 * context down to all allocation sites.
                 */
-               current->flags |= PF_MEMALLOC;
+               noreclaim_flag = memalloc_noreclaim_save();
                ret = __netif_receive_skb_core(skb, true);
-               current_restore_flags(pflags, PF_MEMALLOC);
+               memalloc_noreclaim_restore(noreclaim_flag);
        } else
                ret = __netif_receive_skb_core(skb, false);
 
index b5baeb9cb0fb1bff2fb7c49c0a850bc493f7e58d..79c6aee6af9b817bd7086f04ae8f46342a3bf4b6 100644 (file)
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/sched.h>
+#include <linux/sched/mm.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
@@ -372,14 +373,14 @@ EXPORT_SYMBOL_GPL(sk_clear_memalloc);
 int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
 {
        int ret;
-       unsigned long pflags = current->flags;
+       unsigned int noreclaim_flag;
 
        /* these should have been dropped before queueing */
        BUG_ON(!sock_flag(sk, SOCK_MEMALLOC));
 
-       current->flags |= PF_MEMALLOC;
+       noreclaim_flag = memalloc_noreclaim_save();
        ret = sk->sk_backlog_rcv(sk, skb);
-       current_restore_flags(pflags, PF_MEMALLOC);
+       memalloc_noreclaim_restore(noreclaim_flag);
 
        return ret;
 }