Commit 0e749e54 authored by Dan Williams's avatar Dan Williams Committed by Linus Torvalds

dax: increase granularity of dax_clear_blocks() operations

dax_clear_blocks is currently performing a cond_resched() after every
PAGE_SIZE memset.  We need not check so frequently, for example md-raid
only calls cond_resched() at stripe granularity.  Also, in preparation
for introducing a dax_map_atomic() operation that temporarily pins a dax
mapping move the call to cond_resched() to the outer loop.

The worst case latency between calls to cond_resched() after this change
is 500us the average latency is 133us.  This is up from a 10us max and
4us average.
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Reviewed-by: default avatarJan Kara <jack@suse.com>
Reviewed-by: default avatarJeff Moyer <jmoyer@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 52db400f
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/vmstat.h> #include <linux/vmstat.h>
#include <linux/sizes.h>
/* /*
* dax_clear_blocks() is called from within transaction context from XFS, * dax_clear_blocks() is called from within transaction context from XFS,
...@@ -43,24 +44,17 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size) ...@@ -43,24 +44,17 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)
do { do {
void __pmem *addr; void __pmem *addr;
unsigned long pfn; unsigned long pfn;
long count; long count, sz;
count = bdev_direct_access(bdev, sector, &addr, &pfn, size); count = bdev_direct_access(bdev, sector, &addr, &pfn, size);
if (count < 0) if (count < 0)
return count; return count;
BUG_ON(size < count); sz = min_t(long, count, SZ_128K);
while (count > 0) { clear_pmem(addr, sz);
unsigned pgsz = PAGE_SIZE - offset_in_page(addr); size -= sz;
if (pgsz > count) BUG_ON(sz & 511);
pgsz = count; sector += sz / 512;
clear_pmem(addr, pgsz); cond_resched();
addr += pgsz;
size -= pgsz;
count -= pgsz;
BUG_ON(pgsz & 511);
sector += pgsz / 512;
cond_resched();
}
} while (size); } while (size);
wmb_pmem(); wmb_pmem();
......
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