Commit 8978fa2c authored by Nathan Scott's avatar Nathan Scott Committed by Linus Torvalds

[XFS] Low memory allocation improvements (quietness and blockdev

congestion checks).

SGI-PV: 914873
SGI-Modid: xfs-linux:xfs-kern:20564a
Signed-off-by: default avatarMiquel van Smoorenburg <miquels@cistron.net>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent ba3afcc7
......@@ -35,6 +35,7 @@
#include <linux/vmalloc.h>
#include <linux/highmem.h>
#include <linux/swap.h>
#include <linux/blkdev.h>
#include "time.h"
#include "kmem.h"
......@@ -46,7 +47,8 @@
void *
kmem_alloc(size_t size, int flags)
{
int retries = 0, lflags = kmem_flags_convert(flags);
int retries = 0;
int lflags = kmem_flags_convert(flags);
void *ptr;
do {
......@@ -57,8 +59,10 @@ kmem_alloc(size_t size, int flags)
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
printk(KERN_ERR "possible deadlock in %s (mode:0x%x)\n",
printk(KERN_ERR "XFS: possible memory allocation "
"deadlock in %s (mode:0x%x)\n",
__FUNCTION__, lflags);
blk_congestion_wait(WRITE, HZ/50);
} while (1);
}
......@@ -102,7 +106,8 @@ kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags)
void *
kmem_zone_alloc(kmem_zone_t *zone, int flags)
{
int retries = 0, lflags = kmem_flags_convert(flags);
int retries = 0;
int lflags = kmem_flags_convert(flags);
void *ptr;
do {
......@@ -110,8 +115,10 @@ kmem_zone_alloc(kmem_zone_t *zone, int flags)
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
printk(KERN_ERR "possible deadlock in %s (mode:0x%x)\n",
printk(KERN_ERR "XFS: possible memory allocation "
"deadlock in %s (mode:0x%x)\n",
__FUNCTION__, lflags);
blk_congestion_wait(WRITE, HZ/50);
} while (1);
}
......
......@@ -83,7 +83,7 @@ typedef unsigned long xfs_pflags_t;
static __inline unsigned int kmem_flags_convert(int flags)
{
int lflags;
int lflags = __GFP_NOWARN; /* we'll report problems, if need be */
#ifdef DEBUG
if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
......
......@@ -53,13 +53,10 @@
#include <linux/workqueue.h>
#include <linux/suspend.h>
#include <linux/percpu.h>
#include <linux/blkdev.h>
#include "xfs_linux.h"
#ifndef GFP_READAHEAD
#define GFP_READAHEAD (__GFP_NOWARN|__GFP_NORETRY)
#endif
/*
* File wide globals
*/
......@@ -118,8 +115,8 @@ ktrace_t *pagebuf_trace_buf;
*/
#define pb_to_gfp(flags) \
(((flags) & PBF_READ_AHEAD) ? GFP_READAHEAD : \
((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL)
((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \
((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN)
#define pb_to_km(flags) \
(((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
......@@ -387,13 +384,13 @@ _pagebuf_lookup_pages(
*/
if (!(++retries % 100))
printk(KERN_ERR
"possible deadlock in %s (mode:0x%x)\n",
"XFS: possible memory allocation "
"deadlock in %s (mode:0x%x)\n",
__FUNCTION__, gfp_mask);
XFS_STATS_INC(pb_page_retries);
pagebuf_daemon_wakeup(0, gfp_mask);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(10);
blk_congestion_wait(WRITE, HZ/50);
goto retry;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment