Kernel.org Bugzilla – Attachment 210581 Details for
Bug 114591
xfsdump failing with kernel issues inside vm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Revert Commit
0001-Revert-mm-page_alloc-distinguish-between-being-unabl.patch (text/plain), 68.60 KB, created by
nickkrause
on 2016-03-24 14:44:05 UTC
(
hide
)
Description:
Revert Commit
Filename:
MIME Type:
Creator:
nickkrause
Created:
2016-03-24 14:44:05 UTC
Size:
68.60 KB
patch
obsolete
>From b90ce55428794aa1091fc6647b24a4a13cb46324 Mon Sep 17 00:00:00 2001 >From: Nicholas Krause <xerofoify@gmail.com> >Date: Thu, 24 Mar 2016 10:40:04 -0400 >Subject: [PATCH] Revert "mm, page_alloc: distinguish between being unable to > sleep, unwilling to sleep and avoiding waking kswapd" > >This reverts commit d0164adc89f6bb374d304ffcc375c6d2652fe67d. > >Signed-off-by: Nicholas Krause <xerofoify@gmail.com> >--- > Documentation/vm/balance | 14 ++--- > arch/arm/mm/dma-mapping.c | 17 +++++- > arch/arm/xen/mm.c | 2 +- > arch/arm64/mm/dma-mapping.c | 4 +- > arch/x86/kernel/pci-dma.c | 2 +- > block/bio.c | 26 ++++----- > block/blk-core.c | 16 +++--- > block/blk-ioc.c | 2 +- > block/blk-mq-tag.c | 4 ++ > block/blk-mq.c | 13 +++++ > drivers/block/drbd/drbd_receiver.c | 3 +- > drivers/block/osdblk.c | 2 +- > drivers/connector/connector.c | 3 +- > drivers/firewire/core-cdev.c | 2 +- > drivers/gpu/drm/i915/i915_gem.c | 6 ++ > drivers/infiniband/core/sa_query.c | 2 +- > drivers/iommu/amd_iommu.c | 2 +- > drivers/iommu/intel-iommu.c | 2 +- > drivers/md/dm-crypt.c | 6 +- > drivers/md/dm-kcopyd.c | 2 +- > drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 2 +- > drivers/media/pci/solo6x10/solo6x10-v4l2.c | 2 +- > drivers/media/pci/tw68/tw68-video.c | 2 +- > drivers/mtd/mtdcore.c | 3 +- > drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- > drivers/staging/android/ion/ion_system_heap.c | 4 ++ > .../lustre/include/linux/libcfs/libcfs_private.h | 2 +- > drivers/usb/host/u132-hcd.c | 2 +- > drivers/video/fbdev/vermilion/vermilion.c | 2 +- > fs/btrfs/disk-io.c | 2 +- > fs/btrfs/extent_io.c | 17 ++++-- > fs/btrfs/volumes.c | 5 ++ > fs/ext4/super.c | 2 +- > fs/fscache/cookie.c | 2 +- > fs/fscache/page.c | 6 +- > fs/jbd2/transaction.c | 4 +- > fs/nfs/file.c | 6 +- > fs/xfs/xfs_qm.c | 2 +- > include/linux/gfp.h | 65 +++++++++++++++++++++- > include/linux/skbuff.h | 6 +- > include/net/sock.h | 2 +- > include/trace/events/gfpflags.h | 42 ++++++++++++++ > kernel/audit.c | 8 ++- > kernel/cgroup.c | 2 +- > kernel/locking/lockdep.c | 2 +- > kernel/power/snapshot.c | 2 +- > kernel/smp.c | 2 +- > lib/idr.c | 4 +- > lib/radix-tree.c | 10 ++-- > mm/backing-dev.c | 2 +- > mm/dmapool.c | 2 +- > mm/memcontrol.c | 6 +- > mm/mempool.c | 12 ++-- > mm/migrate.c | 4 ++ > mm/page_alloc.c | 44 +++++++++------ > mm/slab.c | 21 +++++-- > mm/slub.c | 35 +++++++++++- > mm/vmalloc.c | 2 +- > mm/vmscan.c | 4 +- > mm/zswap.c | 5 +- > net/core/skbuff.c | 8 +-- > net/core/sock.c | 6 +- > net/netlink/af_netlink.c | 2 +- > net/rds/ib_recv.c | 4 +- > net/rxrpc/ar-connection.c | 2 +- > net/sctp/associola.c | 2 +- > 66 files changed, 358 insertions(+), 145 deletions(-) > create mode 100644 include/trace/events/gfpflags.h > >diff --git a/Documentation/vm/balance b/Documentation/vm/balance >index 9645954..c46e68c 100644 >--- a/Documentation/vm/balance >+++ b/Documentation/vm/balance >@@ -1,14 +1,12 @@ > Started Jan 2000 by Kanoj Sarcar <kanoj@sgi.com> > >-Memory balancing is needed for !__GFP_ATOMIC and !__GFP_KSWAPD_RECLAIM as >-well as for non __GFP_IO allocations. >+Memory balancing is needed for non __GFP_WAIT as well as for non >+__GFP_IO allocations. > >-The first reason why a caller may avoid reclaim is that the caller can not >-sleep due to holding a spinlock or is in interrupt context. The second may >-be that the caller is willing to fail the allocation without incurring the >-overhead of page reclaim. This may happen for opportunistic high-order >-allocation requests that have order-0 fallback options. In such cases, >-the caller may also wish to avoid waking kswapd. >+There are two reasons to be requesting non __GFP_WAIT allocations: >+the caller can not sleep (typically intr context), or does not want >+to incur cost overheads of page stealing and possible swap io for >+whatever reasons. > > __GFP_IO allocation requests are made to prevent file system deadlocks. > >diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c >index deac58d..cb383bc 100644 >--- a/arch/arm/mm/dma-mapping.c >+++ b/arch/arm/mm/dma-mapping.c >@@ -780,6 +780,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, > args.gfp = gfp; > > *handle = DMA_ERROR_CODE; >+<<<<<<< HEAD > allowblock = gfpflags_allow_blocking(gfp); > cma = allowblock ? dev_get_cma_area(dev) : false; > >@@ -789,6 +790,20 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, > buf->allocator = &simple_allocator; > else if (allowblock) > buf->allocator = &remap_allocator; >+======= >+ size = PAGE_ALIGN(size); >+ want_vaddr = !dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs); >+ >+ if (nommu()) >+ addr = __alloc_simple_buffer(dev, size, gfp, &page); >+ else if (dev_get_cma_area(dev) && (gfp & __GFP_WAIT)) >+ addr = __alloc_from_contiguous(dev, size, prot, &page, >+ caller, want_vaddr); >+ else if (is_coherent) >+ addr = __alloc_simple_buffer(dev, size, gfp, &page); >+ else if (!(gfp & __GFP_WAIT)) >+ addr = __alloc_from_pool(size, &page); >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > else > buf->allocator = &pool_allocator; > >@@ -1504,7 +1519,7 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, > *handle = DMA_ERROR_CODE; > size = PAGE_ALIGN(size); > >- if (!gfpflags_allow_blocking(gfp)) >+ if (!(gfp & __GFP_WAIT)) > return __iommu_alloc_atomic(dev, size, handle); > > /* >diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c >index c5f9a9e..7c34f71 100644 >--- a/arch/arm/xen/mm.c >+++ b/arch/arm/xen/mm.c >@@ -25,7 +25,7 @@ > unsigned long xen_get_swiotlb_free_pages(unsigned int order) > { > struct memblock_region *reg; >- gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM; >+ gfp_t flags = __GFP_NOWARN; > > for_each_memblock(memory, reg) { > if (reg->base < (phys_addr_t)0xffffffff) { >diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c >index a6e757c..cda61b2 100644 >--- a/arch/arm64/mm/dma-mapping.c >+++ b/arch/arm64/mm/dma-mapping.c >@@ -98,7 +98,7 @@ static void *__dma_alloc_coherent(struct device *dev, size_t size, > if (IS_ENABLED(CONFIG_ZONE_DMA) && > dev->coherent_dma_mask <= DMA_BIT_MASK(32)) > flags |= GFP_DMA; >- if (dev_get_cma_area(dev) && gfpflags_allow_blocking(flags)) { >+ if (dev_get_cma_area(dev) && (flags & __GFP_WAIT)) { > struct page *page; > void *addr; > >@@ -146,7 +146,7 @@ static void *__dma_alloc(struct device *dev, size_t size, > > size = PAGE_ALIGN(size); > >- if (!coherent && !gfpflags_allow_blocking(flags)) { >+ if (!coherent && !(flags & __GFP_WAIT)) { > struct page *page = NULL; > void *addr = __alloc_from_pool(size, &page, flags); > >diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c >index 6ba014c..cd99433 100644 >--- a/arch/x86/kernel/pci-dma.c >+++ b/arch/x86/kernel/pci-dma.c >@@ -90,7 +90,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size, > again: > page = NULL; > /* CMA can be used only in the context which permits sleeping */ >- if (gfpflags_allow_blocking(flag)) { >+ if (flag & __GFP_WAIT) { > page = dma_alloc_from_contiguous(dev, count, get_order(size)); > if (page && page_to_phys(page) + size > dma_mask) { > dma_release_from_contiguous(dev, page, count); >diff --git a/block/bio.c b/block/bio.c >index f124a0a..d838137 100644 >--- a/block/bio.c >+++ b/block/bio.c >@@ -211,7 +211,7 @@ fallback: > bvl = mempool_alloc(pool, gfp_mask); > } else { > struct biovec_slab *bvs = bvec_slabs + *idx; >- gfp_t __gfp_mask = gfp_mask & ~(__GFP_DIRECT_RECLAIM | __GFP_IO); >+ gfp_t __gfp_mask = gfp_mask & ~(__GFP_WAIT | __GFP_IO); > > /* > * Make this allocation restricted and don't dump info on >@@ -221,11 +221,11 @@ fallback: > __gfp_mask |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN; > > /* >- * Try a slab allocation. If this fails and __GFP_DIRECT_RECLAIM >+ * Try a slab allocation. If this fails and __GFP_WAIT > * is set, retry with the 1-entry mempool > */ > bvl = kmem_cache_alloc(bvs->slab, __gfp_mask); >- if (unlikely(!bvl && (gfp_mask & __GFP_DIRECT_RECLAIM))) { >+ if (unlikely(!bvl && (gfp_mask & __GFP_WAIT))) { > *idx = BIOVEC_MAX_IDX; > goto fallback; > } >@@ -401,12 +401,12 @@ static void punt_bios_to_rescuer(struct bio_set *bs) > * If @bs is NULL, uses kmalloc() to allocate the bio; else the allocation is > * backed by the @bs's mempool. > * >- * When @bs is not NULL, if %__GFP_DIRECT_RECLAIM is set then bio_alloc will >- * always be able to allocate a bio. This is due to the mempool guarantees. >- * To make this work, callers must never allocate more than 1 bio at a time >- * from this pool. Callers that need to allocate more than 1 bio must always >- * submit the previously allocated bio for IO before attempting to allocate >- * a new one. Failure to do so can cause deadlocks under memory pressure. >+ * When @bs is not NULL, if %__GFP_WAIT is set then bio_alloc will always be >+ * able to allocate a bio. This is due to the mempool guarantees. To make this >+ * work, callers must never allocate more than 1 bio at a time from this pool. >+ * Callers that need to allocate more than 1 bio must always submit the >+ * previously allocated bio for IO before attempting to allocate a new one. >+ * Failure to do so can cause deadlocks under memory pressure. > * > * Note that when running under generic_make_request() (i.e. any block > * driver), bios are not submitted until after you return - see the code in >@@ -465,13 +465,13 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs) > * We solve this, and guarantee forward progress, with a rescuer > * workqueue per bio_set. If we go to allocate and there are > * bios on current->bio_list, we first try the allocation >- * without __GFP_DIRECT_RECLAIM; if that fails, we punt those >- * bios we would be blocking to the rescuer workqueue before >- * we retry with the original gfp_flags. >+ * without __GFP_WAIT; if that fails, we punt those bios we >+ * would be blocking to the rescuer workqueue before we retry >+ * with the original gfp_flags. > */ > > if (current->bio_list && !bio_list_empty(current->bio_list)) >- gfp_mask &= ~__GFP_DIRECT_RECLAIM; >+ gfp_mask &= ~__GFP_WAIT; > > p = mempool_alloc(bs->bio_pool, gfp_mask); > if (!p && gfp_mask != saved_gfp) { >diff --git a/block/blk-core.c b/block/blk-core.c >index 827f8ba..12a81a9 100644 >--- a/block/blk-core.c >+++ b/block/blk-core.c >@@ -1230,8 +1230,8 @@ rq_starved: > * @bio: bio to allocate request for (can be %NULL) > * @gfp_mask: allocation mask > * >- * Get a free request from @q. If %__GFP_DIRECT_RECLAIM is set in @gfp_mask, >- * this function keeps retrying under memory pressure and fails iff @q is dead. >+ * Get a free request from @q. If %__GFP_WAIT is set in @gfp_mask, this >+ * function keeps retrying under memory pressure and fails iff @q is dead. > * > * Must be called with @q->queue_lock held and, > * Returns ERR_PTR on failure, with @q->queue_lock held. >@@ -1251,7 +1251,7 @@ retry: > if (!IS_ERR(rq)) > return rq; > >- if (!gfpflags_allow_blocking(gfp_mask) || unlikely(blk_queue_dying(q))) { >+ if (!(gfp_mask & __GFP_WAIT) || unlikely(blk_queue_dying(q))) { > blk_put_rl(rl); > return rq; > } >@@ -1331,11 +1331,11 @@ EXPORT_SYMBOL(blk_get_request); > * BUG. > * > * WARNING: When allocating/cloning a bio-chain, careful consideration should be >- * given to how you allocate bios. In particular, you cannot use >- * __GFP_DIRECT_RECLAIM for anything but the first bio in the chain. Otherwise >- * you risk waiting for IO completion of a bio that hasn't been submitted yet, >- * thus resulting in a deadlock. Alternatively bios should be allocated using >- * bio_kmalloc() instead of bio_alloc(), as that avoids the mempool deadlock. >+ * given to how you allocate bios. In particular, you cannot use __GFP_WAIT for >+ * anything but the first bio in the chain. Otherwise you risk waiting for IO >+ * completion of a bio that hasn't been submitted yet, thus resulting in a >+ * deadlock. Alternatively bios should be allocated using bio_kmalloc() instead >+ * of bio_alloc(), as that avoids the mempool deadlock. > * If possible a big IO should be split into smaller parts when allocation > * fails. Partial allocation should not be an error, or you risk a live-lock. > */ >diff --git a/block/blk-ioc.c b/block/blk-ioc.c >index 381cb50..1a27f45 100644 >--- a/block/blk-ioc.c >+++ b/block/blk-ioc.c >@@ -289,7 +289,7 @@ struct io_context *get_task_io_context(struct task_struct *task, > { > struct io_context *ioc; > >- might_sleep_if(gfpflags_allow_blocking(gfp_flags)); >+ might_sleep_if(gfp_flags & __GFP_WAIT); > > do { > task_lock(task); >diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c >index abdbb47..308f0a6 100644 >--- a/block/blk-mq-tag.c >+++ b/block/blk-mq-tag.c >@@ -268,7 +268,11 @@ static int bt_get(struct blk_mq_alloc_data *data, > if (tag != -1) > return tag; > >+<<<<<<< HEAD > if (data->flags & BLK_MQ_REQ_NOWAIT) >+======= >+ if (!(data->gfp & __GFP_WAIT)) >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > return -1; > > bs = bt_wait_ptr(bt, hctx); >diff --git a/block/blk-mq.c b/block/blk-mq.c >index 050f7a1..0256f1c 100644 >--- a/block/blk-mq.c >+++ b/block/blk-mq.c >@@ -244,10 +244,18 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, > > ctx = blk_mq_get_ctx(q); > hctx = q->mq_ops->map_queue(q, ctx->cpu); >+<<<<<<< HEAD > blk_mq_set_alloc_data(&alloc_data, q, flags, ctx, hctx); > > rq = __blk_mq_alloc_request(&alloc_data, rw); > if (!rq && !(flags & BLK_MQ_REQ_NOWAIT)) { >+======= >+ blk_mq_set_alloc_data(&alloc_data, q, gfp & ~__GFP_WAIT, >+ reserved, ctx, hctx); >+ >+ rq = __blk_mq_alloc_request(&alloc_data, rw); >+ if (!rq && (gfp & __GFP_WAIT)) { >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > __blk_mq_run_hw_queue(hctx); > blk_mq_put_ctx(ctx); > >@@ -1190,7 +1198,12 @@ static struct request *blk_mq_map_request(struct request_queue *q, > > ctx = blk_mq_get_ctx(q); > hctx = q->mq_ops->map_queue(q, ctx->cpu); >+<<<<<<< HEAD > blk_mq_set_alloc_data(&alloc_data, q, 0, ctx, hctx); >+======= >+ blk_mq_set_alloc_data(&alloc_data, q, >+ __GFP_WAIT|GFP_ATOMIC, false, ctx, hctx); >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > rq = __blk_mq_alloc_request(&alloc_data, rw); > ctx = alloc_data.ctx; > hctx = alloc_data.hctx; >diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c >index 050aaa1..1cf4082 100644 >--- a/drivers/block/drbd/drbd_receiver.c >+++ b/drivers/block/drbd/drbd_receiver.c >@@ -381,8 +381,7 @@ drbd_alloc_peer_req(struct drbd_peer_device *peer_device, u64 id, sector_t secto > } > > if (has_payload && data_size) { >- page = drbd_alloc_pages(peer_device, nr_pages, >- gfpflags_allow_blocking(gfp_mask)); >+ page = drbd_alloc_pages(peer_device, nr_pages, (gfp_mask & __GFP_WAIT)); > if (!page) > goto fail; > } >diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c >index 1b709a4..e229425 100644 >--- a/drivers/block/osdblk.c >+++ b/drivers/block/osdblk.c >@@ -271,7 +271,7 @@ static struct bio *bio_chain_clone(struct bio *old_chain, gfp_t gfpmask) > goto err_out; > > tmp->bi_bdev = NULL; >- gfpmask &= ~__GFP_DIRECT_RECLAIM; >+ gfpmask &= ~__GFP_WAIT; > tmp->bi_next = NULL; > > if (!new_chain) >diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c >index 25693b0..c19e7fc 100644 >--- a/drivers/connector/connector.c >+++ b/drivers/connector/connector.c >@@ -124,8 +124,7 @@ int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group, > if (group) > return netlink_broadcast(dev->nls, skb, portid, group, > gfp_mask); >- return netlink_unicast(dev->nls, skb, portid, >- !gfpflags_allow_blocking(gfp_mask)); >+ return netlink_unicast(dev->nls, skb, portid, !(gfp_mask&__GFP_WAIT)); > } > EXPORT_SYMBOL_GPL(cn_netlink_send_mult); > >diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c >index aee149b..0814824 100644 >--- a/drivers/firewire/core-cdev.c >+++ b/drivers/firewire/core-cdev.c >@@ -486,7 +486,7 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg) > static int add_client_resource(struct client *client, > struct client_resource *resource, gfp_t gfp_mask) > { >- bool preload = gfpflags_allow_blocking(gfp_mask); >+ bool preload = !!(gfp_mask & __GFP_WAIT); > unsigned long flags; > int ret; > >diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c >index 3d31d3a..7ed9551 100644 >--- a/drivers/gpu/drm/i915/i915_gem.c >+++ b/drivers/gpu/drm/i915/i915_gem.c >@@ -2277,8 +2277,14 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) > * Fail silently without starting the shrinker > */ > mapping = file_inode(obj->base.filp)->i_mapping; >+<<<<<<< HEAD > gfp = mapping_gfp_constraint(mapping, ~(__GFP_IO | __GFP_RECLAIM)); > gfp |= __GFP_NORETRY | __GFP_NOWARN; >+======= >+ gfp = mapping_gfp_mask(mapping); >+ gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD; >+ gfp &= ~(__GFP_IO | __GFP_WAIT); >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > sg = st->sgl; > st->nents = 0; > for (i = 0; i < page_count; i++) { >diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c >index 8a09c0f..febd9cf 100644 >--- a/drivers/infiniband/core/sa_query.c >+++ b/drivers/infiniband/core/sa_query.c >@@ -1155,7 +1155,7 @@ static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) > > static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask) > { >- bool preload = gfpflags_allow_blocking(gfp_mask); >+ bool preload = !!(gfp_mask & __GFP_WAIT); > unsigned long flags; > int ret, id; > >diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c >index 374c129..7942637 100644 >--- a/drivers/iommu/amd_iommu.c >+++ b/drivers/iommu/amd_iommu.c >@@ -2758,7 +2758,7 @@ static void *alloc_coherent(struct device *dev, size_t size, > > page = alloc_pages(flag | __GFP_NOWARN, get_order(size)); > if (!page) { >- if (!gfpflags_allow_blocking(flag)) >+ if (!(flag & __GFP_WAIT)) > return NULL; > > page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, >diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c >index a2e1b7f..037ec54 100644 >--- a/drivers/iommu/intel-iommu.c >+++ b/drivers/iommu/intel-iommu.c >@@ -3647,7 +3647,7 @@ static void *intel_alloc_coherent(struct device *dev, size_t size, > flags |= GFP_DMA32; > } > >- if (gfpflags_allow_blocking(flags)) { >+ if (flags & __GFP_WAIT) { > unsigned int count = size >> PAGE_SHIFT; > > page = dma_alloc_from_contiguous(dev, count, order); >diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c >index 4f3cb35..cde6ec4 100644 >--- a/drivers/md/dm-crypt.c >+++ b/drivers/md/dm-crypt.c >@@ -998,7 +998,7 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) > struct bio_vec *bvec; > > retry: >- if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM)) >+ if (unlikely(gfp_mask & __GFP_WAIT)) > mutex_lock(&cc->bio_alloc_lock); > > clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); >@@ -1014,7 +1014,7 @@ retry: > if (!page) { > crypt_free_buffer_pages(cc, clone); > bio_put(clone); >- gfp_mask |= __GFP_DIRECT_RECLAIM; >+ gfp_mask |= __GFP_WAIT; > goto retry; > } > >@@ -1031,7 +1031,7 @@ retry: > } > > return_clone: >- if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM)) >+ if (unlikely(gfp_mask & __GFP_WAIT)) > mutex_unlock(&cc->bio_alloc_lock); > > return clone; >diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c >index 1452ed9..3a7cade 100644 >--- a/drivers/md/dm-kcopyd.c >+++ b/drivers/md/dm-kcopyd.c >@@ -244,7 +244,7 @@ static int kcopyd_get_pages(struct dm_kcopyd_client *kc, > *pages = NULL; > > do { >- pl = alloc_pl(__GFP_NOWARN | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM); >+ pl = alloc_pl(__GFP_NOWARN | __GFP_NORETRY); > if (unlikely(!pl)) { > /* Use reserved pages */ > pl = kc->pages; >diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c >index 67a14c4..eedafc5 100644 >--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c >+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c >@@ -1295,7 +1295,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, > solo_enc->vidq.ops = &solo_enc_video_qops; > solo_enc->vidq.mem_ops = &vb2_dma_sg_memops; > solo_enc->vidq.drv_priv = solo_enc; >- solo_enc->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; >+ solo_enc->vidq.gfp_flags = __GFP_DMA32; > solo_enc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; > solo_enc->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); > solo_enc->vidq.lock = &solo_enc->lock; >diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c >index 721ff53..e3146a9 100644 >--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c >+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c >@@ -678,7 +678,7 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr) > solo_dev->vidq.mem_ops = &vb2_dma_contig_memops; > solo_dev->vidq.drv_priv = solo_dev; > solo_dev->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; >- solo_dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; >+ solo_dev->vidq.gfp_flags = __GFP_DMA32; > solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); > solo_dev->vidq.lock = &solo_dev->lock; > ret = vb2_queue_init(&solo_dev->vidq); >diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c >index 07116a8..5f4dd28 100644 >--- a/drivers/media/pci/tw68/tw68-video.c >+++ b/drivers/media/pci/tw68/tw68-video.c >@@ -979,7 +979,7 @@ int tw68_video_init2(struct tw68_dev *dev, int video_nr) > dev->vidq.ops = &tw68_video_qops; > dev->vidq.mem_ops = &vb2_dma_sg_memops; > dev->vidq.drv_priv = dev; >- dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; >+ dev->vidq.gfp_flags = __GFP_DMA32; > dev->vidq.buf_struct_size = sizeof(struct tw68_buf); > dev->vidq.lock = &dev->lock; > dev->vidq.min_buffers_needed = 2; >diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c >index 3096251..56bf0c5 100644 >--- a/drivers/mtd/mtdcore.c >+++ b/drivers/mtd/mtdcore.c >@@ -1230,7 +1230,8 @@ EXPORT_SYMBOL_GPL(mtd_writev); > */ > void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size) > { >- gfp_t flags = __GFP_NOWARN | __GFP_DIRECT_RECLAIM | __GFP_NORETRY; >+ gfp_t flags = __GFP_NOWARN | __GFP_WAIT | >+ __GFP_NORETRY | __GFP_NO_KSWAPD; > size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); > void *kbuf; > >diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c >index 0a9108c..07e88de 100644 >--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c >+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c >@@ -687,7 +687,7 @@ static void *bnx2x_frag_alloc(const struct bnx2x_fastpath *fp, gfp_t gfp_mask) > { > if (fp->rx_frag_size) { > /* GFP_KERNEL allocations are used only during initialization */ >- if (unlikely(gfpflags_allow_blocking(gfp_mask))) >+ if (unlikely(gfp_mask & __GFP_WAIT)) > return (void *)__get_free_page(gfp_mask); > > return netdev_alloc_frag(fp->rx_frag_size); >diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c >index b69dfc7..d2dfe7f 100644 >--- a/drivers/staging/android/ion/ion_system_heap.c >+++ b/drivers/staging/android/ion/ion_system_heap.c >@@ -27,7 +27,11 @@ > #include "ion_priv.h" > > static gfp_t high_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN | >+<<<<<<< HEAD > __GFP_NORETRY) & ~__GFP_RECLAIM; >+======= >+ __GFP_NORETRY) & ~__GFP_WAIT; >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > static gfp_t low_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN); > static const unsigned int orders[] = {8, 4, 0}; > static const int num_orders = ARRAY_SIZE(orders); >diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h >index dab4862..200d87d 100644 >--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h >+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h >@@ -95,7 +95,7 @@ do { \ > do { \ > LASSERT(!in_interrupt() || \ > ((size) <= LIBCFS_VMALLOC_SIZE && \ >- !gfpflags_allow_blocking(mask))); \ >+ ((mask) & __GFP_WAIT) == 0)); \ > } while (0) > > #define LIBCFS_ALLOC_POST(ptr, size) \ >diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c >index 43d5293..8e0f280 100644 >--- a/drivers/usb/host/u132-hcd.c >+++ b/drivers/usb/host/u132-hcd.c >@@ -2240,7 +2240,7 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, > { > struct u132 *u132 = hcd_to_u132(hcd); > if (irqs_disabled()) { >- if (gfpflags_allow_blocking(mem_flags)) { >+ if (__GFP_WAIT & mem_flags) { > printk(KERN_ERR "invalid context for function that might sleep\n"); > return -EINVAL; > } >diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c >index 1c1e95a..6b70d7f 100644 >--- a/drivers/video/fbdev/vermilion/vermilion.c >+++ b/drivers/video/fbdev/vermilion/vermilion.c >@@ -99,7 +99,7 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order, > * below the first 16MB. > */ > >- flags = __GFP_DMA | __GFP_HIGH | __GFP_KSWAPD_RECLAIM; >+ flags = __GFP_DMA | __GFP_HIGH; > va->logical = > __get_free_pages(flags, --max_order); > } while (va->logical == 0 && max_order > min_order); >diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c >index 4b02591..d8174c7 100644 >--- a/fs/btrfs/disk-io.c >+++ b/fs/btrfs/disk-io.c >@@ -2617,7 +2617,7 @@ int open_ctree(struct super_block *sb, > fs_info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL; > fs_info->avg_delayed_ref_runtime = NSEC_PER_SEC >> 6; /* div by 64 */ > /* readahead state */ >- INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); >+ INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_WAIT); > spin_lock_init(&fs_info->reada_lock); > > fs_info->thread_pool_size = min_t(unsigned long, >diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c >index 76a0c85..6d0b2c1 100644 >--- a/fs/btrfs/extent_io.c >+++ b/fs/btrfs/extent_io.c >@@ -614,7 +614,7 @@ static int __clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, > if (bits & (EXTENT_IOBITS | EXTENT_BOUNDARY)) > clear = 1; > again: >- if (!prealloc && gfpflags_allow_blocking(mask)) { >+ if (!prealloc && (mask & __GFP_WAIT)) { > /* > * Don't care for allocation failure here because we might end > * up not needing the pre-allocated extent state at all, which >@@ -739,7 +739,7 @@ search_again: > if (start > end) > goto out; > spin_unlock(&tree->lock); >- if (gfpflags_allow_blocking(mask)) >+ if (mask & __GFP_WAIT) > cond_resched(); > goto again; > } >@@ -872,7 +872,7 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, > > bits |= EXTENT_FIRST_DELALLOC; > again: >- if (!prealloc && gfpflags_allow_blocking(mask)) { >+ if (!prealloc && (mask & __GFP_WAIT)) { > prealloc = alloc_extent_state(mask); > BUG_ON(!prealloc); > } >@@ -1050,7 +1050,7 @@ search_again: > if (start > end) > goto out; > spin_unlock(&tree->lock); >- if (gfpflags_allow_blocking(mask)) >+ if (mask & __GFP_WAIT) > cond_resched(); > goto again; > } >@@ -1098,7 +1098,7 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, > btrfs_debug_check_extent_io_range(tree, start, end); > > again: >- if (!prealloc && gfpflags_allow_blocking(mask)) { >+ if (!prealloc && (mask & __GFP_WAIT)) { > /* > * Best effort, don't worry if extent state allocation fails > * here for the first iteration. We might have a cached state >@@ -1276,7 +1276,7 @@ search_again: > if (start > end) > goto out; > spin_unlock(&tree->lock); >- if (gfpflags_allow_blocking(mask)) >+ if (mask & __GFP_WAIT) > cond_resched(); > first_iteration = false; > goto again; >@@ -4264,8 +4264,13 @@ int try_release_extent_mapping(struct extent_map_tree *map, > u64 start = page_offset(page); > u64 end = start + PAGE_CACHE_SIZE - 1; > >+<<<<<<< HEAD > if (gfpflags_allow_blocking(mask) && > page->mapping->host->i_size > SZ_16M) { >+======= >+ if ((mask & __GFP_WAIT) && >+ page->mapping->host->i_size > 16 * 1024 * 1024) { >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > u64 len; > while (start <= end) { > len = end - start + 1; >diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >index e2b54d5..3401b2a 100644 >--- a/fs/btrfs/volumes.c >+++ b/fs/btrfs/volumes.c >@@ -233,9 +233,14 @@ static struct btrfs_device *__alloc_device(void) > spin_lock_init(&dev->reada_lock); > atomic_set(&dev->reada_in_flight, 0); > atomic_set(&dev->dev_stats_ccnt, 0); >+<<<<<<< HEAD > btrfs_device_data_ordered_init(dev); > INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); > INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); >+======= >+ INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_WAIT); >+ INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_WAIT); >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > > return dev; > } >diff --git a/fs/ext4/super.c b/fs/ext4/super.c >index 5392975..1572eba 100644 >--- a/fs/ext4/super.c >+++ b/fs/ext4/super.c >@@ -1089,7 +1089,7 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page, > return 0; > if (journal) > return jbd2_journal_try_to_free_buffers(journal, page, >- wait & ~__GFP_DIRECT_RECLAIM); >+ wait & ~__GFP_WAIT); > return try_to_free_buffers(page); > } > >diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c >index 43040721..d403c69 100644 >--- a/fs/fscache/cookie.c >+++ b/fs/fscache/cookie.c >@@ -111,7 +111,7 @@ struct fscache_cookie *__fscache_acquire_cookie( > > /* radix tree insertion won't use the preallocation pool unless it's > * told it may not wait */ >- INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); >+ INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_WAIT); > > switch (cookie->def->type) { > case FSCACHE_COOKIE_TYPE_INDEX: >diff --git a/fs/fscache/page.c b/fs/fscache/page.c >index 6b35fc4..ca916af 100644 >--- a/fs/fscache/page.c >+++ b/fs/fscache/page.c >@@ -58,7 +58,7 @@ bool release_page_wait_timeout(struct fscache_cookie *cookie, struct page *page) > > /* > * decide whether a page can be released, possibly by cancelling a store to it >- * - we're allowed to sleep if __GFP_DIRECT_RECLAIM is flagged >+ * - we're allowed to sleep if __GFP_WAIT is flagged > */ > bool __fscache_maybe_release_page(struct fscache_cookie *cookie, > struct page *page, >@@ -122,7 +122,7 @@ page_busy: > * allocator as the work threads writing to the cache may all end up > * sleeping on memory allocation, so we may need to impose a timeout > * too. */ >- if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & __GFP_FS)) { >+ if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) { > fscache_stat(&fscache_n_store_vmscan_busy); > return false; > } >@@ -132,7 +132,7 @@ page_busy: > _debug("fscache writeout timeout page: %p{%lx}", > page, page->index); > >- gfp &= ~__GFP_DIRECT_RECLAIM; >+ gfp &= ~__GFP_WAIT; > goto try_again; > } > EXPORT_SYMBOL(__fscache_maybe_release_page); >diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c >index 01e4652d..9200203 100644 >--- a/fs/jbd2/transaction.c >+++ b/fs/jbd2/transaction.c >@@ -1927,8 +1927,8 @@ out: > * @journal: journal for operation > * @page: to try and free > * @gfp_mask: we use the mask to detect how hard should we try to release >- * buffers. If __GFP_DIRECT_RECLAIM and __GFP_FS is set, we wait for commit >- * code to release the buffers. >+ * buffers. If __GFP_WAIT and __GFP_FS is set, we wait for commit code to >+ * release the buffers. > * > * > * For all the buffers on this page, >diff --git a/fs/nfs/file.c b/fs/nfs/file.c >index 89bf093..66d6174 100644 >--- a/fs/nfs/file.c >+++ b/fs/nfs/file.c >@@ -475,8 +475,8 @@ static int nfs_release_page(struct page *page, gfp_t gfp) > dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page); > > /* Always try to initiate a 'commit' if relevant, but only >- * wait for it if the caller allows blocking. Even then, >- * only wait 1 second and only if the 'bdi' is not congested. >+ * wait for it if __GFP_WAIT is set. Even then, only wait 1 >+ * second and only if the 'bdi' is not congested. > * Waiting indefinitely can cause deadlocks when the NFS > * server is on this machine, when a new TCP connection is > * needed and in other rare cases. There is no particular >@@ -486,7 +486,7 @@ static int nfs_release_page(struct page *page, gfp_t gfp) > if (mapping) { > struct nfs_server *nfss = NFS_SERVER(mapping->host); > nfs_commit_inode(mapping->host, 0); >- if (gfpflags_allow_blocking(gfp) && >+ if ((gfp & __GFP_WAIT) && > !bdi_write_congested(&nfss->backing_dev_info)) { > wait_on_page_bit_killable_timeout(page, PG_private, > HZ); >diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c >index be125e1..6b86547 100644 >--- a/fs/xfs/xfs_qm.c >+++ b/fs/xfs/xfs_qm.c >@@ -525,7 +525,7 @@ xfs_qm_shrink_scan( > unsigned long freed; > int error; > >- if ((sc->gfp_mask & (__GFP_FS|__GFP_DIRECT_RECLAIM)) != (__GFP_FS|__GFP_DIRECT_RECLAIM)) >+ if ((sc->gfp_mask & (__GFP_FS|__GFP_WAIT)) != (__GFP_FS|__GFP_WAIT)) > return 0; > > INIT_LIST_HEAD(&isol.buffers); >diff --git a/include/linux/gfp.h b/include/linux/gfp.h >index 570383a..db03da6 100644 >--- a/include/linux/gfp.h >+++ b/include/linux/gfp.h >@@ -34,13 +34,17 @@ struct vm_area_struct; > #define ___GFP_NOMEMALLOC 0x10000u > #define ___GFP_HARDWALL 0x20000u > #define ___GFP_THISNODE 0x40000u >+<<<<<<< HEAD > #define ___GFP_ATOMIC 0x80000u > #define ___GFP_ACCOUNT 0x100000u >+======= >+#define ___GFP_WAIT 0x80000u >+#define ___GFP_NOACCOUNT 0x100000u >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > #define ___GFP_NOTRACK 0x200000u >-#define ___GFP_DIRECT_RECLAIM 0x400000u >+#define ___GFP_NO_KSWAPD 0x400000u > #define ___GFP_OTHER_NODE 0x800000u > #define ___GFP_WRITE 0x1000000u >-#define ___GFP_KSWAPD_RECLAIM 0x2000000u > /* If the above are modified, __GFP_BITS_SHIFT may need updating */ > > /* >@@ -81,6 +85,7 @@ struct vm_area_struct; > * __GFP_ACCOUNT causes the allocation to be accounted to kmemcg (only relevant > * to kmem allocations). > */ >+<<<<<<< HEAD > #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) > #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) > #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) >@@ -178,6 +183,38 @@ struct vm_area_struct; > * should not be accounted for as a remote allocation in vmstat. A > * typical user would be khugepaged collapsing a huge page on a remote > * node. >+======= >+#define __GFP_WAIT ((__force gfp_t)___GFP_WAIT) /* Can wait and reschedule? */ >+#define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) /* Should access emergency pools? */ >+#define __GFP_IO ((__force gfp_t)___GFP_IO) /* Can start physical IO? */ >+#define __GFP_FS ((__force gfp_t)___GFP_FS) /* Can call down to low-level FS? */ >+#define __GFP_COLD ((__force gfp_t)___GFP_COLD) /* Cache-cold page required */ >+#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) /* Suppress page allocation failure warning */ >+#define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */ >+#define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */ >+#define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */ >+#define __GFP_MEMALLOC ((__force gfp_t)___GFP_MEMALLOC)/* Allow access to emergency reserves */ >+#define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */ >+#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */ >+#define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves. >+ * This takes precedence over the >+ * __GFP_MEMALLOC flag if both are >+ * set >+ */ >+#define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */ >+#define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */ >+#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */ >+#define __GFP_NOACCOUNT ((__force gfp_t)___GFP_NOACCOUNT) /* Don't account to kmemcg */ >+#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */ >+ >+#define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD) >+#define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */ >+#define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */ >+ >+/* >+ * This may seem redundant, but it's a way of annotating false positives vs. >+ * allocations that simply cannot be supported (e.g. page tables). >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > */ > #define __GFP_COLD ((__force gfp_t)___GFP_COLD) > #define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) >@@ -187,6 +224,7 @@ struct vm_area_struct; > #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK) > #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) > >+<<<<<<< HEAD > /* Room for N __GFP_FOO bits */ > #define __GFP_BITS_SHIFT 26 > #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) >@@ -249,15 +287,35 @@ struct vm_area_struct; > #define GFP_NOIO (__GFP_RECLAIM) > #define GFP_NOFS (__GFP_RECLAIM | __GFP_IO) > #define GFP_TEMPORARY (__GFP_RECLAIM | __GFP_IO | __GFP_FS | \ >+======= >+#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */ >+#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) >+ >+/* This equals 0, but use constants in case they ever change */ >+#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH) >+/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ >+#define GFP_ATOMIC (__GFP_HIGH) >+#define GFP_NOIO (__GFP_WAIT) >+#define GFP_NOFS (__GFP_WAIT | __GFP_IO) >+#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) >+#define GFP_TEMPORARY (__GFP_WAIT | __GFP_IO | __GFP_FS | \ >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > __GFP_RECLAIMABLE) > #define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL) > #define GFP_DMA __GFP_DMA > #define GFP_DMA32 __GFP_DMA32 > #define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM) > #define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE) >+<<<<<<< HEAD > #define GFP_TRANSHUGE ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ > __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN) & \ > ~__GFP_RECLAIM) >+======= >+#define GFP_IOFS (__GFP_IO | __GFP_FS) >+#define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ >+ __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \ >+ __GFP_NO_KSWAPD) >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > > /* Convert GFP flags to their corresponding migrate type */ > #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE) >@@ -278,11 +336,14 @@ static inline int gfpflags_to_migratetype(const gfp_t gfp_flags) > #undef GFP_MOVABLE_MASK > #undef GFP_MOVABLE_SHIFT > >+<<<<<<< HEAD > static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) > { > return !!(gfp_flags & __GFP_DIRECT_RECLAIM); > } > >+======= >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > #ifdef CONFIG_HIGHMEM > #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM > #else >diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h >index 15d0df9..d918e5a 100644 >--- a/include/linux/skbuff.h >+++ b/include/linux/skbuff.h >@@ -1298,7 +1298,7 @@ static inline int skb_cloned(const struct sk_buff *skb) > > static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) > { >- might_sleep_if(gfpflags_allow_blocking(pri)); >+ might_sleep_if(pri & __GFP_WAIT); > > if (skb_cloned(skb)) > return pskb_expand_head(skb, 0, 0, pri); >@@ -1382,7 +1382,7 @@ static inline int skb_shared(const struct sk_buff *skb) > */ > static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri) > { >- might_sleep_if(gfpflags_allow_blocking(pri)); >+ might_sleep_if(pri & __GFP_WAIT); > if (skb_shared(skb)) { > struct sk_buff *nskb = skb_clone(skb, pri); > >@@ -1418,7 +1418,7 @@ static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri) > static inline struct sk_buff *skb_unshare(struct sk_buff *skb, > gfp_t pri) > { >- might_sleep_if(gfpflags_allow_blocking(pri)); >+ might_sleep_if(pri & __GFP_WAIT); > if (skb_cloned(skb)) { > struct sk_buff *nskb = skb_copy(skb, pri); > >diff --git a/include/net/sock.h b/include/net/sock.h >index 255d3e0..8bb8559 100644 >--- a/include/net/sock.h >+++ b/include/net/sock.h >@@ -1940,7 +1940,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, > */ > static inline struct page_frag *sk_page_frag(struct sock *sk) > { >- if (gfpflags_allow_blocking(sk->sk_allocation)) >+ if (sk->sk_allocation & __GFP_WAIT) > return ¤t->task_frag; > > return &sk->sk_frag; >diff --git a/include/trace/events/gfpflags.h b/include/trace/events/gfpflags.h >new file mode 100644 >index 0000000..d6fd8e5 >--- /dev/null >+++ b/include/trace/events/gfpflags.h >@@ -0,0 +1,42 @@ >+/* >+ * The order of these masks is important. Matching masks will be seen >+ * first and the left over flags will end up showing by themselves. >+ * >+ * For example, if we have GFP_KERNEL before GFP_USER we wil get: >+ * >+ * GFP_KERNEL|GFP_HARDWALL >+ * >+ * Thus most bits set go first. >+ */ >+#define show_gfp_flags(flags) \ >+ (flags) ? __print_flags(flags, "|", \ >+ {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ >+ {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"}, \ >+ {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ >+ {(unsigned long)GFP_USER, "GFP_USER"}, \ >+ {(unsigned long)GFP_TEMPORARY, "GFP_TEMPORARY"}, \ >+ {(unsigned long)GFP_KERNEL, "GFP_KERNEL"}, \ >+ {(unsigned long)GFP_NOFS, "GFP_NOFS"}, \ >+ {(unsigned long)GFP_ATOMIC, "GFP_ATOMIC"}, \ >+ {(unsigned long)GFP_NOIO, "GFP_NOIO"}, \ >+ {(unsigned long)__GFP_HIGH, "GFP_HIGH"}, \ >+ {(unsigned long)__GFP_WAIT, "GFP_WAIT"}, \ >+ {(unsigned long)__GFP_IO, "GFP_IO"}, \ >+ {(unsigned long)__GFP_COLD, "GFP_COLD"}, \ >+ {(unsigned long)__GFP_NOWARN, "GFP_NOWARN"}, \ >+ {(unsigned long)__GFP_REPEAT, "GFP_REPEAT"}, \ >+ {(unsigned long)__GFP_NOFAIL, "GFP_NOFAIL"}, \ >+ {(unsigned long)__GFP_NORETRY, "GFP_NORETRY"}, \ >+ {(unsigned long)__GFP_COMP, "GFP_COMP"}, \ >+ {(unsigned long)__GFP_ZERO, "GFP_ZERO"}, \ >+ {(unsigned long)__GFP_NOMEMALLOC, "GFP_NOMEMALLOC"}, \ >+ {(unsigned long)__GFP_MEMALLOC, "GFP_MEMALLOC"}, \ >+ {(unsigned long)__GFP_HARDWALL, "GFP_HARDWALL"}, \ >+ {(unsigned long)__GFP_THISNODE, "GFP_THISNODE"}, \ >+ {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \ >+ {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"}, \ >+ {(unsigned long)__GFP_NOTRACK, "GFP_NOTRACK"}, \ >+ {(unsigned long)__GFP_NO_KSWAPD, "GFP_NO_KSWAPD"}, \ >+ {(unsigned long)__GFP_OTHER_NODE, "GFP_OTHER_NODE"} \ >+ ) : "GFP_NOWAIT" >+ >diff --git a/kernel/audit.c b/kernel/audit.c >index 678c3f0..5eeabb6 100644 >--- a/kernel/audit.c >+++ b/kernel/audit.c >@@ -1385,16 +1385,22 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, > if (unlikely(audit_filter_type(type))) > return NULL; > >+<<<<<<< HEAD > if (gfp_mask & __GFP_DIRECT_RECLAIM) { > if (audit_pid && audit_pid == current->tgid) > gfp_mask &= ~__GFP_DIRECT_RECLAIM; >+======= >+ if (gfp_mask & __GFP_WAIT) { >+ if (audit_pid && audit_pid == current->pid) >+ gfp_mask &= ~__GFP_WAIT; >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > else > reserve = 0; > } > > while (audit_backlog_limit > && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) { >- if (gfp_mask & __GFP_DIRECT_RECLAIM && audit_backlog_wait_time) { >+ if (gfp_mask & __GFP_WAIT && audit_backlog_wait_time) { > long sleep_time; > > sleep_time = timeout_start + audit_backlog_wait_time - jiffies; >diff --git a/kernel/cgroup.c b/kernel/cgroup.c >index 671dc05..81b73e4 100644 >--- a/kernel/cgroup.c >+++ b/kernel/cgroup.c >@@ -335,7 +335,7 @@ static int cgroup_idr_alloc(struct idr *idr, void *ptr, int start, int end, > > idr_preload(gfp_mask); > spin_lock_bh(&cgroup_idr_lock); >- ret = idr_alloc(idr, ptr, start, end, gfp_mask & ~__GFP_DIRECT_RECLAIM); >+ ret = idr_alloc(idr, ptr, start, end, gfp_mask & ~__GFP_WAIT); > spin_unlock_bh(&cgroup_idr_lock); > idr_preload_end(); > return ret; >diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c >index 53ab2f8..3c6ee67 100644 >--- a/kernel/locking/lockdep.c >+++ b/kernel/locking/lockdep.c >@@ -2754,7 +2754,7 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags) > return; > > /* no reclaim without waiting on it */ >- if (!(gfp_mask & __GFP_DIRECT_RECLAIM)) >+ if (!(gfp_mask & __GFP_WAIT)) > return; > > /* this guy won't enter reclaim */ >diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c >index 3a97060..5235dd4 100644 >--- a/kernel/power/snapshot.c >+++ b/kernel/power/snapshot.c >@@ -1779,7 +1779,7 @@ alloc_highmem_pages(struct memory_bitmap *bm, unsigned int nr_highmem) > while (to_alloc-- > 0) { > struct page *page; > >- page = alloc_image_page(__GFP_HIGHMEM|__GFP_KSWAPD_RECLAIM); >+ page = alloc_image_page(__GFP_HIGHMEM); > memory_bm_set_bit(bm, page_to_pfn(page)); > } > return nr_highmem; >diff --git a/kernel/smp.c b/kernel/smp.c >index 7416544..3b1dbea 100644 >--- a/kernel/smp.c >+++ b/kernel/smp.c >@@ -669,7 +669,7 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info), > cpumask_var_t cpus; > int cpu, ret; > >- might_sleep_if(gfpflags_allow_blocking(gfp_flags)); >+ might_sleep_if(gfp_flags & __GFP_WAIT); > > if (likely(zalloc_cpumask_var(&cpus, (gfp_flags|__GFP_NOWARN)))) { > preempt_disable(); >diff --git a/lib/idr.c b/lib/idr.c >index 6098336..5335c43 100644 >--- a/lib/idr.c >+++ b/lib/idr.c >@@ -399,7 +399,7 @@ void idr_preload(gfp_t gfp_mask) > * allocation guarantee. Disallow usage from those contexts. > */ > WARN_ON_ONCE(in_interrupt()); >- might_sleep_if(gfpflags_allow_blocking(gfp_mask)); >+ might_sleep_if(gfp_mask & __GFP_WAIT); > > preempt_disable(); > >@@ -453,7 +453,7 @@ int idr_alloc(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask) > struct idr_layer *pa[MAX_IDR_LEVEL + 1]; > int id; > >- might_sleep_if(gfpflags_allow_blocking(gfp_mask)); >+ might_sleep_if(gfp_mask & __GFP_WAIT); > > /* sanity checks */ > if (WARN_ON_ONCE(start < 0)) >diff --git a/lib/radix-tree.c b/lib/radix-tree.c >index 1624c41..bbf6265 100644 >--- a/lib/radix-tree.c >+++ b/lib/radix-tree.c >@@ -223,7 +223,7 @@ radix_tree_node_alloc(struct radix_tree_root *root) > * preloading in the interrupt anyway as all the allocations have to > * be atomic. So just do normal allocation when in interrupt. > */ >- if (!gfpflags_allow_blocking(gfp_mask) && !in_interrupt()) { >+ if (!(gfp_mask & __GFP_WAIT) && !in_interrupt()) { > struct radix_tree_preload *rtp; > > /* >@@ -294,7 +294,7 @@ radix_tree_node_free(struct radix_tree_node *node) > * with preemption not disabled. > * > * To make use of this facility, the radix tree must be initialised without >- * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE(). >+ * __GFP_WAIT being passed to INIT_RADIX_TREE(). > */ > static int __radix_tree_preload(gfp_t gfp_mask) > { >@@ -331,12 +331,12 @@ out: > * with preemption not disabled. > * > * To make use of this facility, the radix tree must be initialised without >- * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE(). >+ * __GFP_WAIT being passed to INIT_RADIX_TREE(). > */ > int radix_tree_preload(gfp_t gfp_mask) > { > /* Warn on non-sensical use... */ >- WARN_ON_ONCE(!gfpflags_allow_blocking(gfp_mask)); >+ WARN_ON_ONCE(!(gfp_mask & __GFP_WAIT)); > return __radix_tree_preload(gfp_mask); > } > EXPORT_SYMBOL(radix_tree_preload); >@@ -348,7 +348,7 @@ EXPORT_SYMBOL(radix_tree_preload); > */ > int radix_tree_maybe_preload(gfp_t gfp_mask) > { >- if (gfpflags_allow_blocking(gfp_mask)) >+ if (gfp_mask & __GFP_WAIT) > return __radix_tree_preload(gfp_mask); > /* Preloading doesn't help anything with this gfp mask, skip it */ > preempt_disable(); >diff --git a/mm/backing-dev.c b/mm/backing-dev.c >index bfbd709..c095555 100644 >--- a/mm/backing-dev.c >+++ b/mm/backing-dev.c >@@ -637,7 +637,7 @@ struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi, > { > struct bdi_writeback *wb; > >- might_sleep_if(gfpflags_allow_blocking(gfp)); >+ might_sleep_if(gfp & __GFP_WAIT); > > if (!memcg_css->parent) > return &bdi->wb; >diff --git a/mm/dmapool.c b/mm/dmapool.c >index abcbfe8..b6bbba7 100644 >--- a/mm/dmapool.c >+++ b/mm/dmapool.c >@@ -325,7 +325,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, > size_t offset; > void *retval; > >- might_sleep_if(gfpflags_allow_blocking(mem_flags)); >+ might_sleep_if(mem_flags & __GFP_WAIT); > > spin_lock_irqsave(&pool->lock, flags); > list_for_each_entry(page, &pool->page_list, page_list) { >diff --git a/mm/memcontrol.c b/mm/memcontrol.c >index 36db05f..67b9681 100644 >--- a/mm/memcontrol.c >+++ b/mm/memcontrol.c >@@ -1973,7 +1973,7 @@ retry: > if (unlikely(task_in_memcg_oom(current))) > goto nomem; > >- if (!gfpflags_allow_blocking(gfp_mask)) >+ if (!(gfp_mask & __GFP_WAIT)) > goto nomem; > > mem_cgroup_events(mem_over_limit, MEMCG_MAX, 1); >@@ -4271,8 +4271,8 @@ static int mem_cgroup_do_precharge(unsigned long count) > { > int ret; > >- /* Try a single bulk charge without reclaim first, kswapd may wake */ >- ret = try_charge(mc.to, GFP_KERNEL & ~__GFP_DIRECT_RECLAIM, count); >+ /* Try a single bulk charge without reclaim first */ >+ ret = try_charge(mc.to, GFP_KERNEL & ~__GFP_WAIT, count); > if (!ret) { > mc.precharge += count; > return ret; >diff --git a/mm/mempool.c b/mm/mempool.c >index 07c383d..05ec074 100644 >--- a/mm/mempool.c >+++ b/mm/mempool.c >@@ -323,13 +323,17 @@ void *mempool_alloc(mempool_t *pool, gfp_t gfp_mask) > VM_WARN_ON_ONCE(gfp_mask & __GFP_NOMEMALLOC); > /* No element size to zero on allocation */ > VM_WARN_ON_ONCE(gfp_mask & __GFP_ZERO); >+<<<<<<< HEAD > > might_sleep_if(gfp_mask & __GFP_DIRECT_RECLAIM); >+======= >+ might_sleep_if(gfp_mask & __GFP_WAIT); >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > > gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */ > gfp_mask |= __GFP_NOWARN; /* failures are OK */ > >- gfp_temp = gfp_mask & ~(__GFP_DIRECT_RECLAIM|__GFP_IO); >+ gfp_temp = gfp_mask & ~(__GFP_WAIT|__GFP_IO); > > repeat_alloc: > if (likely(pool->curr_nr)) { >@@ -360,7 +364,7 @@ repeat_alloc: > } > > /* >- * We use gfp mask w/o direct reclaim or IO for the first round. If >+ * We use gfp mask w/o __GFP_WAIT or IO for the first round. If > * alloc failed with that and @pool was empty, retry immediately. > */ > if ((gfp_temp & ~__GFP_NOMEMALLOC) != gfp_mask) { >@@ -370,8 +374,8 @@ repeat_alloc: > } > gfp_temp = gfp_mask; > >- /* We must not sleep if !__GFP_DIRECT_RECLAIM */ >- if (!(gfp_mask & __GFP_DIRECT_RECLAIM)) { >+ /* We must not sleep if !__GFP_WAIT */ >+ if (!(gfp_mask & __GFP_WAIT)) { > spin_unlock_irqrestore(&pool->lock, flags); > return NULL; > } >diff --git a/mm/migrate.c b/mm/migrate.c >index 6c822a7..518375a 100644 >--- a/mm/migrate.c >+++ b/mm/migrate.c >@@ -1591,7 +1591,11 @@ static struct page *alloc_misplaced_dst_page(struct page *page, > (GFP_HIGHUSER_MOVABLE | > __GFP_THISNODE | __GFP_NOMEMALLOC | > __GFP_NORETRY | __GFP_NOWARN) & >+<<<<<<< HEAD > ~__GFP_RECLAIM, 0); >+======= >+ ~GFP_IOFS, 0); >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > > return newpage; > } >diff --git a/mm/page_alloc.c b/mm/page_alloc.c >index a762be5..d0c4f3f 100644 >--- a/mm/page_alloc.c >+++ b/mm/page_alloc.c >@@ -163,12 +163,12 @@ void pm_restrict_gfp_mask(void) > WARN_ON(!mutex_is_locked(&pm_mutex)); > WARN_ON(saved_gfp_mask); > saved_gfp_mask = gfp_allowed_mask; >- gfp_allowed_mask &= ~(__GFP_IO | __GFP_FS); >+ gfp_allowed_mask &= ~GFP_IOFS; > } > > bool pm_suspended_storage(void) > { >- if ((gfp_allowed_mask & (__GFP_IO | __GFP_FS)) == (__GFP_IO | __GFP_FS)) >+ if ((gfp_allowed_mask & GFP_IOFS) == GFP_IOFS) > return false; > return true; > } >@@ -2425,8 +2425,12 @@ static bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) > return false; > if (fail_page_alloc.ignore_gfp_highmem && (gfp_mask & __GFP_HIGHMEM)) > return false; >+<<<<<<< HEAD > if (fail_page_alloc.ignore_gfp_reclaim && > (gfp_mask & __GFP_DIRECT_RECLAIM)) >+======= >+ if (fail_page_alloc.ignore_gfp_wait && (gfp_mask & __GFP_WAIT)) >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > return false; > > return should_fail(&fail_page_alloc.attr, 1 << order); >@@ -2784,7 +2788,7 @@ void warn_alloc_failed(gfp_t gfp_mask, unsigned int order, const char *fmt, ...) > if (test_thread_flag(TIF_MEMDIE) || > (current->flags & (PF_MEMALLOC | PF_EXITING))) > filter &= ~SHOW_MEM_FILTER_NODES; >- if (in_interrupt() || !(gfp_mask & __GFP_DIRECT_RECLAIM)) >+ if (in_interrupt() || !(gfp_mask & __GFP_WAIT)) > filter &= ~SHOW_MEM_FILTER_NODES; > > if (fmt) { >@@ -3036,6 +3040,7 @@ static inline int > gfp_to_alloc_flags(gfp_t gfp_mask) > { > int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET; >+ const bool atomic = !(gfp_mask & (__GFP_WAIT | __GFP_NO_KSWAPD)); > > /* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */ > BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH); >@@ -3044,11 +3049,11 @@ gfp_to_alloc_flags(gfp_t gfp_mask) > * The caller may dip into page reserves a bit more if the caller > * cannot run direct reclaim, or if the caller has realtime scheduling > * policy or is asking for __GFP_HIGH memory. GFP_ATOMIC requests will >- * set both ALLOC_HARDER (__GFP_ATOMIC) and ALLOC_HIGH (__GFP_HIGH). >+ * set both ALLOC_HARDER (atomic == true) and ALLOC_HIGH (__GFP_HIGH). > */ > alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH); > >- if (gfp_mask & __GFP_ATOMIC) { >+ if (atomic) { > /* > * Not worth trying to allocate harder for __GFP_NOMEMALLOC even > * if it can't schedule. >@@ -3085,16 +3090,11 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) > return !!(gfp_to_alloc_flags(gfp_mask) & ALLOC_NO_WATERMARKS); > } > >-static inline bool is_thp_gfp_mask(gfp_t gfp_mask) >-{ >- return (gfp_mask & (GFP_TRANSHUGE | __GFP_KSWAPD_RECLAIM)) == GFP_TRANSHUGE; >-} >- > static inline struct page * > __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > struct alloc_context *ac) > { >- bool can_direct_reclaim = gfp_mask & __GFP_DIRECT_RECLAIM; >+ const gfp_t wait = gfp_mask & __GFP_WAIT; > struct page *page = NULL; > int alloc_flags; > unsigned long pages_reclaimed = 0; >@@ -3115,15 +3115,24 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > } > > /* >+<<<<<<< HEAD > * We also sanity check to catch abuse of atomic reserves being used by > * callers that are not in atomic context. > */ > if (WARN_ON_ONCE((gfp_mask & (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)) == > (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM))) > gfp_mask &= ~__GFP_ATOMIC; >+======= >+ * If this allocation cannot block and it is for a specific node, then >+ * fail early. There's no need to wakeup kswapd or retry for a >+ * speculative node-specific allocation. >+ */ >+ if (IS_ENABLED(CONFIG_NUMA) && (gfp_mask & __GFP_THISNODE) && !wait) >+ goto nopage; >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > > retry: >- if (gfp_mask & __GFP_KSWAPD_RECLAIM) >+ if (!(gfp_mask & __GFP_NO_KSWAPD)) > wake_all_kswapds(order, ac); > > /* >@@ -3164,8 +3173,8 @@ retry: > goto got_pg; > } > >- /* Caller is not willing to reclaim, we can't balance anything */ >- if (!can_direct_reclaim) { >+ /* Atomic allocations - we can't balance anything */ >+ if (!wait) { > /* > * All existing users of the __GFP_NOFAIL are blockable, so warn > * of any new users that actually allow this type of allocation >@@ -3205,7 +3214,7 @@ retry: > goto got_pg; > > /* Checks for THP-specific high-order allocations */ >- if (is_thp_gfp_mask(gfp_mask)) { >+ if ((gfp_mask & GFP_TRANSHUGE) == GFP_TRANSHUGE) { > /* > * If compaction is deferred for high-order allocations, it is > * because sync compaction recently failed. If this is the case >@@ -3240,7 +3249,8 @@ retry: > * fault, so use asynchronous memory compaction for THP unless it is > * khugepaged trying to collapse. > */ >- if (!is_thp_gfp_mask(gfp_mask) || (current->flags & PF_KTHREAD)) >+ if ((gfp_mask & GFP_TRANSHUGE) != GFP_TRANSHUGE || >+ (current->flags & PF_KTHREAD)) > migration_mode = MIGRATE_SYNC_LIGHT; > > /* Try direct reclaim and then allocating */ >@@ -3311,7 +3321,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, > > lockdep_trace_alloc(gfp_mask); > >- might_sleep_if(gfp_mask & __GFP_DIRECT_RECLAIM); >+ might_sleep_if(gfp_mask & __GFP_WAIT); > > if (should_fail_alloc_page(gfp_mask, order)) > return NULL; >diff --git a/mm/slab.c b/mm/slab.c >index e719a5c..510eef3 100644 >--- a/mm/slab.c >+++ b/mm/slab.c >@@ -841,12 +841,21 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp) > } > > /* >+<<<<<<< HEAD > * Construct gfp mask to allocate from a specific node but do not reclaim or > * warn about failures. > */ > static inline gfp_t gfp_exact_node(gfp_t flags) > { > return (flags | __GFP_THISNODE | __GFP_NOWARN) & ~(__GFP_RECLAIM|__GFP_NOFAIL); >+======= >+ * Construct gfp mask to allocate from a specific node but do not invoke reclaim >+ * or warn about failures. >+ */ >+static inline gfp_t gfp_exact_node(gfp_t flags) >+{ >+ return (flags | __GFP_THISNODE | __GFP_NOWARN) & ~__GFP_WAIT; >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > } > #endif > >@@ -2522,7 +2531,7 @@ static int cache_grow(struct kmem_cache *cachep, > > offset *= cachep->colour_off; > >- if (gfpflags_allow_blocking(local_flags)) >+ if (local_flags & __GFP_WAIT) > local_irq_enable(); > > /* >@@ -2552,7 +2561,7 @@ static int cache_grow(struct kmem_cache *cachep, > > cache_init_objs(cachep, page); > >- if (gfpflags_allow_blocking(local_flags)) >+ if (local_flags & __GFP_WAIT) > local_irq_disable(); > check_irq_off(); > spin_lock(&n->list_lock); >@@ -2566,7 +2575,7 @@ static int cache_grow(struct kmem_cache *cachep, > opps1: > kmem_freepages(cachep, page); > failed: >- if (gfpflags_allow_blocking(local_flags)) >+ if (local_flags & __GFP_WAIT) > local_irq_disable(); > return 0; > } >@@ -2870,7 +2879,7 @@ alloc_done: > static inline void cache_alloc_debugcheck_before(struct kmem_cache *cachep, > gfp_t flags) > { >- might_sleep_if(gfpflags_allow_blocking(flags)); >+ might_sleep_if(flags & __GFP_WAIT); > #if DEBUG > kmem_flagcheck(cachep, flags); > #endif >@@ -3029,11 +3038,11 @@ retry: > */ > struct page *page; > >- if (gfpflags_allow_blocking(local_flags)) >+ if (local_flags & __GFP_WAIT) > local_irq_enable(); > kmem_flagcheck(cache, flags); > page = kmem_getpages(cache, local_flags, numa_mem_id()); >- if (gfpflags_allow_blocking(local_flags)) >+ if (local_flags & __GFP_WAIT) > local_irq_disable(); > if (page) { > /* >diff --git a/mm/slub.c b/mm/slub.c >index 7277413..f36cad7 100644 >--- a/mm/slub.c >+++ b/mm/slub.c >@@ -1322,6 +1322,32 @@ static inline void kfree_hook(const void *x) > kasan_kfree_large(x); > } > >+<<<<<<< HEAD >+======= >+static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s, >+ gfp_t flags) >+{ >+ flags &= gfp_allowed_mask; >+ lockdep_trace_alloc(flags); >+ might_sleep_if(flags & __GFP_WAIT); >+ >+ if (should_failslab(s->object_size, flags, s->flags)) >+ return NULL; >+ >+ return memcg_kmem_get_cache(s, flags); >+} >+ >+static inline void slab_post_alloc_hook(struct kmem_cache *s, >+ gfp_t flags, void *object) >+{ >+ flags &= gfp_allowed_mask; >+ kmemcheck_slab_alloc(s, flags, object, slab_ksize(s)); >+ kmemleak_alloc_recursive(object, s->object_size, 1, s->flags, flags); >+ memcg_kmem_put_cache(s); >+ kasan_slab_alloc(s, object); >+} >+ >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > static inline void slab_free_hook(struct kmem_cache *s, void *x) > { > kmemleak_free_recursive(x, s->flags); >@@ -1415,7 +1441,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) > > flags &= gfp_allowed_mask; > >- if (gfpflags_allow_blocking(flags)) >+ if (flags & __GFP_WAIT) > local_irq_enable(); > > flags |= s->allocflags; >@@ -1425,8 +1451,13 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) > * so we fall-back to the minimum order allocation. > */ > alloc_gfp = (flags | __GFP_NOWARN | __GFP_NORETRY) & ~__GFP_NOFAIL; >+<<<<<<< HEAD > if ((alloc_gfp & __GFP_DIRECT_RECLAIM) && oo_order(oo) > oo_order(s->min)) > alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~(__GFP_RECLAIM|__GFP_NOFAIL); >+======= >+ if ((alloc_gfp & __GFP_WAIT) && oo_order(oo) > oo_order(s->min)) >+ alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~__GFP_WAIT; >+>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd > > page = alloc_slab_page(s, alloc_gfp, node, oo); > if (unlikely(!page)) { >@@ -1486,7 +1517,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) > page->frozen = 1; > > out: >- if (gfpflags_allow_blocking(flags)) >+ if (flags & __GFP_WAIT) > local_irq_disable(); > if (!page) > return NULL; >diff --git a/mm/vmalloc.c b/mm/vmalloc.c >index ae7d20b..f3e6be8 100644 >--- a/mm/vmalloc.c >+++ b/mm/vmalloc.c >@@ -1612,7 +1612,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, > goto fail; > } > area->pages[i] = page; >- if (gfpflags_allow_blocking(gfp_mask)) >+ if (gfp_mask & __GFP_WAIT) > cond_resched(); > } > >diff --git a/mm/vmscan.c b/mm/vmscan.c >index b934223e..70b0b7a 100644 >--- a/mm/vmscan.c >+++ b/mm/vmscan.c >@@ -1486,7 +1486,7 @@ static int too_many_isolated(struct zone *zone, int file, > * won't get blocked by normal direct-reclaimers, forming a circular > * deadlock. > */ >- if ((sc->gfp_mask & (__GFP_IO | __GFP_FS)) == (__GFP_IO | __GFP_FS)) >+ if ((sc->gfp_mask & GFP_IOFS) == GFP_IOFS) > inactive >>= 3; > > return isolated > inactive; >@@ -3756,7 +3756,7 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) > /* > * Do not scan if the allocation should not be delayed. > */ >- if (!gfpflags_allow_blocking(gfp_mask) || (current->flags & PF_MEMALLOC)) >+ if (!(gfp_mask & __GFP_WAIT) || (current->flags & PF_MEMALLOC)) > return ZONE_RECLAIM_NOSCAN; > > /* >diff --git a/mm/zswap.c b/mm/zswap.c >index bf14508..b07e7e1 100644 >--- a/mm/zswap.c >+++ b/mm/zswap.c >@@ -565,7 +565,7 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) > static struct zswap_pool *zswap_pool_create(char *type, char *compressor) > { > struct zswap_pool *pool; >- gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM; >+ gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; > > pool = kzalloc(sizeof(*pool), GFP_KERNEL); > if (!pool) { >@@ -1011,8 +1011,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, > /* store */ > len = dlen + sizeof(struct zswap_header); > ret = zpool_malloc(entry->pool->zpool, len, >- __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM, >- &handle); >+ __GFP_NORETRY | __GFP_NOWARN, &handle); > if (ret == -ENOSPC) { > zswap_reject_compress_poor++; > goto put_dstmem; >diff --git a/net/core/skbuff.c b/net/core/skbuff.c >index d04c2d1..eb6e79a 100644 >--- a/net/core/skbuff.c >+++ b/net/core/skbuff.c >@@ -424,7 +424,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, > len += NET_SKB_PAD; > > if ((len > SKB_WITH_OVERHEAD(PAGE_SIZE)) || >- (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { >+ (gfp_mask & (__GFP_WAIT | GFP_DMA))) { > skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); > if (!skb) > goto skb_fail; >@@ -491,7 +491,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len, > len += NET_SKB_PAD + NET_IP_ALIGN; > > if ((len > SKB_WITH_OVERHEAD(PAGE_SIZE)) || >- (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { >+ (gfp_mask & (__GFP_WAIT | GFP_DMA))) { > skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); > if (!skb) > goto skb_fail; >@@ -4547,7 +4547,7 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, > return NULL; > > gfp_head = gfp_mask; >- if (gfp_head & __GFP_DIRECT_RECLAIM) >+ if (gfp_head & __GFP_WAIT) > gfp_head |= __GFP_REPEAT; > > *errcode = -ENOBUFS; >@@ -4562,7 +4562,7 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, > > while (order) { > if (npages >= 1 << order) { >- page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) | >+ page = alloc_pages((gfp_mask & ~__GFP_WAIT) | > __GFP_COMP | > __GFP_NOWARN | > __GFP_NORETRY, >diff --git a/net/core/sock.c b/net/core/sock.c >index b67b9ae..c7a70c1 100644 >--- a/net/core/sock.c >+++ b/net/core/sock.c >@@ -1919,10 +1919,8 @@ bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t gfp) > > pfrag->offset = 0; > if (SKB_FRAG_PAGE_ORDER) { >- /* Avoid direct reclaim but allow kswapd to wake */ >- pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) | >- __GFP_COMP | __GFP_NOWARN | >- __GFP_NORETRY, >+ pfrag->page = alloc_pages((gfp & ~__GFP_WAIT) | __GFP_COMP | >+ __GFP_NOWARN | __GFP_NORETRY, > SKB_FRAG_PAGE_ORDER); > if (likely(pfrag->page)) { > pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER; >diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c >index 215fc08..16f5a3d 100644 >--- a/net/netlink/af_netlink.c >+++ b/net/netlink/af_netlink.c >@@ -1423,7 +1423,7 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid > consume_skb(info.skb2); > > if (info.delivered) { >- if (info.congested && gfpflags_allow_blocking(allocation)) >+ if (info.congested && (allocation & __GFP_WAIT)) > yield(); > return 0; > } >diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c >index 977fb86..96744b7 100644 >--- a/net/rds/ib_recv.c >+++ b/net/rds/ib_recv.c >@@ -305,7 +305,7 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn, > gfp_t slab_mask = GFP_NOWAIT; > gfp_t page_mask = GFP_NOWAIT; > >- if (gfp & __GFP_DIRECT_RECLAIM) { >+ if (gfp & __GFP_WAIT) { > slab_mask = GFP_KERNEL; > page_mask = GFP_HIGHUSER; > } >@@ -379,7 +379,7 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp) > struct ib_recv_wr *failed_wr; > unsigned int posted = 0; > int ret = 0; >- bool can_wait = !!(gfp & __GFP_DIRECT_RECLAIM); >+ bool can_wait = !!(gfp & __GFP_WAIT); > u32 pos; > > /* the goal here is to just make sure that someone, somewhere >diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c >index 9942da1..3b999c7 100644 >--- a/net/rxrpc/ar-connection.c >+++ b/net/rxrpc/ar-connection.c >@@ -499,7 +499,7 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, > if (bundle->num_conns >= 20) { > _debug("too many conns"); > >- if (!gfpflags_allow_blocking(gfp)) { >+ if (!(gfp & __GFP_WAIT)) { > _leave(" = -EAGAIN"); > return -EAGAIN; > } >diff --git a/net/sctp/associola.c b/net/sctp/associola.c >index e1849f3..f5f1ad2 100644 >--- a/net/sctp/associola.c >+++ b/net/sctp/associola.c >@@ -1596,7 +1596,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc, > /* Set an association id for a given association */ > int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp) > { >- bool preload = gfpflags_allow_blocking(gfp); >+ bool preload = !!(gfp & __GFP_WAIT); > int ret; > > /* If the id is already assigned, keep it. */ >-- >2.5.0 >
From b90ce55428794aa1091fc6647b24a4a13cb46324 Mon Sep 17 00:00:00 2001 From: Nicholas Krause <xerofoify@gmail.com> Date: Thu, 24 Mar 2016 10:40:04 -0400 Subject: [PATCH] Revert "mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd" This reverts commit d0164adc89f6bb374d304ffcc375c6d2652fe67d. Signed-off-by: Nicholas Krause <xerofoify@gmail.com> --- Documentation/vm/balance | 14 ++--- arch/arm/mm/dma-mapping.c | 17 +++++- arch/arm/xen/mm.c | 2 +- arch/arm64/mm/dma-mapping.c | 4 +- arch/x86/kernel/pci-dma.c | 2 +- block/bio.c | 26 ++++----- block/blk-core.c | 16 +++--- block/blk-ioc.c | 2 +- block/blk-mq-tag.c | 4 ++ block/blk-mq.c | 13 +++++ drivers/block/drbd/drbd_receiver.c | 3 +- drivers/block/osdblk.c | 2 +- drivers/connector/connector.c | 3 +- drivers/firewire/core-cdev.c | 2 +- drivers/gpu/drm/i915/i915_gem.c | 6 ++ drivers/infiniband/core/sa_query.c | 2 +- drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/intel-iommu.c | 2 +- drivers/md/dm-crypt.c | 6 +- drivers/md/dm-kcopyd.c | 2 +- drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 2 +- drivers/media/pci/solo6x10/solo6x10-v4l2.c | 2 +- drivers/media/pci/tw68/tw68-video.c | 2 +- drivers/mtd/mtdcore.c | 3 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/staging/android/ion/ion_system_heap.c | 4 ++ .../lustre/include/linux/libcfs/libcfs_private.h | 2 +- drivers/usb/host/u132-hcd.c | 2 +- drivers/video/fbdev/vermilion/vermilion.c | 2 +- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_io.c | 17 ++++-- fs/btrfs/volumes.c | 5 ++ fs/ext4/super.c | 2 +- fs/fscache/cookie.c | 2 +- fs/fscache/page.c | 6 +- fs/jbd2/transaction.c | 4 +- fs/nfs/file.c | 6 +- fs/xfs/xfs_qm.c | 2 +- include/linux/gfp.h | 65 +++++++++++++++++++++- include/linux/skbuff.h | 6 +- include/net/sock.h | 2 +- include/trace/events/gfpflags.h | 42 ++++++++++++++ kernel/audit.c | 8 ++- kernel/cgroup.c | 2 +- kernel/locking/lockdep.c | 2 +- kernel/power/snapshot.c | 2 +- kernel/smp.c | 2 +- lib/idr.c | 4 +- lib/radix-tree.c | 10 ++-- mm/backing-dev.c | 2 +- mm/dmapool.c | 2 +- mm/memcontrol.c | 6 +- mm/mempool.c | 12 ++-- mm/migrate.c | 4 ++ mm/page_alloc.c | 44 +++++++++------ mm/slab.c | 21 +++++-- mm/slub.c | 35 +++++++++++- mm/vmalloc.c | 2 +- mm/vmscan.c | 4 +- mm/zswap.c | 5 +- net/core/skbuff.c | 8 +-- net/core/sock.c | 6 +- net/netlink/af_netlink.c | 2 +- net/rds/ib_recv.c | 4 +- net/rxrpc/ar-connection.c | 2 +- net/sctp/associola.c | 2 +- 66 files changed, 358 insertions(+), 145 deletions(-) create mode 100644 include/trace/events/gfpflags.h diff --git a/Documentation/vm/balance b/Documentation/vm/balance index 9645954..c46e68c 100644 --- a/Documentation/vm/balance +++ b/Documentation/vm/balance @@ -1,14 +1,12 @@ Started Jan 2000 by Kanoj Sarcar <kanoj@sgi.com> -Memory balancing is needed for !__GFP_ATOMIC and !__GFP_KSWAPD_RECLAIM as -well as for non __GFP_IO allocations. +Memory balancing is needed for non __GFP_WAIT as well as for non +__GFP_IO allocations. -The first reason why a caller may avoid reclaim is that the caller can not -sleep due to holding a spinlock or is in interrupt context. The second may -be that the caller is willing to fail the allocation without incurring the -overhead of page reclaim. This may happen for opportunistic high-order -allocation requests that have order-0 fallback options. In such cases, -the caller may also wish to avoid waking kswapd. +There are two reasons to be requesting non __GFP_WAIT allocations: +the caller can not sleep (typically intr context), or does not want +to incur cost overheads of page stealing and possible swap io for +whatever reasons. __GFP_IO allocation requests are made to prevent file system deadlocks. diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index deac58d..cb383bc 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -780,6 +780,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, args.gfp = gfp; *handle = DMA_ERROR_CODE; +<<<<<<< HEAD allowblock = gfpflags_allow_blocking(gfp); cma = allowblock ? dev_get_cma_area(dev) : false; @@ -789,6 +790,20 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, buf->allocator = &simple_allocator; else if (allowblock) buf->allocator = &remap_allocator; +======= + size = PAGE_ALIGN(size); + want_vaddr = !dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs); + + if (nommu()) + addr = __alloc_simple_buffer(dev, size, gfp, &page); + else if (dev_get_cma_area(dev) && (gfp & __GFP_WAIT)) + addr = __alloc_from_contiguous(dev, size, prot, &page, + caller, want_vaddr); + else if (is_coherent) + addr = __alloc_simple_buffer(dev, size, gfp, &page); + else if (!(gfp & __GFP_WAIT)) + addr = __alloc_from_pool(size, &page); +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd else buf->allocator = &pool_allocator; @@ -1504,7 +1519,7 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, *handle = DMA_ERROR_CODE; size = PAGE_ALIGN(size); - if (!gfpflags_allow_blocking(gfp)) + if (!(gfp & __GFP_WAIT)) return __iommu_alloc_atomic(dev, size, handle); /* diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c index c5f9a9e..7c34f71 100644 --- a/arch/arm/xen/mm.c +++ b/arch/arm/xen/mm.c @@ -25,7 +25,7 @@ unsigned long xen_get_swiotlb_free_pages(unsigned int order) { struct memblock_region *reg; - gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM; + gfp_t flags = __GFP_NOWARN; for_each_memblock(memory, reg) { if (reg->base < (phys_addr_t)0xffffffff) { diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index a6e757c..cda61b2 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -98,7 +98,7 @@ static void *__dma_alloc_coherent(struct device *dev, size_t size, if (IS_ENABLED(CONFIG_ZONE_DMA) && dev->coherent_dma_mask <= DMA_BIT_MASK(32)) flags |= GFP_DMA; - if (dev_get_cma_area(dev) && gfpflags_allow_blocking(flags)) { + if (dev_get_cma_area(dev) && (flags & __GFP_WAIT)) { struct page *page; void *addr; @@ -146,7 +146,7 @@ static void *__dma_alloc(struct device *dev, size_t size, size = PAGE_ALIGN(size); - if (!coherent && !gfpflags_allow_blocking(flags)) { + if (!coherent && !(flags & __GFP_WAIT)) { struct page *page = NULL; void *addr = __alloc_from_pool(size, &page, flags); diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 6ba014c..cd99433 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -90,7 +90,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size, again: page = NULL; /* CMA can be used only in the context which permits sleeping */ - if (gfpflags_allow_blocking(flag)) { + if (flag & __GFP_WAIT) { page = dma_alloc_from_contiguous(dev, count, get_order(size)); if (page && page_to_phys(page) + size > dma_mask) { dma_release_from_contiguous(dev, page, count); diff --git a/block/bio.c b/block/bio.c index f124a0a..d838137 100644 --- a/block/bio.c +++ b/block/bio.c @@ -211,7 +211,7 @@ fallback: bvl = mempool_alloc(pool, gfp_mask); } else { struct biovec_slab *bvs = bvec_slabs + *idx; - gfp_t __gfp_mask = gfp_mask & ~(__GFP_DIRECT_RECLAIM | __GFP_IO); + gfp_t __gfp_mask = gfp_mask & ~(__GFP_WAIT | __GFP_IO); /* * Make this allocation restricted and don't dump info on @@ -221,11 +221,11 @@ fallback: __gfp_mask |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN; /* - * Try a slab allocation. If this fails and __GFP_DIRECT_RECLAIM + * Try a slab allocation. If this fails and __GFP_WAIT * is set, retry with the 1-entry mempool */ bvl = kmem_cache_alloc(bvs->slab, __gfp_mask); - if (unlikely(!bvl && (gfp_mask & __GFP_DIRECT_RECLAIM))) { + if (unlikely(!bvl && (gfp_mask & __GFP_WAIT))) { *idx = BIOVEC_MAX_IDX; goto fallback; } @@ -401,12 +401,12 @@ static void punt_bios_to_rescuer(struct bio_set *bs) * If @bs is NULL, uses kmalloc() to allocate the bio; else the allocation is * backed by the @bs's mempool. * - * When @bs is not NULL, if %__GFP_DIRECT_RECLAIM is set then bio_alloc will - * always be able to allocate a bio. This is due to the mempool guarantees. - * To make this work, callers must never allocate more than 1 bio at a time - * from this pool. Callers that need to allocate more than 1 bio must always - * submit the previously allocated bio for IO before attempting to allocate - * a new one. Failure to do so can cause deadlocks under memory pressure. + * When @bs is not NULL, if %__GFP_WAIT is set then bio_alloc will always be + * able to allocate a bio. This is due to the mempool guarantees. To make this + * work, callers must never allocate more than 1 bio at a time from this pool. + * Callers that need to allocate more than 1 bio must always submit the + * previously allocated bio for IO before attempting to allocate a new one. + * Failure to do so can cause deadlocks under memory pressure. * * Note that when running under generic_make_request() (i.e. any block * driver), bios are not submitted until after you return - see the code in @@ -465,13 +465,13 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs) * We solve this, and guarantee forward progress, with a rescuer * workqueue per bio_set. If we go to allocate and there are * bios on current->bio_list, we first try the allocation - * without __GFP_DIRECT_RECLAIM; if that fails, we punt those - * bios we would be blocking to the rescuer workqueue before - * we retry with the original gfp_flags. + * without __GFP_WAIT; if that fails, we punt those bios we + * would be blocking to the rescuer workqueue before we retry + * with the original gfp_flags. */ if (current->bio_list && !bio_list_empty(current->bio_list)) - gfp_mask &= ~__GFP_DIRECT_RECLAIM; + gfp_mask &= ~__GFP_WAIT; p = mempool_alloc(bs->bio_pool, gfp_mask); if (!p && gfp_mask != saved_gfp) { diff --git a/block/blk-core.c b/block/blk-core.c index 827f8ba..12a81a9 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1230,8 +1230,8 @@ rq_starved: * @bio: bio to allocate request for (can be %NULL) * @gfp_mask: allocation mask * - * Get a free request from @q. If %__GFP_DIRECT_RECLAIM is set in @gfp_mask, - * this function keeps retrying under memory pressure and fails iff @q is dead. + * Get a free request from @q. If %__GFP_WAIT is set in @gfp_mask, this + * function keeps retrying under memory pressure and fails iff @q is dead. * * Must be called with @q->queue_lock held and, * Returns ERR_PTR on failure, with @q->queue_lock held. @@ -1251,7 +1251,7 @@ retry: if (!IS_ERR(rq)) return rq; - if (!gfpflags_allow_blocking(gfp_mask) || unlikely(blk_queue_dying(q))) { + if (!(gfp_mask & __GFP_WAIT) || unlikely(blk_queue_dying(q))) { blk_put_rl(rl); return rq; } @@ -1331,11 +1331,11 @@ EXPORT_SYMBOL(blk_get_request); * BUG. * * WARNING: When allocating/cloning a bio-chain, careful consideration should be - * given to how you allocate bios. In particular, you cannot use - * __GFP_DIRECT_RECLAIM for anything but the first bio in the chain. Otherwise - * you risk waiting for IO completion of a bio that hasn't been submitted yet, - * thus resulting in a deadlock. Alternatively bios should be allocated using - * bio_kmalloc() instead of bio_alloc(), as that avoids the mempool deadlock. + * given to how you allocate bios. In particular, you cannot use __GFP_WAIT for + * anything but the first bio in the chain. Otherwise you risk waiting for IO + * completion of a bio that hasn't been submitted yet, thus resulting in a + * deadlock. Alternatively bios should be allocated using bio_kmalloc() instead + * of bio_alloc(), as that avoids the mempool deadlock. * If possible a big IO should be split into smaller parts when allocation * fails. Partial allocation should not be an error, or you risk a live-lock. */ diff --git a/block/blk-ioc.c b/block/blk-ioc.c index 381cb50..1a27f45 100644 --- a/block/blk-ioc.c +++ b/block/blk-ioc.c @@ -289,7 +289,7 @@ struct io_context *get_task_io_context(struct task_struct *task, { struct io_context *ioc; - might_sleep_if(gfpflags_allow_blocking(gfp_flags)); + might_sleep_if(gfp_flags & __GFP_WAIT); do { task_lock(task); diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index abdbb47..308f0a6 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -268,7 +268,11 @@ static int bt_get(struct blk_mq_alloc_data *data, if (tag != -1) return tag; +<<<<<<< HEAD if (data->flags & BLK_MQ_REQ_NOWAIT) +======= + if (!(data->gfp & __GFP_WAIT)) +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd return -1; bs = bt_wait_ptr(bt, hctx); diff --git a/block/blk-mq.c b/block/blk-mq.c index 050f7a1..0256f1c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -244,10 +244,18 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, ctx = blk_mq_get_ctx(q); hctx = q->mq_ops->map_queue(q, ctx->cpu); +<<<<<<< HEAD blk_mq_set_alloc_data(&alloc_data, q, flags, ctx, hctx); rq = __blk_mq_alloc_request(&alloc_data, rw); if (!rq && !(flags & BLK_MQ_REQ_NOWAIT)) { +======= + blk_mq_set_alloc_data(&alloc_data, q, gfp & ~__GFP_WAIT, + reserved, ctx, hctx); + + rq = __blk_mq_alloc_request(&alloc_data, rw); + if (!rq && (gfp & __GFP_WAIT)) { +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd __blk_mq_run_hw_queue(hctx); blk_mq_put_ctx(ctx); @@ -1190,7 +1198,12 @@ static struct request *blk_mq_map_request(struct request_queue *q, ctx = blk_mq_get_ctx(q); hctx = q->mq_ops->map_queue(q, ctx->cpu); +<<<<<<< HEAD blk_mq_set_alloc_data(&alloc_data, q, 0, ctx, hctx); +======= + blk_mq_set_alloc_data(&alloc_data, q, + __GFP_WAIT|GFP_ATOMIC, false, ctx, hctx); +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd rq = __blk_mq_alloc_request(&alloc_data, rw); ctx = alloc_data.ctx; hctx = alloc_data.hctx; diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 050aaa1..1cf4082 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -381,8 +381,7 @@ drbd_alloc_peer_req(struct drbd_peer_device *peer_device, u64 id, sector_t secto } if (has_payload && data_size) { - page = drbd_alloc_pages(peer_device, nr_pages, - gfpflags_allow_blocking(gfp_mask)); + page = drbd_alloc_pages(peer_device, nr_pages, (gfp_mask & __GFP_WAIT)); if (!page) goto fail; } diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c index 1b709a4..e229425 100644 --- a/drivers/block/osdblk.c +++ b/drivers/block/osdblk.c @@ -271,7 +271,7 @@ static struct bio *bio_chain_clone(struct bio *old_chain, gfp_t gfpmask) goto err_out; tmp->bi_bdev = NULL; - gfpmask &= ~__GFP_DIRECT_RECLAIM; + gfpmask &= ~__GFP_WAIT; tmp->bi_next = NULL; if (!new_chain) diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index 25693b0..c19e7fc 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c @@ -124,8 +124,7 @@ int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group, if (group) return netlink_broadcast(dev->nls, skb, portid, group, gfp_mask); - return netlink_unicast(dev->nls, skb, portid, - !gfpflags_allow_blocking(gfp_mask)); + return netlink_unicast(dev->nls, skb, portid, !(gfp_mask&__GFP_WAIT)); } EXPORT_SYMBOL_GPL(cn_netlink_send_mult); diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index aee149b..0814824 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -486,7 +486,7 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg) static int add_client_resource(struct client *client, struct client_resource *resource, gfp_t gfp_mask) { - bool preload = gfpflags_allow_blocking(gfp_mask); + bool preload = !!(gfp_mask & __GFP_WAIT); unsigned long flags; int ret; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 3d31d3a..7ed9551 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2277,8 +2277,14 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) * Fail silently without starting the shrinker */ mapping = file_inode(obj->base.filp)->i_mapping; +<<<<<<< HEAD gfp = mapping_gfp_constraint(mapping, ~(__GFP_IO | __GFP_RECLAIM)); gfp |= __GFP_NORETRY | __GFP_NOWARN; +======= + gfp = mapping_gfp_mask(mapping); + gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD; + gfp &= ~(__GFP_IO | __GFP_WAIT); +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd sg = st->sgl; st->nents = 0; for (i = 0; i < page_count; i++) { diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 8a09c0f..febd9cf 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c @@ -1155,7 +1155,7 @@ static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask) { - bool preload = gfpflags_allow_blocking(gfp_mask); + bool preload = !!(gfp_mask & __GFP_WAIT); unsigned long flags; int ret, id; diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 374c129..7942637 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2758,7 +2758,7 @@ static void *alloc_coherent(struct device *dev, size_t size, page = alloc_pages(flag | __GFP_NOWARN, get_order(size)); if (!page) { - if (!gfpflags_allow_blocking(flag)) + if (!(flag & __GFP_WAIT)) return NULL; page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a2e1b7f..037ec54 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3647,7 +3647,7 @@ static void *intel_alloc_coherent(struct device *dev, size_t size, flags |= GFP_DMA32; } - if (gfpflags_allow_blocking(flags)) { + if (flags & __GFP_WAIT) { unsigned int count = size >> PAGE_SHIFT; page = dma_alloc_from_contiguous(dev, count, order); diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 4f3cb35..cde6ec4 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -998,7 +998,7 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) struct bio_vec *bvec; retry: - if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM)) + if (unlikely(gfp_mask & __GFP_WAIT)) mutex_lock(&cc->bio_alloc_lock); clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); @@ -1014,7 +1014,7 @@ retry: if (!page) { crypt_free_buffer_pages(cc, clone); bio_put(clone); - gfp_mask |= __GFP_DIRECT_RECLAIM; + gfp_mask |= __GFP_WAIT; goto retry; } @@ -1031,7 +1031,7 @@ retry: } return_clone: - if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM)) + if (unlikely(gfp_mask & __GFP_WAIT)) mutex_unlock(&cc->bio_alloc_lock); return clone; diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c index 1452ed9..3a7cade 100644 --- a/drivers/md/dm-kcopyd.c +++ b/drivers/md/dm-kcopyd.c @@ -244,7 +244,7 @@ static int kcopyd_get_pages(struct dm_kcopyd_client *kc, *pages = NULL; do { - pl = alloc_pl(__GFP_NOWARN | __GFP_NORETRY | __GFP_KSWAPD_RECLAIM); + pl = alloc_pl(__GFP_NOWARN | __GFP_NORETRY); if (unlikely(!pl)) { /* Use reserved pages */ pl = kc->pages; diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c index 67a14c4..eedafc5 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c @@ -1295,7 +1295,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, solo_enc->vidq.ops = &solo_enc_video_qops; solo_enc->vidq.mem_ops = &vb2_dma_sg_memops; solo_enc->vidq.drv_priv = solo_enc; - solo_enc->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; + solo_enc->vidq.gfp_flags = __GFP_DMA32; solo_enc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; solo_enc->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); solo_enc->vidq.lock = &solo_enc->lock; diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c index 721ff53..e3146a9 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c @@ -678,7 +678,7 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr) solo_dev->vidq.mem_ops = &vb2_dma_contig_memops; solo_dev->vidq.drv_priv = solo_dev; solo_dev->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - solo_dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; + solo_dev->vidq.gfp_flags = __GFP_DMA32; solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); solo_dev->vidq.lock = &solo_dev->lock; ret = vb2_queue_init(&solo_dev->vidq); diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 07116a8..5f4dd28 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c @@ -979,7 +979,7 @@ int tw68_video_init2(struct tw68_dev *dev, int video_nr) dev->vidq.ops = &tw68_video_qops; dev->vidq.mem_ops = &vb2_dma_sg_memops; dev->vidq.drv_priv = dev; - dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM; + dev->vidq.gfp_flags = __GFP_DMA32; dev->vidq.buf_struct_size = sizeof(struct tw68_buf); dev->vidq.lock = &dev->lock; dev->vidq.min_buffers_needed = 2; diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 3096251..56bf0c5 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -1230,7 +1230,8 @@ EXPORT_SYMBOL_GPL(mtd_writev); */ void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size) { - gfp_t flags = __GFP_NOWARN | __GFP_DIRECT_RECLAIM | __GFP_NORETRY; + gfp_t flags = __GFP_NOWARN | __GFP_WAIT | + __GFP_NORETRY | __GFP_NO_KSWAPD; size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); void *kbuf; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 0a9108c..07e88de 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -687,7 +687,7 @@ static void *bnx2x_frag_alloc(const struct bnx2x_fastpath *fp, gfp_t gfp_mask) { if (fp->rx_frag_size) { /* GFP_KERNEL allocations are used only during initialization */ - if (unlikely(gfpflags_allow_blocking(gfp_mask))) + if (unlikely(gfp_mask & __GFP_WAIT)) return (void *)__get_free_page(gfp_mask); return netdev_alloc_frag(fp->rx_frag_size); diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index b69dfc7..d2dfe7f 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -27,7 +27,11 @@ #include "ion_priv.h" static gfp_t high_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN | +<<<<<<< HEAD __GFP_NORETRY) & ~__GFP_RECLAIM; +======= + __GFP_NORETRY) & ~__GFP_WAIT; +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd static gfp_t low_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN); static const unsigned int orders[] = {8, 4, 0}; static const int num_orders = ARRAY_SIZE(orders); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index dab4862..200d87d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -95,7 +95,7 @@ do { \ do { \ LASSERT(!in_interrupt() || \ ((size) <= LIBCFS_VMALLOC_SIZE && \ - !gfpflags_allow_blocking(mask))); \ + ((mask) & __GFP_WAIT) == 0)); \ } while (0) #define LIBCFS_ALLOC_POST(ptr, size) \ diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 43d5293..8e0f280 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c @@ -2240,7 +2240,7 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, { struct u132 *u132 = hcd_to_u132(hcd); if (irqs_disabled()) { - if (gfpflags_allow_blocking(mem_flags)) { + if (__GFP_WAIT & mem_flags) { printk(KERN_ERR "invalid context for function that might sleep\n"); return -EINVAL; } diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c index 1c1e95a..6b70d7f 100644 --- a/drivers/video/fbdev/vermilion/vermilion.c +++ b/drivers/video/fbdev/vermilion/vermilion.c @@ -99,7 +99,7 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order, * below the first 16MB. */ - flags = __GFP_DMA | __GFP_HIGH | __GFP_KSWAPD_RECLAIM; + flags = __GFP_DMA | __GFP_HIGH; va->logical = __get_free_pages(flags, --max_order); } while (va->logical == 0 && max_order > min_order); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 4b02591..d8174c7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2617,7 +2617,7 @@ int open_ctree(struct super_block *sb, fs_info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL; fs_info->avg_delayed_ref_runtime = NSEC_PER_SEC >> 6; /* div by 64 */ /* readahead state */ - INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); + INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_WAIT); spin_lock_init(&fs_info->reada_lock); fs_info->thread_pool_size = min_t(unsigned long, diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 76a0c85..6d0b2c1 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -614,7 +614,7 @@ static int __clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, if (bits & (EXTENT_IOBITS | EXTENT_BOUNDARY)) clear = 1; again: - if (!prealloc && gfpflags_allow_blocking(mask)) { + if (!prealloc && (mask & __GFP_WAIT)) { /* * Don't care for allocation failure here because we might end * up not needing the pre-allocated extent state at all, which @@ -739,7 +739,7 @@ search_again: if (start > end) goto out; spin_unlock(&tree->lock); - if (gfpflags_allow_blocking(mask)) + if (mask & __GFP_WAIT) cond_resched(); goto again; } @@ -872,7 +872,7 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, bits |= EXTENT_FIRST_DELALLOC; again: - if (!prealloc && gfpflags_allow_blocking(mask)) { + if (!prealloc && (mask & __GFP_WAIT)) { prealloc = alloc_extent_state(mask); BUG_ON(!prealloc); } @@ -1050,7 +1050,7 @@ search_again: if (start > end) goto out; spin_unlock(&tree->lock); - if (gfpflags_allow_blocking(mask)) + if (mask & __GFP_WAIT) cond_resched(); goto again; } @@ -1098,7 +1098,7 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, btrfs_debug_check_extent_io_range(tree, start, end); again: - if (!prealloc && gfpflags_allow_blocking(mask)) { + if (!prealloc && (mask & __GFP_WAIT)) { /* * Best effort, don't worry if extent state allocation fails * here for the first iteration. We might have a cached state @@ -1276,7 +1276,7 @@ search_again: if (start > end) goto out; spin_unlock(&tree->lock); - if (gfpflags_allow_blocking(mask)) + if (mask & __GFP_WAIT) cond_resched(); first_iteration = false; goto again; @@ -4264,8 +4264,13 @@ int try_release_extent_mapping(struct extent_map_tree *map, u64 start = page_offset(page); u64 end = start + PAGE_CACHE_SIZE - 1; +<<<<<<< HEAD if (gfpflags_allow_blocking(mask) && page->mapping->host->i_size > SZ_16M) { +======= + if ((mask & __GFP_WAIT) && + page->mapping->host->i_size > 16 * 1024 * 1024) { +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd u64 len; while (start <= end) { len = end - start + 1; diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e2b54d5..3401b2a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -233,9 +233,14 @@ static struct btrfs_device *__alloc_device(void) spin_lock_init(&dev->reada_lock); atomic_set(&dev->reada_in_flight, 0); atomic_set(&dev->dev_stats_ccnt, 0); +<<<<<<< HEAD btrfs_device_data_ordered_init(dev); INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); +======= + INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_WAIT); + INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_WAIT); +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd return dev; } diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 5392975..1572eba 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1089,7 +1089,7 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page, return 0; if (journal) return jbd2_journal_try_to_free_buffers(journal, page, - wait & ~__GFP_DIRECT_RECLAIM); + wait & ~__GFP_WAIT); return try_to_free_buffers(page); } diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c index 43040721..d403c69 100644 --- a/fs/fscache/cookie.c +++ b/fs/fscache/cookie.c @@ -111,7 +111,7 @@ struct fscache_cookie *__fscache_acquire_cookie( /* radix tree insertion won't use the preallocation pool unless it's * told it may not wait */ - INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); + INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_WAIT); switch (cookie->def->type) { case FSCACHE_COOKIE_TYPE_INDEX: diff --git a/fs/fscache/page.c b/fs/fscache/page.c index 6b35fc4..ca916af 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c @@ -58,7 +58,7 @@ bool release_page_wait_timeout(struct fscache_cookie *cookie, struct page *page) /* * decide whether a page can be released, possibly by cancelling a store to it - * - we're allowed to sleep if __GFP_DIRECT_RECLAIM is flagged + * - we're allowed to sleep if __GFP_WAIT is flagged */ bool __fscache_maybe_release_page(struct fscache_cookie *cookie, struct page *page, @@ -122,7 +122,7 @@ page_busy: * allocator as the work threads writing to the cache may all end up * sleeping on memory allocation, so we may need to impose a timeout * too. */ - if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & __GFP_FS)) { + if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) { fscache_stat(&fscache_n_store_vmscan_busy); return false; } @@ -132,7 +132,7 @@ page_busy: _debug("fscache writeout timeout page: %p{%lx}", page, page->index); - gfp &= ~__GFP_DIRECT_RECLAIM; + gfp &= ~__GFP_WAIT; goto try_again; } EXPORT_SYMBOL(__fscache_maybe_release_page); diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 01e4652d..9200203 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -1927,8 +1927,8 @@ out: * @journal: journal for operation * @page: to try and free * @gfp_mask: we use the mask to detect how hard should we try to release - * buffers. If __GFP_DIRECT_RECLAIM and __GFP_FS is set, we wait for commit - * code to release the buffers. + * buffers. If __GFP_WAIT and __GFP_FS is set, we wait for commit code to + * release the buffers. * * * For all the buffers on this page, diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 89bf093..66d6174 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -475,8 +475,8 @@ static int nfs_release_page(struct page *page, gfp_t gfp) dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page); /* Always try to initiate a 'commit' if relevant, but only - * wait for it if the caller allows blocking. Even then, - * only wait 1 second and only if the 'bdi' is not congested. + * wait for it if __GFP_WAIT is set. Even then, only wait 1 + * second and only if the 'bdi' is not congested. * Waiting indefinitely can cause deadlocks when the NFS * server is on this machine, when a new TCP connection is * needed and in other rare cases. There is no particular @@ -486,7 +486,7 @@ static int nfs_release_page(struct page *page, gfp_t gfp) if (mapping) { struct nfs_server *nfss = NFS_SERVER(mapping->host); nfs_commit_inode(mapping->host, 0); - if (gfpflags_allow_blocking(gfp) && + if ((gfp & __GFP_WAIT) && !bdi_write_congested(&nfss->backing_dev_info)) { wait_on_page_bit_killable_timeout(page, PG_private, HZ); diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index be125e1..6b86547 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -525,7 +525,7 @@ xfs_qm_shrink_scan( unsigned long freed; int error; - if ((sc->gfp_mask & (__GFP_FS|__GFP_DIRECT_RECLAIM)) != (__GFP_FS|__GFP_DIRECT_RECLAIM)) + if ((sc->gfp_mask & (__GFP_FS|__GFP_WAIT)) != (__GFP_FS|__GFP_WAIT)) return 0; INIT_LIST_HEAD(&isol.buffers); diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 570383a..db03da6 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -34,13 +34,17 @@ struct vm_area_struct; #define ___GFP_NOMEMALLOC 0x10000u #define ___GFP_HARDWALL 0x20000u #define ___GFP_THISNODE 0x40000u +<<<<<<< HEAD #define ___GFP_ATOMIC 0x80000u #define ___GFP_ACCOUNT 0x100000u +======= +#define ___GFP_WAIT 0x80000u +#define ___GFP_NOACCOUNT 0x100000u +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd #define ___GFP_NOTRACK 0x200000u -#define ___GFP_DIRECT_RECLAIM 0x400000u +#define ___GFP_NO_KSWAPD 0x400000u #define ___GFP_OTHER_NODE 0x800000u #define ___GFP_WRITE 0x1000000u -#define ___GFP_KSWAPD_RECLAIM 0x2000000u /* If the above are modified, __GFP_BITS_SHIFT may need updating */ /* @@ -81,6 +85,7 @@ struct vm_area_struct; * __GFP_ACCOUNT causes the allocation to be accounted to kmemcg (only relevant * to kmem allocations). */ +<<<<<<< HEAD #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) @@ -178,6 +183,38 @@ struct vm_area_struct; * should not be accounted for as a remote allocation in vmstat. A * typical user would be khugepaged collapsing a huge page on a remote * node. +======= +#define __GFP_WAIT ((__force gfp_t)___GFP_WAIT) /* Can wait and reschedule? */ +#define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) /* Should access emergency pools? */ +#define __GFP_IO ((__force gfp_t)___GFP_IO) /* Can start physical IO? */ +#define __GFP_FS ((__force gfp_t)___GFP_FS) /* Can call down to low-level FS? */ +#define __GFP_COLD ((__force gfp_t)___GFP_COLD) /* Cache-cold page required */ +#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) /* Suppress page allocation failure warning */ +#define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */ +#define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */ +#define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */ +#define __GFP_MEMALLOC ((__force gfp_t)___GFP_MEMALLOC)/* Allow access to emergency reserves */ +#define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */ +#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */ +#define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves. + * This takes precedence over the + * __GFP_MEMALLOC flag if both are + * set + */ +#define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */ +#define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */ +#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */ +#define __GFP_NOACCOUNT ((__force gfp_t)___GFP_NOACCOUNT) /* Don't account to kmemcg */ +#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */ + +#define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD) +#define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */ +#define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */ + +/* + * This may seem redundant, but it's a way of annotating false positives vs. + * allocations that simply cannot be supported (e.g. page tables). +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd */ #define __GFP_COLD ((__force gfp_t)___GFP_COLD) #define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) @@ -187,6 +224,7 @@ struct vm_area_struct; #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK) #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) +<<<<<<< HEAD /* Room for N __GFP_FOO bits */ #define __GFP_BITS_SHIFT 26 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) @@ -249,15 +287,35 @@ struct vm_area_struct; #define GFP_NOIO (__GFP_RECLAIM) #define GFP_NOFS (__GFP_RECLAIM | __GFP_IO) #define GFP_TEMPORARY (__GFP_RECLAIM | __GFP_IO | __GFP_FS | \ +======= +#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */ +#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) + +/* This equals 0, but use constants in case they ever change */ +#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH) +/* GFP_ATOMIC means both !wait (__GFP_WAIT not set) and use emergency pool */ +#define GFP_ATOMIC (__GFP_HIGH) +#define GFP_NOIO (__GFP_WAIT) +#define GFP_NOFS (__GFP_WAIT | __GFP_IO) +#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS) +#define GFP_TEMPORARY (__GFP_WAIT | __GFP_IO | __GFP_FS | \ +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd __GFP_RECLAIMABLE) #define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL) #define GFP_DMA __GFP_DMA #define GFP_DMA32 __GFP_DMA32 #define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM) #define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE) +<<<<<<< HEAD #define GFP_TRANSHUGE ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN) & \ ~__GFP_RECLAIM) +======= +#define GFP_IOFS (__GFP_IO | __GFP_FS) +#define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ + __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \ + __GFP_NO_KSWAPD) +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd /* Convert GFP flags to their corresponding migrate type */ #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE) @@ -278,11 +336,14 @@ static inline int gfpflags_to_migratetype(const gfp_t gfp_flags) #undef GFP_MOVABLE_MASK #undef GFP_MOVABLE_SHIFT +<<<<<<< HEAD static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) { return !!(gfp_flags & __GFP_DIRECT_RECLAIM); } +======= +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd #ifdef CONFIG_HIGHMEM #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM #else diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 15d0df9..d918e5a 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1298,7 +1298,7 @@ static inline int skb_cloned(const struct sk_buff *skb) static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) { - might_sleep_if(gfpflags_allow_blocking(pri)); + might_sleep_if(pri & __GFP_WAIT); if (skb_cloned(skb)) return pskb_expand_head(skb, 0, 0, pri); @@ -1382,7 +1382,7 @@ static inline int skb_shared(const struct sk_buff *skb) */ static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri) { - might_sleep_if(gfpflags_allow_blocking(pri)); + might_sleep_if(pri & __GFP_WAIT); if (skb_shared(skb)) { struct sk_buff *nskb = skb_clone(skb, pri); @@ -1418,7 +1418,7 @@ static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri) static inline struct sk_buff *skb_unshare(struct sk_buff *skb, gfp_t pri) { - might_sleep_if(gfpflags_allow_blocking(pri)); + might_sleep_if(pri & __GFP_WAIT); if (skb_cloned(skb)) { struct sk_buff *nskb = skb_copy(skb, pri); diff --git a/include/net/sock.h b/include/net/sock.h index 255d3e0..8bb8559 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1940,7 +1940,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, */ static inline struct page_frag *sk_page_frag(struct sock *sk) { - if (gfpflags_allow_blocking(sk->sk_allocation)) + if (sk->sk_allocation & __GFP_WAIT) return ¤t->task_frag; return &sk->sk_frag; diff --git a/include/trace/events/gfpflags.h b/include/trace/events/gfpflags.h new file mode 100644 index 0000000..d6fd8e5 --- /dev/null +++ b/include/trace/events/gfpflags.h @@ -0,0 +1,42 @@ +/* + * The order of these masks is important. Matching masks will be seen + * first and the left over flags will end up showing by themselves. + * + * For example, if we have GFP_KERNEL before GFP_USER we wil get: + * + * GFP_KERNEL|GFP_HARDWALL + * + * Thus most bits set go first. + */ +#define show_gfp_flags(flags) \ + (flags) ? __print_flags(flags, "|", \ + {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ + {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"}, \ + {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ + {(unsigned long)GFP_USER, "GFP_USER"}, \ + {(unsigned long)GFP_TEMPORARY, "GFP_TEMPORARY"}, \ + {(unsigned long)GFP_KERNEL, "GFP_KERNEL"}, \ + {(unsigned long)GFP_NOFS, "GFP_NOFS"}, \ + {(unsigned long)GFP_ATOMIC, "GFP_ATOMIC"}, \ + {(unsigned long)GFP_NOIO, "GFP_NOIO"}, \ + {(unsigned long)__GFP_HIGH, "GFP_HIGH"}, \ + {(unsigned long)__GFP_WAIT, "GFP_WAIT"}, \ + {(unsigned long)__GFP_IO, "GFP_IO"}, \ + {(unsigned long)__GFP_COLD, "GFP_COLD"}, \ + {(unsigned long)__GFP_NOWARN, "GFP_NOWARN"}, \ + {(unsigned long)__GFP_REPEAT, "GFP_REPEAT"}, \ + {(unsigned long)__GFP_NOFAIL, "GFP_NOFAIL"}, \ + {(unsigned long)__GFP_NORETRY, "GFP_NORETRY"}, \ + {(unsigned long)__GFP_COMP, "GFP_COMP"}, \ + {(unsigned long)__GFP_ZERO, "GFP_ZERO"}, \ + {(unsigned long)__GFP_NOMEMALLOC, "GFP_NOMEMALLOC"}, \ + {(unsigned long)__GFP_MEMALLOC, "GFP_MEMALLOC"}, \ + {(unsigned long)__GFP_HARDWALL, "GFP_HARDWALL"}, \ + {(unsigned long)__GFP_THISNODE, "GFP_THISNODE"}, \ + {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \ + {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"}, \ + {(unsigned long)__GFP_NOTRACK, "GFP_NOTRACK"}, \ + {(unsigned long)__GFP_NO_KSWAPD, "GFP_NO_KSWAPD"}, \ + {(unsigned long)__GFP_OTHER_NODE, "GFP_OTHER_NODE"} \ + ) : "GFP_NOWAIT" + diff --git a/kernel/audit.c b/kernel/audit.c index 678c3f0..5eeabb6 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -1385,16 +1385,22 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, if (unlikely(audit_filter_type(type))) return NULL; +<<<<<<< HEAD if (gfp_mask & __GFP_DIRECT_RECLAIM) { if (audit_pid && audit_pid == current->tgid) gfp_mask &= ~__GFP_DIRECT_RECLAIM; +======= + if (gfp_mask & __GFP_WAIT) { + if (audit_pid && audit_pid == current->pid) + gfp_mask &= ~__GFP_WAIT; +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd else reserve = 0; } while (audit_backlog_limit && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) { - if (gfp_mask & __GFP_DIRECT_RECLAIM && audit_backlog_wait_time) { + if (gfp_mask & __GFP_WAIT && audit_backlog_wait_time) { long sleep_time; sleep_time = timeout_start + audit_backlog_wait_time - jiffies; diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 671dc05..81b73e4 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -335,7 +335,7 @@ static int cgroup_idr_alloc(struct idr *idr, void *ptr, int start, int end, idr_preload(gfp_mask); spin_lock_bh(&cgroup_idr_lock); - ret = idr_alloc(idr, ptr, start, end, gfp_mask & ~__GFP_DIRECT_RECLAIM); + ret = idr_alloc(idr, ptr, start, end, gfp_mask & ~__GFP_WAIT); spin_unlock_bh(&cgroup_idr_lock); idr_preload_end(); return ret; diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 53ab2f8..3c6ee67 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2754,7 +2754,7 @@ static void __lockdep_trace_alloc(gfp_t gfp_mask, unsigned long flags) return; /* no reclaim without waiting on it */ - if (!(gfp_mask & __GFP_DIRECT_RECLAIM)) + if (!(gfp_mask & __GFP_WAIT)) return; /* this guy won't enter reclaim */ diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 3a97060..5235dd4 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -1779,7 +1779,7 @@ alloc_highmem_pages(struct memory_bitmap *bm, unsigned int nr_highmem) while (to_alloc-- > 0) { struct page *page; - page = alloc_image_page(__GFP_HIGHMEM|__GFP_KSWAPD_RECLAIM); + page = alloc_image_page(__GFP_HIGHMEM); memory_bm_set_bit(bm, page_to_pfn(page)); } return nr_highmem; diff --git a/kernel/smp.c b/kernel/smp.c index 7416544..3b1dbea 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -669,7 +669,7 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info), cpumask_var_t cpus; int cpu, ret; - might_sleep_if(gfpflags_allow_blocking(gfp_flags)); + might_sleep_if(gfp_flags & __GFP_WAIT); if (likely(zalloc_cpumask_var(&cpus, (gfp_flags|__GFP_NOWARN)))) { preempt_disable(); diff --git a/lib/idr.c b/lib/idr.c index 6098336..5335c43 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -399,7 +399,7 @@ void idr_preload(gfp_t gfp_mask) * allocation guarantee. Disallow usage from those contexts. */ WARN_ON_ONCE(in_interrupt()); - might_sleep_if(gfpflags_allow_blocking(gfp_mask)); + might_sleep_if(gfp_mask & __GFP_WAIT); preempt_disable(); @@ -453,7 +453,7 @@ int idr_alloc(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask) struct idr_layer *pa[MAX_IDR_LEVEL + 1]; int id; - might_sleep_if(gfpflags_allow_blocking(gfp_mask)); + might_sleep_if(gfp_mask & __GFP_WAIT); /* sanity checks */ if (WARN_ON_ONCE(start < 0)) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 1624c41..bbf6265 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -223,7 +223,7 @@ radix_tree_node_alloc(struct radix_tree_root *root) * preloading in the interrupt anyway as all the allocations have to * be atomic. So just do normal allocation when in interrupt. */ - if (!gfpflags_allow_blocking(gfp_mask) && !in_interrupt()) { + if (!(gfp_mask & __GFP_WAIT) && !in_interrupt()) { struct radix_tree_preload *rtp; /* @@ -294,7 +294,7 @@ radix_tree_node_free(struct radix_tree_node *node) * with preemption not disabled. * * To make use of this facility, the radix tree must be initialised without - * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE(). + * __GFP_WAIT being passed to INIT_RADIX_TREE(). */ static int __radix_tree_preload(gfp_t gfp_mask) { @@ -331,12 +331,12 @@ out: * with preemption not disabled. * * To make use of this facility, the radix tree must be initialised without - * __GFP_DIRECT_RECLAIM being passed to INIT_RADIX_TREE(). + * __GFP_WAIT being passed to INIT_RADIX_TREE(). */ int radix_tree_preload(gfp_t gfp_mask) { /* Warn on non-sensical use... */ - WARN_ON_ONCE(!gfpflags_allow_blocking(gfp_mask)); + WARN_ON_ONCE(!(gfp_mask & __GFP_WAIT)); return __radix_tree_preload(gfp_mask); } EXPORT_SYMBOL(radix_tree_preload); @@ -348,7 +348,7 @@ EXPORT_SYMBOL(radix_tree_preload); */ int radix_tree_maybe_preload(gfp_t gfp_mask) { - if (gfpflags_allow_blocking(gfp_mask)) + if (gfp_mask & __GFP_WAIT) return __radix_tree_preload(gfp_mask); /* Preloading doesn't help anything with this gfp mask, skip it */ preempt_disable(); diff --git a/mm/backing-dev.c b/mm/backing-dev.c index bfbd709..c095555 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -637,7 +637,7 @@ struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi, { struct bdi_writeback *wb; - might_sleep_if(gfpflags_allow_blocking(gfp)); + might_sleep_if(gfp & __GFP_WAIT); if (!memcg_css->parent) return &bdi->wb; diff --git a/mm/dmapool.c b/mm/dmapool.c index abcbfe8..b6bbba7 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -325,7 +325,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, size_t offset; void *retval; - might_sleep_if(gfpflags_allow_blocking(mem_flags)); + might_sleep_if(mem_flags & __GFP_WAIT); spin_lock_irqsave(&pool->lock, flags); list_for_each_entry(page, &pool->page_list, page_list) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 36db05f..67b9681 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1973,7 +1973,7 @@ retry: if (unlikely(task_in_memcg_oom(current))) goto nomem; - if (!gfpflags_allow_blocking(gfp_mask)) + if (!(gfp_mask & __GFP_WAIT)) goto nomem; mem_cgroup_events(mem_over_limit, MEMCG_MAX, 1); @@ -4271,8 +4271,8 @@ static int mem_cgroup_do_precharge(unsigned long count) { int ret; - /* Try a single bulk charge without reclaim first, kswapd may wake */ - ret = try_charge(mc.to, GFP_KERNEL & ~__GFP_DIRECT_RECLAIM, count); + /* Try a single bulk charge without reclaim first */ + ret = try_charge(mc.to, GFP_KERNEL & ~__GFP_WAIT, count); if (!ret) { mc.precharge += count; return ret; diff --git a/mm/mempool.c b/mm/mempool.c index 07c383d..05ec074 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -323,13 +323,17 @@ void *mempool_alloc(mempool_t *pool, gfp_t gfp_mask) VM_WARN_ON_ONCE(gfp_mask & __GFP_NOMEMALLOC); /* No element size to zero on allocation */ VM_WARN_ON_ONCE(gfp_mask & __GFP_ZERO); +<<<<<<< HEAD might_sleep_if(gfp_mask & __GFP_DIRECT_RECLAIM); +======= + might_sleep_if(gfp_mask & __GFP_WAIT); +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */ gfp_mask |= __GFP_NOWARN; /* failures are OK */ - gfp_temp = gfp_mask & ~(__GFP_DIRECT_RECLAIM|__GFP_IO); + gfp_temp = gfp_mask & ~(__GFP_WAIT|__GFP_IO); repeat_alloc: if (likely(pool->curr_nr)) { @@ -360,7 +364,7 @@ repeat_alloc: } /* - * We use gfp mask w/o direct reclaim or IO for the first round. If + * We use gfp mask w/o __GFP_WAIT or IO for the first round. If * alloc failed with that and @pool was empty, retry immediately. */ if ((gfp_temp & ~__GFP_NOMEMALLOC) != gfp_mask) { @@ -370,8 +374,8 @@ repeat_alloc: } gfp_temp = gfp_mask; - /* We must not sleep if !__GFP_DIRECT_RECLAIM */ - if (!(gfp_mask & __GFP_DIRECT_RECLAIM)) { + /* We must not sleep if !__GFP_WAIT */ + if (!(gfp_mask & __GFP_WAIT)) { spin_unlock_irqrestore(&pool->lock, flags); return NULL; } diff --git a/mm/migrate.c b/mm/migrate.c index 6c822a7..518375a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1591,7 +1591,11 @@ static struct page *alloc_misplaced_dst_page(struct page *page, (GFP_HIGHUSER_MOVABLE | __GFP_THISNODE | __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN) & +<<<<<<< HEAD ~__GFP_RECLAIM, 0); +======= + ~GFP_IOFS, 0); +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd return newpage; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a762be5..d0c4f3f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -163,12 +163,12 @@ void pm_restrict_gfp_mask(void) WARN_ON(!mutex_is_locked(&pm_mutex)); WARN_ON(saved_gfp_mask); saved_gfp_mask = gfp_allowed_mask; - gfp_allowed_mask &= ~(__GFP_IO | __GFP_FS); + gfp_allowed_mask &= ~GFP_IOFS; } bool pm_suspended_storage(void) { - if ((gfp_allowed_mask & (__GFP_IO | __GFP_FS)) == (__GFP_IO | __GFP_FS)) + if ((gfp_allowed_mask & GFP_IOFS) == GFP_IOFS) return false; return true; } @@ -2425,8 +2425,12 @@ static bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) return false; if (fail_page_alloc.ignore_gfp_highmem && (gfp_mask & __GFP_HIGHMEM)) return false; +<<<<<<< HEAD if (fail_page_alloc.ignore_gfp_reclaim && (gfp_mask & __GFP_DIRECT_RECLAIM)) +======= + if (fail_page_alloc.ignore_gfp_wait && (gfp_mask & __GFP_WAIT)) +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd return false; return should_fail(&fail_page_alloc.attr, 1 << order); @@ -2784,7 +2788,7 @@ void warn_alloc_failed(gfp_t gfp_mask, unsigned int order, const char *fmt, ...) if (test_thread_flag(TIF_MEMDIE) || (current->flags & (PF_MEMALLOC | PF_EXITING))) filter &= ~SHOW_MEM_FILTER_NODES; - if (in_interrupt() || !(gfp_mask & __GFP_DIRECT_RECLAIM)) + if (in_interrupt() || !(gfp_mask & __GFP_WAIT)) filter &= ~SHOW_MEM_FILTER_NODES; if (fmt) { @@ -3036,6 +3040,7 @@ static inline int gfp_to_alloc_flags(gfp_t gfp_mask) { int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET; + const bool atomic = !(gfp_mask & (__GFP_WAIT | __GFP_NO_KSWAPD)); /* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */ BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH); @@ -3044,11 +3049,11 @@ gfp_to_alloc_flags(gfp_t gfp_mask) * The caller may dip into page reserves a bit more if the caller * cannot run direct reclaim, or if the caller has realtime scheduling * policy or is asking for __GFP_HIGH memory. GFP_ATOMIC requests will - * set both ALLOC_HARDER (__GFP_ATOMIC) and ALLOC_HIGH (__GFP_HIGH). + * set both ALLOC_HARDER (atomic == true) and ALLOC_HIGH (__GFP_HIGH). */ alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH); - if (gfp_mask & __GFP_ATOMIC) { + if (atomic) { /* * Not worth trying to allocate harder for __GFP_NOMEMALLOC even * if it can't schedule. @@ -3085,16 +3090,11 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) return !!(gfp_to_alloc_flags(gfp_mask) & ALLOC_NO_WATERMARKS); } -static inline bool is_thp_gfp_mask(gfp_t gfp_mask) -{ - return (gfp_mask & (GFP_TRANSHUGE | __GFP_KSWAPD_RECLAIM)) == GFP_TRANSHUGE; -} - static inline struct page * __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, struct alloc_context *ac) { - bool can_direct_reclaim = gfp_mask & __GFP_DIRECT_RECLAIM; + const gfp_t wait = gfp_mask & __GFP_WAIT; struct page *page = NULL; int alloc_flags; unsigned long pages_reclaimed = 0; @@ -3115,15 +3115,24 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, } /* +<<<<<<< HEAD * We also sanity check to catch abuse of atomic reserves being used by * callers that are not in atomic context. */ if (WARN_ON_ONCE((gfp_mask & (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)) == (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM))) gfp_mask &= ~__GFP_ATOMIC; +======= + * If this allocation cannot block and it is for a specific node, then + * fail early. There's no need to wakeup kswapd or retry for a + * speculative node-specific allocation. + */ + if (IS_ENABLED(CONFIG_NUMA) && (gfp_mask & __GFP_THISNODE) && !wait) + goto nopage; +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd retry: - if (gfp_mask & __GFP_KSWAPD_RECLAIM) + if (!(gfp_mask & __GFP_NO_KSWAPD)) wake_all_kswapds(order, ac); /* @@ -3164,8 +3173,8 @@ retry: goto got_pg; } - /* Caller is not willing to reclaim, we can't balance anything */ - if (!can_direct_reclaim) { + /* Atomic allocations - we can't balance anything */ + if (!wait) { /* * All existing users of the __GFP_NOFAIL are blockable, so warn * of any new users that actually allow this type of allocation @@ -3205,7 +3214,7 @@ retry: goto got_pg; /* Checks for THP-specific high-order allocations */ - if (is_thp_gfp_mask(gfp_mask)) { + if ((gfp_mask & GFP_TRANSHUGE) == GFP_TRANSHUGE) { /* * If compaction is deferred for high-order allocations, it is * because sync compaction recently failed. If this is the case @@ -3240,7 +3249,8 @@ retry: * fault, so use asynchronous memory compaction for THP unless it is * khugepaged trying to collapse. */ - if (!is_thp_gfp_mask(gfp_mask) || (current->flags & PF_KTHREAD)) + if ((gfp_mask & GFP_TRANSHUGE) != GFP_TRANSHUGE || + (current->flags & PF_KTHREAD)) migration_mode = MIGRATE_SYNC_LIGHT; /* Try direct reclaim and then allocating */ @@ -3311,7 +3321,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, lockdep_trace_alloc(gfp_mask); - might_sleep_if(gfp_mask & __GFP_DIRECT_RECLAIM); + might_sleep_if(gfp_mask & __GFP_WAIT); if (should_fail_alloc_page(gfp_mask, order)) return NULL; diff --git a/mm/slab.c b/mm/slab.c index e719a5c..510eef3 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -841,12 +841,21 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp) } /* +<<<<<<< HEAD * Construct gfp mask to allocate from a specific node but do not reclaim or * warn about failures. */ static inline gfp_t gfp_exact_node(gfp_t flags) { return (flags | __GFP_THISNODE | __GFP_NOWARN) & ~(__GFP_RECLAIM|__GFP_NOFAIL); +======= + * Construct gfp mask to allocate from a specific node but do not invoke reclaim + * or warn about failures. + */ +static inline gfp_t gfp_exact_node(gfp_t flags) +{ + return (flags | __GFP_THISNODE | __GFP_NOWARN) & ~__GFP_WAIT; +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd } #endif @@ -2522,7 +2531,7 @@ static int cache_grow(struct kmem_cache *cachep, offset *= cachep->colour_off; - if (gfpflags_allow_blocking(local_flags)) + if (local_flags & __GFP_WAIT) local_irq_enable(); /* @@ -2552,7 +2561,7 @@ static int cache_grow(struct kmem_cache *cachep, cache_init_objs(cachep, page); - if (gfpflags_allow_blocking(local_flags)) + if (local_flags & __GFP_WAIT) local_irq_disable(); check_irq_off(); spin_lock(&n->list_lock); @@ -2566,7 +2575,7 @@ static int cache_grow(struct kmem_cache *cachep, opps1: kmem_freepages(cachep, page); failed: - if (gfpflags_allow_blocking(local_flags)) + if (local_flags & __GFP_WAIT) local_irq_disable(); return 0; } @@ -2870,7 +2879,7 @@ alloc_done: static inline void cache_alloc_debugcheck_before(struct kmem_cache *cachep, gfp_t flags) { - might_sleep_if(gfpflags_allow_blocking(flags)); + might_sleep_if(flags & __GFP_WAIT); #if DEBUG kmem_flagcheck(cachep, flags); #endif @@ -3029,11 +3038,11 @@ retry: */ struct page *page; - if (gfpflags_allow_blocking(local_flags)) + if (local_flags & __GFP_WAIT) local_irq_enable(); kmem_flagcheck(cache, flags); page = kmem_getpages(cache, local_flags, numa_mem_id()); - if (gfpflags_allow_blocking(local_flags)) + if (local_flags & __GFP_WAIT) local_irq_disable(); if (page) { /* diff --git a/mm/slub.c b/mm/slub.c index 7277413..f36cad7 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1322,6 +1322,32 @@ static inline void kfree_hook(const void *x) kasan_kfree_large(x); } +<<<<<<< HEAD +======= +static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s, + gfp_t flags) +{ + flags &= gfp_allowed_mask; + lockdep_trace_alloc(flags); + might_sleep_if(flags & __GFP_WAIT); + + if (should_failslab(s->object_size, flags, s->flags)) + return NULL; + + return memcg_kmem_get_cache(s, flags); +} + +static inline void slab_post_alloc_hook(struct kmem_cache *s, + gfp_t flags, void *object) +{ + flags &= gfp_allowed_mask; + kmemcheck_slab_alloc(s, flags, object, slab_ksize(s)); + kmemleak_alloc_recursive(object, s->object_size, 1, s->flags, flags); + memcg_kmem_put_cache(s); + kasan_slab_alloc(s, object); +} + +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd static inline void slab_free_hook(struct kmem_cache *s, void *x) { kmemleak_free_recursive(x, s->flags); @@ -1415,7 +1441,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= gfp_allowed_mask; - if (gfpflags_allow_blocking(flags)) + if (flags & __GFP_WAIT) local_irq_enable(); flags |= s->allocflags; @@ -1425,8 +1451,13 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) * so we fall-back to the minimum order allocation. */ alloc_gfp = (flags | __GFP_NOWARN | __GFP_NORETRY) & ~__GFP_NOFAIL; +<<<<<<< HEAD if ((alloc_gfp & __GFP_DIRECT_RECLAIM) && oo_order(oo) > oo_order(s->min)) alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~(__GFP_RECLAIM|__GFP_NOFAIL); +======= + if ((alloc_gfp & __GFP_WAIT) && oo_order(oo) > oo_order(s->min)) + alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~__GFP_WAIT; +>>>>>>> parent of d0164ad... mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd page = alloc_slab_page(s, alloc_gfp, node, oo); if (unlikely(!page)) { @@ -1486,7 +1517,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) page->frozen = 1; out: - if (gfpflags_allow_blocking(flags)) + if (flags & __GFP_WAIT) local_irq_disable(); if (!page) return NULL; diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ae7d20b..f3e6be8 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1612,7 +1612,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, goto fail; } area->pages[i] = page; - if (gfpflags_allow_blocking(gfp_mask)) + if (gfp_mask & __GFP_WAIT) cond_resched(); } diff --git a/mm/vmscan.c b/mm/vmscan.c index b934223e..70b0b7a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1486,7 +1486,7 @@ static int too_many_isolated(struct zone *zone, int file, * won't get blocked by normal direct-reclaimers, forming a circular * deadlock. */ - if ((sc->gfp_mask & (__GFP_IO | __GFP_FS)) == (__GFP_IO | __GFP_FS)) + if ((sc->gfp_mask & GFP_IOFS) == GFP_IOFS) inactive >>= 3; return isolated > inactive; @@ -3756,7 +3756,7 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) /* * Do not scan if the allocation should not be delayed. */ - if (!gfpflags_allow_blocking(gfp_mask) || (current->flags & PF_MEMALLOC)) + if (!(gfp_mask & __GFP_WAIT) || (current->flags & PF_MEMALLOC)) return ZONE_RECLAIM_NOSCAN; /* diff --git a/mm/zswap.c b/mm/zswap.c index bf14508..b07e7e1 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -565,7 +565,7 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) static struct zswap_pool *zswap_pool_create(char *type, char *compressor) { struct zswap_pool *pool; - gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM; + gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; pool = kzalloc(sizeof(*pool), GFP_KERNEL); if (!pool) { @@ -1011,8 +1011,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, /* store */ len = dlen + sizeof(struct zswap_header); ret = zpool_malloc(entry->pool->zpool, len, - __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM, - &handle); + __GFP_NORETRY | __GFP_NOWARN, &handle); if (ret == -ENOSPC) { zswap_reject_compress_poor++; goto put_dstmem; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index d04c2d1..eb6e79a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -424,7 +424,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, len += NET_SKB_PAD; if ((len > SKB_WITH_OVERHEAD(PAGE_SIZE)) || - (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { + (gfp_mask & (__GFP_WAIT | GFP_DMA))) { skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); if (!skb) goto skb_fail; @@ -491,7 +491,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len, len += NET_SKB_PAD + NET_IP_ALIGN; if ((len > SKB_WITH_OVERHEAD(PAGE_SIZE)) || - (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { + (gfp_mask & (__GFP_WAIT | GFP_DMA))) { skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); if (!skb) goto skb_fail; @@ -4547,7 +4547,7 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, return NULL; gfp_head = gfp_mask; - if (gfp_head & __GFP_DIRECT_RECLAIM) + if (gfp_head & __GFP_WAIT) gfp_head |= __GFP_REPEAT; *errcode = -ENOBUFS; @@ -4562,7 +4562,7 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len, while (order) { if (npages >= 1 << order) { - page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) | + page = alloc_pages((gfp_mask & ~__GFP_WAIT) | __GFP_COMP | __GFP_NOWARN | __GFP_NORETRY, diff --git a/net/core/sock.c b/net/core/sock.c index b67b9ae..c7a70c1 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1919,10 +1919,8 @@ bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t gfp) pfrag->offset = 0; if (SKB_FRAG_PAGE_ORDER) { - /* Avoid direct reclaim but allow kswapd to wake */ - pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) | - __GFP_COMP | __GFP_NOWARN | - __GFP_NORETRY, + pfrag->page = alloc_pages((gfp & ~__GFP_WAIT) | __GFP_COMP | + __GFP_NOWARN | __GFP_NORETRY, SKB_FRAG_PAGE_ORDER); if (likely(pfrag->page)) { pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 215fc08..16f5a3d 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1423,7 +1423,7 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid consume_skb(info.skb2); if (info.delivered) { - if (info.congested && gfpflags_allow_blocking(allocation)) + if (info.congested && (allocation & __GFP_WAIT)) yield(); return 0; } diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index 977fb86..96744b7 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -305,7 +305,7 @@ static int rds_ib_recv_refill_one(struct rds_connection *conn, gfp_t slab_mask = GFP_NOWAIT; gfp_t page_mask = GFP_NOWAIT; - if (gfp & __GFP_DIRECT_RECLAIM) { + if (gfp & __GFP_WAIT) { slab_mask = GFP_KERNEL; page_mask = GFP_HIGHUSER; } @@ -379,7 +379,7 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp) struct ib_recv_wr *failed_wr; unsigned int posted = 0; int ret = 0; - bool can_wait = !!(gfp & __GFP_DIRECT_RECLAIM); + bool can_wait = !!(gfp & __GFP_WAIT); u32 pos; /* the goal here is to just make sure that someone, somewhere diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c index 9942da1..3b999c7 100644 --- a/net/rxrpc/ar-connection.c +++ b/net/rxrpc/ar-connection.c @@ -499,7 +499,7 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, if (bundle->num_conns >= 20) { _debug("too many conns"); - if (!gfpflags_allow_blocking(gfp)) { + if (!(gfp & __GFP_WAIT)) { _leave(" = -EAGAIN"); return -EAGAIN; } diff --git a/net/sctp/associola.c b/net/sctp/associola.c index e1849f3..f5f1ad2 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -1596,7 +1596,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc, /* Set an association id for a given association */ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp) { - bool preload = gfpflags_allow_blocking(gfp); + bool preload = !!(gfp & __GFP_WAIT); int ret; /* If the id is already assigned, keep it. */ -- 2.5.0
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 114591
:
209201
|
209481
|
209501
|
210291
| 210581 |
210781
|
210921
|
211331
|
211341