From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
Michal Hocko <mhocko@suse.cz>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3.18 50/61] mm: get rid of radix tree gfp mask for pagecache_get_page
Date: Tue, 27 Jan 2015 17:27:02 -0800 [thread overview]
Message-ID: <20150128012642.386422859@linuxfoundation.org> (raw)
In-Reply-To: <20150128012636.936333725@linuxfoundation.org>
3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Hocko <mhocko@suse.cz>
commit 45f87de57f8fad59302fd263dd81ffa4843b5b24 upstream.
Commit 2457aec63745 ("mm: non-atomically mark page accessed during page
cache allocation where possible") has added a separate parameter for
specifying gfp mask for radix tree allocations.
Not only this is less than optimal from the API point of view because it
is error prone, it is also buggy currently because
grab_cache_page_write_begin is using GFP_KERNEL for radix tree and if
fgp_flags doesn't contain FGP_NOFS (mostly controlled by fs by
AOP_FLAG_NOFS flag) but the mapping_gfp_mask has __GFP_FS cleared then
the radix tree allocation wouldn't obey the restriction and might
recurse into filesystem and cause deadlocks. This is the case for most
filesystems unfortunately because only ext4 and gfs2 are using
AOP_FLAG_NOFS.
Let's simply remove radix_gfp_mask parameter because the allocation
context is same for both page cache and for the radix tree. Just make
sure that the radix tree gets only the sane subset of the mask (e.g. do
not pass __GFP_WRITE).
Long term it is more preferable to convert remaining users of
AOP_FLAG_NOFS to use mapping_gfp_mask instead and simplify this
interface even further.
Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/pagemap.h | 13 ++++++-------
mm/filemap.c | 29 ++++++++++++-----------------
2 files changed, 18 insertions(+), 24 deletions(-)
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -251,7 +251,7 @@ pgoff_t page_cache_prev_hole(struct addr
#define FGP_NOWAIT 0x00000020
struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
- int fgp_flags, gfp_t cache_gfp_mask, gfp_t radix_gfp_mask);
+ int fgp_flags, gfp_t cache_gfp_mask);
/**
* find_get_page - find and get a page reference
@@ -266,13 +266,13 @@ struct page *pagecache_get_page(struct a
static inline struct page *find_get_page(struct address_space *mapping,
pgoff_t offset)
{
- return pagecache_get_page(mapping, offset, 0, 0, 0);
+ return pagecache_get_page(mapping, offset, 0, 0);
}
static inline struct page *find_get_page_flags(struct address_space *mapping,
pgoff_t offset, int fgp_flags)
{
- return pagecache_get_page(mapping, offset, fgp_flags, 0, 0);
+ return pagecache_get_page(mapping, offset, fgp_flags, 0);
}
/**
@@ -292,7 +292,7 @@ static inline struct page *find_get_page
static inline struct page *find_lock_page(struct address_space *mapping,
pgoff_t offset)
{
- return pagecache_get_page(mapping, offset, FGP_LOCK, 0, 0);
+ return pagecache_get_page(mapping, offset, FGP_LOCK, 0);
}
/**
@@ -319,7 +319,7 @@ static inline struct page *find_or_creat
{
return pagecache_get_page(mapping, offset,
FGP_LOCK|FGP_ACCESSED|FGP_CREAT,
- gfp_mask, gfp_mask & GFP_RECLAIM_MASK);
+ gfp_mask);
}
/**
@@ -340,8 +340,7 @@ static inline struct page *grab_cache_pa
{
return pagecache_get_page(mapping, index,
FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
- mapping_gfp_mask(mapping),
- GFP_NOFS);
+ mapping_gfp_mask(mapping));
}
struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1046,8 +1046,7 @@ EXPORT_SYMBOL(find_lock_entry);
* @mapping: the address_space to search
* @offset: the page index
* @fgp_flags: PCG flags
- * @cache_gfp_mask: gfp mask to use for the page cache data page allocation
- * @radix_gfp_mask: gfp mask to use for radix tree node allocation
+ * @gfp_mask: gfp mask to use for the page cache data page allocation
*
* Looks up the page cache slot at @mapping & @offset.
*
@@ -1056,11 +1055,9 @@ EXPORT_SYMBOL(find_lock_entry);
* FGP_ACCESSED: the page will be marked accessed
* FGP_LOCK: Page is return locked
* FGP_CREAT: If page is not present then a new page is allocated using
- * @cache_gfp_mask and added to the page cache and the VM's LRU
- * list. If radix tree nodes are allocated during page cache
- * insertion then @radix_gfp_mask is used. The page is returned
- * locked and with an increased refcount. Otherwise, %NULL is
- * returned.
+ * @gfp_mask and added to the page cache and the VM's LRU
+ * list. The page is returned locked and with an increased
+ * refcount. Otherwise, %NULL is returned.
*
* If FGP_LOCK or FGP_CREAT are specified then the function may sleep even
* if the GFP flags specified for FGP_CREAT are atomic.
@@ -1068,7 +1065,7 @@ EXPORT_SYMBOL(find_lock_entry);
* If there is a page cache page, it is returned with an increased refcount.
*/
struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
- int fgp_flags, gfp_t cache_gfp_mask, gfp_t radix_gfp_mask)
+ int fgp_flags, gfp_t gfp_mask)
{
struct page *page;
@@ -1105,13 +1102,11 @@ no_page:
if (!page && (fgp_flags & FGP_CREAT)) {
int err;
if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping))
- cache_gfp_mask |= __GFP_WRITE;
- if (fgp_flags & FGP_NOFS) {
- cache_gfp_mask &= ~__GFP_FS;
- radix_gfp_mask &= ~__GFP_FS;
- }
+ gfp_mask |= __GFP_WRITE;
+ if (fgp_flags & FGP_NOFS)
+ gfp_mask &= ~__GFP_FS;
- page = __page_cache_alloc(cache_gfp_mask);
+ page = __page_cache_alloc(gfp_mask);
if (!page)
return NULL;
@@ -1122,7 +1117,8 @@ no_page:
if (fgp_flags & FGP_ACCESSED)
__SetPageReferenced(page);
- err = add_to_page_cache_lru(page, mapping, offset, radix_gfp_mask);
+ err = add_to_page_cache_lru(page, mapping, offset,
+ gfp_mask & GFP_RECLAIM_MASK);
if (unlikely(err)) {
page_cache_release(page);
page = NULL;
@@ -2443,8 +2439,7 @@ struct page *grab_cache_page_write_begin
fgp_flags |= FGP_NOFS;
page = pagecache_get_page(mapping, index, fgp_flags,
- mapping_gfp_mask(mapping),
- GFP_KERNEL);
+ mapping_gfp_mask(mapping));
if (page)
wait_for_stable_page(page);
next prev parent reply other threads:[~2015-01-28 1:34 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 1:26 [PATCH 3.18 00/61] 3.18.5-stable review Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 01/61] can: dev: fix crtlmode_supported check Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 02/61] can: m_can: tag current CAN FD controllers as non-ISO Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 03/61] pinctrl: qcom: Dont iterate past end of function array Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 04/61] pinctrl: Fix two deadlocks Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 05/61] mfd: tps65218: Make INT[12] and STATUS registers volatile Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 06/61] mfd: tps65218: Make INT1 our status_base register Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 07/61] mfd: rtsx_usb: Fix runtime PM deadlock Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 08/61] libata: allow sata_sil24 to opt-out of tag ordered submission Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 09/61] libata: prevent HSM state change race between ISR and PIO Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 10/61] ALSA: usb-audio: Add mic volume fix quirk for Logitech Webcam C210 Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 11/61] workqueue: fix subtle pool management issue which can stall whole worker_pool Greg Kroah-Hartman
2015-01-28 1:51 ` Lai Jiangshan
2015-01-28 2:24 ` Tejun Heo
2015-01-28 3:15 ` Lai Jiangshan
2015-01-28 15:07 ` Tejun Heo
2015-01-28 17:54 ` Greg Kroah-Hartman
2015-01-29 20:33 ` Tejun Heo
2015-02-02 11:28 ` Luis Henriques
2015-01-28 1:26 ` [PATCH 3.18 12/61] scripts/recordmcount.pl: There is no -m32 gcc option on Super-H anymore Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 13/61] drm/i915: Ban Haswell from using RCS flips Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 14/61] drm/i915: Fix mutex->owner inspection race under DEBUG_MUTEXES Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 15/61] drm/radeon: add a dpm quirk list Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 16/61] drm/radeon: add si " Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 17/61] drm/radeon: use rv515_ring_start on r5xx Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 18/61] PCI: Pass bridge device, not bus, when updating bridge windows Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 19/61] PCI: Add pci_claim_bridge_resource() to clip window if necessary Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 20/61] PCI: Add pci_bus_clip_resource() to clip to fit upstream window Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 21/61] x86/PCI: Clip bridge windows to fit in upstream windows Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 22/61] PCI: Add flag for devices where we cant use bus reset Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 23/61] PCI: Mark Atheros AR93xx to avoid " Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 24/61] ipr: wait for aborted command responses Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 25/61] [media] cx23885: Split Hauppauge WinTV Starburst from HVR4400 card entry Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 26/61] [media] vb2: fix vb2_thread_stop race conditions Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 27/61] dm cache: share cache-metadata object across inactive and active DM tables Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 28/61] dm cache: fix problematic dual use of a single migration count variable Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 29/61] irqchip: omap-intc: Fix legacy DMA regression Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 30/61] time: settimeofday: Validate the values of tv from user Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 31/61] time: adjtimex: Validate the ADJ_FREQUENCY values Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 32/61] ARM: dts: imx25: Fix PWM "per" clocks Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 33/61] ARM: mvebu: completely disable hardware I/O coherency Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 34/61] bus: mvebu-mbus: fix support of MBus window 13 Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 35/61] fix deadlock in cifs_ioctl_clone() Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 36/61] irqchip: atmel-aic-common: Prevent clobbering of priority when changing IRQ type Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 37/61] x86, irq: Properly tag virtualization entry in /proc/interrupts Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 38/61] clocksource: exynos_mct: Fix bitmask regression for exynos4_mct_write Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 39/61] x86, hyperv: Mark the Hyper-V clocksource as being continuous Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 40/61] x86/tsc: Change Fast TSC calibration failed from error to info Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 41/61] x86, boot: Skip relocs when load address unchanged Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 42/61] KVM: x86: SYSENTER emulation is broken Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 43/61] KVM: x86: Fix of previously incomplete fix for CVE-2014-8480 Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 44/61] x86, tls, ldt: Stop checking lm in LDT_empty Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 45/61] x86, tls: Interpret an all-zero struct user_desc as "no segment" Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 46/61] x86/apic: Re-enable PCI_MSI support for non-SMP X86_32 Greg Kroah-Hartman
2015-01-28 1:26 ` [PATCH 3.18 47/61] sata_dwc_460ex: fix resource leak on error path Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 48/61] ahci_xgene: Fix the endianess issue in APM X-Gene SoC AHCI SATA controller driver Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 49/61] KEYS: close race between key lookup and freeing Greg Kroah-Hartman
2015-01-28 1:27 ` Greg Kroah-Hartman [this message]
2015-01-28 1:27 ` [PATCH 3.18 51/61] netfilter: nfnetlink: validate nfnetlink header from batch Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 52/61] netfilter: nf_tables: fix flush ruleset chain dependencies Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 53/61] netfilter: nfnetlink: relax strict multicast group check from netlink_bind Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 54/61] netfilter: conntrack: fix race between confirmation and flush Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 55/61] ipvs: uninitialized data with IP_VS_IPV6 Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 56/61] Revert "swiotlb-xen: pass dev_addr to swiotlb_tbl_unmap_single" Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 57/61] iwlwifi: mvm: add a flag to enable match found notification Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 58/61] ACPI / PM: Do not disable wakeup GPEs that have not been enabled Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 59/61] crypto: prefix module autoloading with "crypto-" Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 60/61] crypto: include crypto- module prefix in template Greg Kroah-Hartman
2015-01-28 1:27 ` [PATCH 3.18 61/61] crypto: add missing crypto module aliases Greg Kroah-Hartman
2015-01-28 14:15 ` [PATCH 3.18 00/61] 3.18.5-stable review Guenter Roeck
2015-01-28 17:55 ` Greg Kroah-Hartman
2015-01-28 16:50 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150128012642.386422859@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=david@fromorbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.cz \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).