DAX tracepoints, mm argument simplification
Subsystems (9)
v4 cover DAX tracepoints, mm argument simplification
Andrew,
This contains both my DAX tracepoint code and Dave Jiang's MM argument simplifications. Dave's code was written with my tracepoint code as a baseline, so it seemed simplest to keep them together in a single series.
This series is based on the v4.10-rc3-mmots-2017-01-09-17-08 snapshot. A working tree can be found here:
https://git.kernel.org/cgit/linux/kernel/git/zwisler/linux.git/log/?h=mmots_dax_tracepoint
Changes from the previous versions of these patches:
- Combined Dave's code and mine into a single series.
- Resolved some minor merge conflics in Dave's patches so they could be applied to the latest mmots snapshot.
- Added Reviewed-by and Acked-by tags to patches as appropriate.
My goal for this series is to get it merged for v4.11.
Thanks,
- Ross
Dave Jiang (2):
mm, dax: make pmd_fault() and friends to be the same as fault() mm, dax: move pmd_fault() to take only vmf parameter
Ross Zwisler (5):
tracing: add __print_flags_u64()
dax: add tracepoint infrastructure, PMD tracing
dax: update MAINTAINERS entries for FS DAX
dax: add tracepoints to dax_pmd_load_hole()
dax: add tracepoints to dax_pmd_insert_mapping()
MAINTAINERS | 5 +- drivers/dax/dax.c | 26 ++++--- fs/dax.c | 114 ++++++++++++++++-------------- fs/ext4/file.c | 13 ++-- fs/xfs/xfs_file.c | 15 ++-- include/linux/dax.h | 6 +- include/linux/mm.h | 28 +++++++- include/linux/pfn_t.h | 6 ++ include/linux/trace_events.h | 4 ++ include/trace/events/fs_dax.h | 156 ++++++++++++++++++++++++++++++++++++++++++ include/trace/trace_events.h | 11 +++ kernel/trace/trace_output.c | 38 ++++++++++ mm/memory.c | 11 ++- 13 files changed, 338 insertions(+), 95 deletions(-) create mode 100644 include/trace/events/fs_dax.h
Signature · 1 line
2.7.4
PATCH v4 1/7 tracing: add __print_flags_u64()
Add __print_flags_u64() and the helper trace_print_flags_seq_u64() in the same spirit as __print_symbolic_u64() and trace_print_symbols_seq_u64(). These functions allow us to print symbols associated with flags that are 64 bits wide even on 32 bit machines.
These will be used by the DAX code so that we can print the flags set in a pfn_t such as PFN_SG_CHAIN, PFN_SG_LAST, PFN_DEV and PFN_MAP.
Without this new function I was getting errors like the following when compiling for i386:
./include/linux/pfn_t.h:13:22: warning: large integer implicitly truncated to unsigned type [-Woverflow]
#define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1))
^
--- include/linux/trace_events.h | 4 ++++ include/trace/trace_events.h | 11 +++++++++++ kernel/trace/trace_output.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+)
include/linux/trace_events.h +4 -0
@@ -23,6 +23,10 @@ const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val, const struct trace_print_flags *symbol_array);#if BITS_PER_LONG ==32 +const char *trace_print_flags_seq_u64 (struct trace_seq *p,const char *delim, +unsigned long long flags, +const struct trace_print_flags_u64 *flag_array); +const char *trace_print_symbols_seq_u64 (struct trace_seq *p,unsigned long long val, const struct trace_print_flags_u64
include/trace/trace_events.h +11 -0
@@ -283,8 +283,16 @@ TRACE_MAKE_SYSTEM_STR();trace_print_symbols_seq (p, value, symbols); \ }) +#undef __print_flags_u64#undef __print_symbolic_u64#if BITS_PER_LONG ==32 +#define __print_flags_u64(flag, delim, flag_array...) \ + ({ \ + static const struct trace_print_flags_u64 __flags[] = \ + { flag_array, { -1, NULL } }; \ + trace_print_flags_seq_u64(p, delim, flag, __flags); \ + }) + #define __print_symbolic_u64(value, symbol_array...) \ ({ \ static const struct trace_print_flags_u64 symbols[] = \
@@ -292,6 +300,9 @@ TRACE_MAKE_SYSTEM_STR();trace_print_symbols_seq_u64 (p, value, symbols); \ })#else +#define __print_flags_u64(flag, delim, flag_array...) \ + __print_flags(flag, delim, flag_array) + #define __print_symbolic_u64(value, symbol_array...) \ __print_symbolic(value, symbol_array)#endif
kernel/trace/trace_output.c +38 -0
@@ -124,6 +124,44 @@ EXPORT_SYMBOL(trace_print_symbols_seq);#if BITS_PER_LONG ==32 const char * +trace_print_flags_seq_u64 (struct trace_seq *p,const char *delim, +unsigned long long flags, +const struct trace_print_flags_u64 *flag_array) +{ +unsigned long long mask; +const char *str; +const char *ret =trace_seq_buffer_ptr (p); +int i, first =1 ; + +for (i =0 ; flag_array[i].name && flags; i++) { + + mask = flag_array[i].mask; +if ((flags & mask) != mask) +continue ; + + str = flag_array[i].name; + flags &= ~mask; +if (!first && delim) +trace_seq_puts (p, delim); +else + first =0 ; +trace_seq_puts (p, str); + } + +/* check for left over flags */ +if (flags) { +if (!first && delim) +trace_seq_puts (p, delim); +trace_seq_printf (p,"0x%llx" , flags); + } + +trace_seq_putc (p,0 ); + +return ret; +} +EXPORT_SYMBOL (trace_print_flags_seq_u64); + +const char *trace_print_symbols_seq_u64 (struct trace_seq *p,unsigned long long val,const struct trace_print_flags_u64 *symbol_array) {
Signature · 1 line
2.7.4
PATCH v4 2/7 dax: add tracepoint infrastructure, PMD tracing
In reply to Ross ZwislerTracepoints are the standard way to capture debugging and tracing information in many parts of the kernel, including the XFS and ext4 filesystems. Create a tracepoint header for FS DAX and add the first DAX tracepoints to the PMD fault handler. This allows the tracing for DAX to be done in the same way as the filesystem tracing so that developers can look at them together and get a coherent idea of what the system is doing.
I added both an entry and exit tracepoint because future patches will add tracepoints to child functions of dax_iomap_pmd_fault() like dax_pmd_load_hole() and dax_pmd_insert_mapping(). We want those messages to be wrapped by the parent function tracepoints so the code flow is more easily understood. Having entry and exit tracepoints for faults also allows us to easily see what filesystems functions were called during the fault. These filesystem functions get executed via iomap_begin() and iomap_end() calls, for example, and will have their own tracepoints.
For PMD faults we primarily want to understand the type of mapping, the fault flags, the faulting address and whether it fell back to 4k faults. If it fell back to 4k faults the tracepoints should let us understand why.
I named the new tracepoint header file "fs_dax.h" to allow for device DAX to have its own separate tracing header in the same directory at some point.
Here is an example output for these events from a successful PMD fault:
big-1441 [005] .... 32.582758: xfs_filemap_pmd_fault: dev 259:0 ino0x1003
big-1441 [005] .... 32.582776: dax_pmd_fault: dev 259:0 ino 0x1003
shared WRITE|ALLOW_RETRY|KILLABLE|USER address 0x10505000 vm_start 0x10200000 vm_end 0x10700000 pgoff 0x200 max_pgoff 0x1400
big-1441 [005] .... 32.583292: dax_pmd_fault_done: dev 259:0 ino 0x1003
shared WRITE|ALLOW_RETRY|KILLABLE|USER address 0x10505000 vm_start 0x10200000 vm_end 0x10700000 pgoff 0x200 max_pgoff 0x1400 NOPAGE
--- fs/dax.c | 30 ++++++++++++------- include/linux/mm.h | 25 ++++++++++++++++ include/trace/events/fs_dax.h | 68 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 include/trace/events/fs_dax.h
fs/dax.c +20 -10
@@ -35,6 +35,9 @@#include <linux/iomap.h> #include "internal.h" +#define CREATE_TRACE_POINTS +#include <trace/events/fs_dax.h> +/* We choose 4096 entries - same as per-zone page wait tables */ #define DAX_WAIT_TABLE_BITS 12#define DAX_WAIT_TABLE_ENTRIES (1 << DAX_WAIT_TABLE_BITS)
@@ -1333,6 +1336,16 @@ int dax_iomap_pmd_fault(struct vm_area_struct *vma, unsigned long address,loff_t pos;int error; +/* +* Check whether offset isn't beyond end of file now. Caller is +* supposed to hold locks serializing us with truncate / punch hole so +* this is a reliable test. +*/ + pgoff =linear_page_index (vma, pmd_addr); + max_pgoff = (i_size_read (inode) -1 ) >>PAGE_SHIFT ; + +trace_dax_pmd_fault (inode, vma, address, flags, pgoff, max_pgoff,0 ); +/* Fall back to PTEs if we're going to COW */ if (write && !(vma->vm_flags &VM_SHARED )) goto fallback;
@@ -1343,16 +1356,10 @@ int dax_iomap_pmd_fault(struct vm_area_struct *vma, unsigned long address,if ((pmd_addr +PMD_SIZE ) > vma->vm_end) goto fallback; -/* -* Check whether offset isn't beyond end of file now. Caller is -* supposed to hold locks serializing us with truncate / punch hole so -* this is a reliable test. -*/ - pgoff =linear_page_index (vma, pmd_addr); - max_pgoff = (i_size_read (inode) -1 ) >>PAGE_SHIFT ; - -if (pgoff > max_pgoff) -return VM_FAULT_SIGBUS ; +if (pgoff > max_pgoff) { + result =VM_FAULT_SIGBUS ; + goto out; + }/* If the PMD would extend beyond the file size */ if ((pgoff |PG_PMD_COLOUR ) > max_pgoff)
@@ -1424,6 +1431,9 @@ int dax_iomap_pmd_fault(struct vm_area_struct *vma, unsigned long address,split_huge_pmd (vma, pmd, address);count_vm_event (THP_FAULT_FALLBACK ); } +out: +trace_dax_pmd_fault_done (inode, vma, address, flags, pgoff, max_pgoff, + result);return result; }EXPORT_SYMBOL_GPL (dax_iomap_pmd_fault);
include/linux/mm.h +25 -0
@@ -281,6 +281,17 @@ extern pgprot_t protection_map[16];#define FAULT_FLAG_REMOTE 0x80/* faulting for non current tsk/mm */ #define FAULT_FLAG_INSTRUCTION 0x100/* The fault was during an instruction fetch */ +#define FAULT_FLAG_TRACE \ + { FAULT_FLAG_WRITE, "WRITE" }, \ + { FAULT_FLAG_MKWRITE, "MKWRITE" }, \ + { FAULT_FLAG_ALLOW_RETRY, "ALLOW_RETRY" }, \ + { FAULT_FLAG_RETRY_NOWAIT, "RETRY_NOWAIT" }, \ + { FAULT_FLAG_KILLABLE, "KILLABLE" }, \ + { FAULT_FLAG_TRIED, "TRIED" }, \ + { FAULT_FLAG_USER, "USER" }, \ + { FAULT_FLAG_REMOTE, "REMOTE" }, \ + { FAULT_FLAG_INSTRUCTION, "INSTRUCTION" } +/* * vm_fault is filled by the the pagefault handler and passed to the vma's * ->fault function. The vma's ->fault is responsible for returning a bitmask
@@ -1107,6 +1118,20 @@ static inline void clear_page_pfmemalloc(struct page *page) VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ VM_FAULT_FALLBACK) +#define VM_FAULT_RESULT_TRACE \ + { VM_FAULT_OOM, "OOM" }, \ + { VM_FAULT_SIGBUS, "SIGBUS" }, \ + { VM_FAULT_MAJOR, "MAJOR" }, \ + { VM_FAULT_WRITE, "WRITE" }, \ + { VM_FAULT_HWPOISON, "HWPOISON" }, \ + { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \ + { VM_FAULT_SIGSEGV, "SIGSEGV" }, \ + { VM_FAULT_NOPAGE, "NOPAGE" }, \ + { VM_FAULT_LOCKED, "LOCKED" }, \ + { VM_FAULT_RETRY, "RETRY" }, \ + { VM_FAULT_FALLBACK, "FALLBACK" }, \ + { VM_FAULT_DONE_COW, "DONE_COW" } +/* Encode hstate index for a hwpoisoned large page */ #define VM_FAULT_SET_HINDEX (x) ((x) << 12)#define VM_FAULT_GET_HINDEX (x) (((x) >> 12) & 0xf)
include/trace/events/fs_dax.h new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 3/7 dax: update MAINTAINERS entries for FS DAX
In reply to Ross ZwislerAdd the new include/trace/events/fs_dax.h tracepoint header, the existing include/linux/dax.h header, update Matthew's email address and add myself as a maintainer for filesystem DAX.
--- MAINTAINERS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
MAINTAINERS +4 -1
@@ -3909,10 +3909,13 @@ S: Maintained F: drivers/i2c/busses/i2c-diolan-u2c.c DIRECT ACCESS (DAX) -M: Matthew Wilcox <willy-VuQAYsv1563Yd54FQh9/[email protected]> +M: Matthew Wilcox <[email protected]> +M: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/[email protected]> L: [email protected] S: Supported F: fs/dax.c +F: include/linux/dax.h +F: include/trace/events/fs_dax.h DIRECTORY NOTIFICATION (DNOTIFY) M: Eric Paris <[email protected]>
Signature · 1 line
2.7.4
PATCH v4 4/7 dax: add tracepoints to dax_pmd_load_hole()
In reply to Ross ZwislerAdd tracepoints to dax_pmd_load_hole(), following the same logging conventions as the tracepoints in dax_iomap_pmd_fault().
Here is an example PMD fault showing the new tracepoints:
read_big-1478 [004] .... 238.242188: xfs_filemap_pmd_fault: dev 259:0
ino 0x1003
read_big-1478 [004] .... 238.242191: dax_pmd_fault: dev 259:0 ino 0x1003
shared ALLOW_RETRY|KILLABLE|USER address 0x10400000 vm_start 0x10200000 vm_end 0x10600000 pgoff 0x200 max_pgoff 0x1400
read_big-1478 [004] .... 238.242390: dax_pmd_load_hole: dev 259:0 ino0x1003 shared address 0x10400000 zero_page ffffea0002c20000 radix_entry 0x1e
read_big-1478 [004] .... 238.242392: dax_pmd_fault_done: dev 259:0 ino0x1003 shared ALLOW_RETRY|KILLABLE|USER address 0x10400000 vm_start 0x10200000 vm_end 0x10600000 pgoff 0x200 max_pgoff 0x1400 NOPAGE
--- fs/dax.c | 14 ++++++++++---- include/trace/events/fs_dax.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-)
fs/dax.c +10 -4
@@ -1291,33 +1291,39 @@ static int dax_pmd_load_hole(struct vm_area_struct *vma, pmd_t *pmd, {struct address_space *mapping = vma->vm_file->f_mapping;unsigned long pmd_addr = address &PMD_MASK ; +struct inode *inode = mapping->host;struct page *zero_page; +void *ret =NULL ;spinlock_t *ptl;pmd_t pmd_entry; -void *ret; zero_page =mm_get_huge_zero_page (vma->vm_mm);if (unlikely (!zero_page)) -return VM_FAULT_FALLBACK ; + goto fallback; ret =dax_insert_mapping_entry (mapping, vmf, *entryp,0 ,RADIX_DAX_PMD |RADIX_DAX_HZP );if (IS_ERR (ret)) -return VM_FAULT_FALLBACK ; + goto fallback; *entryp = ret; ptl =pmd_lock (vma->vm_mm, pmd);if (!pmd_none (*pmd)) {spin_unlock (ptl); -return VM_FAULT_FALLBACK ; + goto fallback; } pmd_entry =mk_pmd (zero_page, vma->vm_page_prot); pmd_entry =pmd_mkhuge (pmd_entry);set_pmd_at (vma->vm_mm, pmd_addr, pmd, pmd_entry);spin_unlock (ptl); +trace_dax_pmd_load_hole (inode, vma, address, zero_page, ret);return VM_FAULT_NOPAGE ; + +fallback: +trace_dax_pmd_load_hole_fallback (inode, vma, address, zero_page, ret); +return VM_FAULT_FALLBACK ; } int dax_iomap_pmd_fault(struct vm_area_struct *vma, unsigned long address,
include/trace/events/fs_dax.h +42 -0
48 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 5/7 dax: add tracepoints to dax_pmd_insert_mapping()
In reply to Ross ZwislerAdd tracepoints to dax_pmd_insert_mapping(), following the same logging conventions as the tracepoints in dax_iomap_pmd_fault().
Here is an example PMD fault showing the new tracepoints:
big-1504 [001] .... 326.960743: xfs_filemap_pmd_fault: dev 259:0 ino0x1003
big-1504 [001] .... 326.960753: dax_pmd_fault: dev 259:0 ino 0x1003
shared WRITE|ALLOW_RETRY|KILLABLE|USER address 0x10505000 vm_start 0x10200000 vm_end 0x10700000 pgoff 0x200 max_pgoff 0x1400
big-1504 [001] .... 326.960981: dax_pmd_insert_mapping: dev 259:0 ino0x1003 shared write address 0x10505000 length 0x200000 pfn 0x100600 DEV|MAP radix_entry 0xc000e
big-1504 [001] .... 326.960986: dax_pmd_fault_done: dev 259:0 ino 0x1003
shared WRITE|ALLOW_RETRY|KILLABLE|USER address 0x10505000 vm_start 0x10200000 vm_end 0x10700000 pgoff 0x200 max_pgoff 0x1400 NOPAGE
--- fs/dax.c | 12 +++++++--- include/linux/pfn_t.h | 6 +++++ include/trace/events/fs_dax.h | 51 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-)
fs/dax.c +9 -3
@@ -1254,15 +1254,16 @@ static int dax_pmd_insert_mapping(struct vm_area_struct *vma, pmd_t *pmd, {struct address_space *mapping = vma->vm_file->f_mapping;struct block_device *bdev = iomap->bdev; +struct inode *inode = mapping->host;struct blk_dax_ctl dax = { .sector =dax_iomap_sector (iomap, pos), .size =PMD_SIZE , };long length =dax_map_atomic (bdev, &dax); -void *ret; +void *ret =NULL ;if (length <0 )/* dax_map_atomic() failed */ -return VM_FAULT_FALLBACK ; + goto fallback;if (length <PMD_SIZE ) goto unmap_fallback;if (pfn_t_to_pfn (dax.pfn) &PG_PMD_COLOUR )
@@ -1275,13 +1276,18 @@ static int dax_pmd_insert_mapping(struct vm_area_struct *vma, pmd_t *pmd, ret =dax_insert_mapping_entry (mapping, vmf, *entryp, dax.sector,RADIX_DAX_PMD );if (IS_ERR (ret)) -return VM_FAULT_FALLBACK ; + goto fallback; *entryp = ret; +trace_dax_pmd_insert_mapping (inode, vma, address, write, length, + dax.pfn, ret);return vmf_insert_pfn_pmd (vma, address, pmd, dax.pfn, write); unmap_fallback:dax_unmap_atomic (bdev, &dax); +fallback: +trace_dax_pmd_insert_mapping_fallback (inode, vma, address, write, + length, dax.pfn, ret);return VM_FAULT_FALLBACK ; }
include/linux/pfn_t.h +6 -0
@@ -15,6 +15,12 @@#define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))#define PFN_MAP (1ULL << (BITS_PER_LONG_LONG - 4)) +#define PFN_FLAGS_TRACE \ + { PFN_SG_CHAIN, "SG_CHAIN" }, \ + { PFN_SG_LAST, "SG_LAST" }, \ + { PFN_DEV, "DEV" }, \ + { PFN_MAP, "MAP" } +static inline pfn_t __pfn_to_pfn_t (unsigned long pfn,u64 flags) {pfn_t pfn_t = { .val = pfn | (flags &PFN_FLAGS_MASK ), };
include/trace/events/fs_dax.h +51 -0
57 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 6/7 mm, dax: make pmd_fault() and friends to be the same as fault()
In reply to Ross ZwislerFrom: Dave Jiang <[email protected]>
Instead of passing in multiple parameters in the pmd_fault() handler, a vmf can be passed in just like a fault() handler. This will simplify code and remove the need for the actual pmd fault handlers to allocate a vmf. Related functions are also modified to do the same.
--- drivers/dax/dax.c | 16 +++++++--------- fs/dax.c | 42 ++++++++++++++++++------------------------ fs/ext4/file.c | 9 ++++----- fs/xfs/xfs_file.c | 10 ++++------ include/linux/dax.h | 7 +++---- include/linux/mm.h | 3 +-- include/trace/events/fs_dax.h | 15 +++++++-------- mm/memory.c | 6 ++---- 8 files changed, 46 insertions(+), 62 deletions(-)
drivers/dax/dax.c +7 -9
@@ -473,10 +473,9 @@ static int dax_dev_fault(struct vm_area_struct *vma, struct vm_fault *vmf) }static int __dax_dev_pmd_fault (struct dax_dev *dax_dev, -struct vm_area_struct *vma,unsigned long addr,pmd_t *pmd, -unsigned int flags) +struct vm_area_struct *vma,struct vm_fault *vmf) { -unsigned long pmd_addr = addr &PMD_MASK ; +unsigned long pmd_addr = vmf->address &PMD_MASK ;struct device *dev = &dax_dev->dev;struct dax_region *dax_region;phys_addr_t phys;
@@ -508,23 +507,22 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev, pfn =phys_to_pfn_t (phys, dax_region->pfn_flags); -return vmf_insert_pfn_pmd (vma, addr, pmd, pfn, - flags &FAULT_FLAG_WRITE ); +return vmf_insert_pfn_pmd (vma, vmf->address, vmf->pmd, pfn, + vmf->flags &FAULT_FLAG_WRITE ); } -static int dax_dev_pmd_fault (struct vm_area_struct *vma,unsigned long addr, -pmd_t *pmd,unsigned int flags) +static int dax_dev_pmd_fault (struct vm_area_struct *vma,struct vm_fault *vmf) {int rc;struct file *filp = vma->vm_file;struct dax_dev *dax_dev = filp->private_data;dev_dbg (&dax_dev->dev,"%s: %s: %s (%#lx - %#lx)\n" , __func__, - current->comm, (flags &FAULT_FLAG_WRITE ) + current->comm, (vmf->flags &FAULT_FLAG_WRITE ) ?"write" :"read" , vma->vm_start, vma->vm_end);rcu_read_lock (); - rc =__dax_dev_pmd_fault (dax_dev, vma, addr, pmd, flags); + rc =__dax_dev_pmd_fault (dax_dev, vma, vmf);rcu_read_unlock ();return rc;
fs/dax.c +18 -24
110 lines not on this page · raw message
fs/ext4/file.c +4 -5
@@ -275,21 +275,20 @@ static int ext4_dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf)return result; } -static int ext4_dax_pmd_fault (struct vm_area_struct *vma,unsigned long addr, -pmd_t *pmd,unsigned int flags) +static int +ext4_dax_pmd_fault (struct vm_area_struct *vma,struct vm_fault *vmf) {int result;struct inode *inode =file_inode (vma->vm_file);struct super_block *sb = inode->i_sb; -bool write = flags &FAULT_FLAG_WRITE ; +bool write = vmf->flags &FAULT_FLAG_WRITE ;if (write) {sb_start_pagefault (sb);file_update_time (vma->vm_file); }down_read (&EXT4_I (inode)->i_mmap_sem); - result =dax_iomap_pmd_fault (vma, addr, pmd, flags, - &ext4_iomap_ops); + result =dax_iomap_pmd_fault (vma, vmf, &ext4_iomap_ops);up_read (&EXT4_I (inode)->i_mmap_sem);if (write)sb_end_pagefault (sb);
fs/xfs/xfs_file.c +4 -6
@@ -1432,9 +1432,7 @@ xfs_filemap_fault( STATIC intxfs_filemap_pmd_fault (struct vm_area_struct *vma, -unsigned long addr, -pmd_t *pmd, -unsigned int flags) +struct vm_fault *vmf) {struct inode *inode =file_inode (vma->vm_file);struct xfs_inode *ip =XFS_I (inode);
@@ -1445,16 +1443,16 @@ xfs_filemap_pmd_fault(trace_xfs_filemap_pmd_fault (ip); -if (flags &FAULT_FLAG_WRITE ) { +if (vmf->flags &FAULT_FLAG_WRITE ) {sb_start_pagefault (inode->i_sb);file_update_time (vma->vm_file); }xfs_ilock (XFS_I (inode),XFS_MMAPLOCK_SHARED ); - ret =dax_iomap_pmd_fault (vma, addr, pmd, flags, &xfs_iomap_ops); + ret =dax_iomap_pmd_fault (vma, vmf, &xfs_iomap_ops);xfs_iunlock (XFS_I (inode),XFS_MMAPLOCK_SHARED ); -if (flags &FAULT_FLAG_WRITE ) +if (vmf->flags &FAULT_FLAG_WRITE )sb_end_pagefault (inode->i_sb);return ret;
include/linux/dax.h +3 -4
@@ -71,16 +71,15 @@ static inline unsigned int dax_radix_order(void *entry)return PMD_SHIFT -PAGE_SHIFT ; return 0; } -int dax_iomap_pmd_fault (struct vm_area_struct *vma,unsigned long address, -pmd_t *pmd,unsigned int flags,struct iomap_ops *ops); +int dax_iomap_pmd_fault (struct vm_area_struct *vma,struct vm_fault *vmf, +struct iomap_ops *ops);#else static inline unsigned int dax_radix_order (void *entry) {return 0 ; }static inline int dax_iomap_pmd_fault (struct vm_area_struct *vma, -unsigned long address,pmd_t *pmd,unsigned int flags, -struct iomap_ops *ops) +struct vm_fault *vmf,struct iomap_ops *ops) {return VM_FAULT_FALLBACK ; }
include/linux/mm.h +1 -2
@@ -347,8 +347,7 @@ struct vm_operations_struct {void (*close)(struct vm_area_struct * area);int (*mremap)(struct vm_area_struct * area);int (*fault)(struct vm_area_struct *vma,struct vm_fault *vmf); -int (*pmd_fault)(struct vm_area_struct *,unsigned long address, -pmd_t *,unsigned int flags); +int (*pmd_fault)(struct vm_area_struct *vma,struct vm_fault *vmf);void (*map_pages)(struct vm_fault *vmf,pgoff_t start_pgoff,pgoff_t end_pgoff);
include/trace/events/fs_dax.h +7 -8
@@ -8,9 +8,8 @@ DECLARE_EVENT_CLASS(dax_pmd_fault_class, TP_PROTO(struct inode *inode, struct vm_area_struct *vma, - unsigned long address, unsigned int flags, pgoff_t pgoff, - pgoff_t max_pgoff, int result), - TP_ARGS(inode, vma, address, flags, pgoff, max_pgoff, result), + struct vm_fault *vmf, pgoff_t max_pgoff, int result), + TP_ARGS(inode, vma, vmf, max_pgoff, result), TP_STRUCT__entry( __field(unsigned long, ino) __field(unsigned long, vm_start)
@@ -29,9 +28,9 @@ DECLARE_EVENT_CLASS(dax_pmd_fault_class, __entry->vm_start = vma->vm_start; __entry->vm_end = vma->vm_end; __entry->vm_flags = vma->vm_flags; - __entry->address = address; - __entry->flags = flags; - __entry->pgoff = pgoff; + __entry->address = vmf->address; + __entry->flags = vmf->flags; + __entry->pgoff = vmf->pgoff; __entry->max_pgoff = max_pgoff; __entry->result = result; ),
@@ -54,9 +53,9 @@ DECLARE_EVENT_CLASS(dax_pmd_fault_class,#define DEFINE_PMD_FAULT_EVENT (name) \ DEFINE_EVENT(dax_pmd_fault_class, name, \ TP_PROTO(struct inode *inode, struct vm_area_struct *vma, \ - unsigned long address, unsigned int flags, pgoff_t pgoff, \ + struct vm_fault *vmf, \ pgoff_t max_pgoff, int result), \ - TP_ARGS(inode, vma, address, flags, pgoff, max_pgoff, result)) + TP_ARGS(inode, vma, vmf, max_pgoff, result))DEFINE_PMD_FAULT_EVENT (dax_pmd_fault);DEFINE_PMD_FAULT_EVENT (dax_pmd_fault_done);
mm/memory.c +2 -4
@@ -3475,8 +3475,7 @@ static int create_huge_pmd(struct vm_fault *vmf)if (vma_is_anonymous (vma))return do_huge_pmd_anonymous_page (vmf);if (vma->vm_ops->pmd_fault) -return vma->vm_ops->pmd_fault (vma, vmf->address, vmf->pmd, - vmf->flags); +return vma->vm_ops->pmd_fault (vma, vmf);return VM_FAULT_FALLBACK ; }
@@ -3485,8 +3484,7 @@ static int wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)if (vma_is_anonymous (vmf->vma))return do_huge_pmd_wp_page (vmf, orig_pmd);if (vmf->vma->vm_ops->pmd_fault) -return vmf->vma->vm_ops->pmd_fault (vmf->vma, vmf->address, - vmf->pmd, vmf->flags); +return vmf->vma->vm_ops->pmd_fault (vmf->vma, vmf);/* COW handled on pte level: split pmd */ VM_BUG_ON_VMA (vmf->vma->vm_flags &VM_SHARED , vmf->vma);
Signature · 1 line
2.7.4
PATCH v4 7/7 mm, dax: move pmd_fault() to take only vmf parameter
In reply to Ross ZwislerFrom: Dave Jiang <[email protected]>
pmd_fault() and related functions really only need the vmf parameter since the additional parameters are all included in the vmf struct. Removing additional parameter and simplify pmd_fault() and friends.
--- drivers/dax/dax.c | 18 +++++++-------- fs/dax.c | 54 ++++++++++++++++++++----------------------- fs/ext4/file.c | 8 +++---- fs/xfs/xfs_file.c | 7 +++--- include/linux/dax.h | 7 +++--- include/linux/mm.h | 2 +- include/trace/events/fs_dax.h | 54 ++++++++++++++++++++----------------------- mm/memory.c | 9 ++++---- 8 files changed, 74 insertions(+), 85 deletions(-)
drivers/dax/dax.c +9 -9
@@ -472,8 +472,7 @@ static int dax_dev_fault(struct vm_area_struct *vma, struct vm_fault *vmf)return rc; } -static int __dax_dev_pmd_fault (struct dax_dev *dax_dev, -struct vm_area_struct *vma,struct vm_fault *vmf) +static int __dax_dev_pmd_fault (struct dax_dev *dax_dev,struct vm_fault *vmf) {unsigned long pmd_addr = vmf->address &PMD_MASK ;struct device *dev = &dax_dev->dev;
@@ -482,7 +481,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,pgoff_t pgoff;pfn_t pfn; -if (check_vma (dax_dev, vma, __func__)) +if (check_vma (dax_dev, vmf->vma, __func__))return VM_FAULT_SIGBUS ; dax_region = dax_dev->region;
@@ -497,7 +496,7 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev,return VM_FAULT_SIGBUS ; } - pgoff =linear_page_index (vma, pmd_addr); + pgoff =linear_page_index (vmf->vma, pmd_addr); phys =pgoff_to_phys (dax_dev, pgoff,PMD_SIZE );if (phys ==-1 ) { dev_dbg(dev, "%s: phys_to_pgoff(%#lx) failed\n", __func__,
@@ -507,22 +506,23 @@ static int __dax_dev_pmd_fault(struct dax_dev *dax_dev, pfn =phys_to_pfn_t (phys, dax_region->pfn_flags); -return vmf_insert_pfn_pmd (vma, vmf->address, vmf->pmd, pfn, +return vmf_insert_pfn_pmd (vmf->vma, vmf->address, vmf->pmd, pfn, vmf->flags &FAULT_FLAG_WRITE ); } -static int dax_dev_pmd_fault (struct vm_area_struct *vma,struct vm_fault *vmf) +static int dax_dev_pmd_fault (struct vm_fault *vmf) {int rc; -struct file *filp = vma->vm_file; +struct file *filp = vmf->vma->vm_file;struct dax_dev *dax_dev = filp->private_data;dev_dbg (&dax_dev->dev,"%s: %s: %s (%#lx - %#lx)\n" , __func__, current->comm, (vmf->flags &FAULT_FLAG_WRITE ) - ?"write" :"read" , vma->vm_start, vma->vm_end); + ?"write" :"read" , + vmf->vma->vm_start, vmf->vma->vm_end);rcu_read_lock (); - rc =__dax_dev_pmd_fault (dax_dev, vma, vmf); + rc =__dax_dev_pmd_fault (dax_dev, vmf);rcu_read_unlock ();return rc;
fs/dax.c +25 -29
123 lines not on this page · raw message
fs/ext4/file.c +4 -4
@@ -276,19 +276,19 @@ static int ext4_dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf) }static int -ext4_dax_pmd_fault (struct vm_area_struct *vma,struct vm_fault *vmf) +ext4_dax_pmd_fault (struct vm_fault *vmf) {int result; -struct inode *inode =file_inode (vma->vm_file); +struct inode *inode =file_inode (vmf->vma->vm_file);struct super_block *sb = inode->i_sb;bool write = vmf->flags &FAULT_FLAG_WRITE ;if (write) {sb_start_pagefault (sb); -file_update_time (vma->vm_file); +file_update_time (vmf->vma->vm_file); }down_read (&EXT4_I (inode)->i_mmap_sem); - result =dax_iomap_pmd_fault (vma, vmf, &ext4_iomap_ops); + result =dax_iomap_pmd_fault (vmf, &ext4_iomap_ops);up_read (&EXT4_I (inode)->i_mmap_sem);if (write)sb_end_pagefault (sb);
fs/xfs/xfs_file.c +3 -4
@@ -1431,10 +1431,9 @@ xfs_filemap_fault(*/ STATIC intxfs_filemap_pmd_fault ( -struct vm_area_struct *vma,struct vm_fault *vmf) { -struct inode *inode =file_inode (vma->vm_file); +struct inode *inode =file_inode (vmf->vma->vm_file);struct xfs_inode *ip =XFS_I (inode);int ret;
@@ -1445,11 +1444,11 @@ xfs_filemap_pmd_fault(if (vmf->flags &FAULT_FLAG_WRITE ) {sb_start_pagefault (inode->i_sb); -file_update_time (vma->vm_file); +file_update_time (vmf->vma->vm_file); }xfs_ilock (XFS_I (inode),XFS_MMAPLOCK_SHARED ); - ret =dax_iomap_pmd_fault (vma, vmf, &xfs_iomap_ops); + ret =dax_iomap_pmd_fault (vmf, &xfs_iomap_ops);xfs_iunlock (XFS_I (inode),XFS_MMAPLOCK_SHARED );if (vmf->flags &FAULT_FLAG_WRITE )
include/linux/dax.h +3 -4
@@ -71,15 +71,14 @@ static inline unsigned int dax_radix_order(void *entry)return PMD_SHIFT -PAGE_SHIFT ; return 0; } -int dax_iomap_pmd_fault (struct vm_area_struct *vma,struct vm_fault *vmf, -struct iomap_ops *ops); +int dax_iomap_pmd_fault (struct vm_fault *vmf,struct iomap_ops *ops);#else static inline unsigned int dax_radix_order (void *entry) {return 0 ; } -static inline int dax_iomap_pmd_fault (struct vm_area_struct *vma, -struct vm_fault *vmf,struct iomap_ops *ops) +static inline int dax_iomap_pmd_fault (struct vm_fault *vmf, +struct iomap_ops *ops) {return VM_FAULT_FALLBACK ; }
include/linux/mm.h +1 -1
@@ -347,7 +347,7 @@ struct vm_operations_struct {void (*close)(struct vm_area_struct * area);int (*mremap)(struct vm_area_struct * area);int (*fault)(struct vm_area_struct *vma,struct vm_fault *vmf); -int (*pmd_fault)(struct vm_area_struct *vma,struct vm_fault *vmf); +int (*pmd_fault)(struct vm_fault *vmf);void (*map_pages)(struct vm_fault *vmf,pgoff_t start_pgoff,pgoff_t end_pgoff);
include/trace/events/fs_dax.h +25 -29
108 lines not on this page · raw message
mm/memory.c +4 -5
@@ -3471,11 +3471,10 @@ static int do_numa_page(struct vm_fault *vmf)static int create_huge_pmd (struct vm_fault *vmf) { -struct vm_area_struct *vma = vmf->vma; -if (vma_is_anonymous (vma)) +if (vma_is_anonymous (vmf->vma))return do_huge_pmd_anonymous_page (vmf); -if (vma->vm_ops->pmd_fault) -return vma->vm_ops->pmd_fault (vma, vmf); +if (vmf->vma->vm_ops->pmd_fault) +return vmf->vma->vm_ops->pmd_fault (vmf);return VM_FAULT_FALLBACK ; }
@@ -3484,7 +3483,7 @@ static int wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)if (vma_is_anonymous (vmf->vma))return do_huge_pmd_wp_page (vmf, orig_pmd);if (vmf->vma->vm_ops->pmd_fault) -return vmf->vma->vm_ops->pmd_fault (vmf->vma, vmf); +return vmf->vma->vm_ops->pmd_fault (vmf);/* COW handled on pte level: split pmd */ VM_BUG_ON_VMA (vmf->vma->vm_flags &VM_SHARED , vmf->vma);
Signature · 1 line
2.7.4