2 #include <linux/vmacache.h>
3 #include <linux/hugetlb.h>
4 #include <linux/huge_mm.h>
5 #include <linux/mount.h>
6 #include <linux/seq_file.h>
7 #include <linux/highmem.h>
8 #include <linux/ptrace.h>
9 #include <linux/slab.h>
10 #include <linux/pagemap.h>
11 #include <linux/mempolicy.h>
12 #include <linux/rmap.h>
13 #include <linux/swap.h>
14 #include <linux/swapops.h>
15 #include <linux/mmu_notifier.h>
18 #include <asm/uaccess.h>
19 #include <asm/tlbflush.h>
22 void task_mem(struct seq_file
*m
, struct mm_struct
*mm
)
24 unsigned long data
, text
, lib
, swap
, ptes
, pmds
;
25 unsigned long hiwater_vm
, total_vm
, hiwater_rss
, total_rss
;
28 * Note: to minimize their overhead, mm maintains hiwater_vm and
29 * hiwater_rss only when about to *lower* total_vm or rss. Any
30 * collector of these hiwater stats must therefore get total_vm
31 * and rss too, which will usually be the higher. Barriers? not
32 * worth the effort, such snapshots can always be inconsistent.
34 hiwater_vm
= total_vm
= mm
->total_vm
;
35 if (hiwater_vm
< mm
->hiwater_vm
)
36 hiwater_vm
= mm
->hiwater_vm
;
37 hiwater_rss
= total_rss
= get_mm_rss(mm
);
38 if (hiwater_rss
< mm
->hiwater_rss
)
39 hiwater_rss
= mm
->hiwater_rss
;
41 data
= mm
->total_vm
- mm
->shared_vm
- mm
->stack_vm
;
42 text
= (PAGE_ALIGN(mm
->end_code
) - (mm
->start_code
& PAGE_MASK
)) >> 10;
43 lib
= (mm
->exec_vm
<< (PAGE_SHIFT
-10)) - text
;
44 swap
= get_mm_counter(mm
, MM_SWAPENTS
);
45 ptes
= PTRS_PER_PTE
* sizeof(pte_t
) * atomic_long_read(&mm
->nr_ptes
);
46 pmds
= PTRS_PER_PMD
* sizeof(pmd_t
) * mm_nr_pmds(mm
);
61 hiwater_vm
<< (PAGE_SHIFT
-10),
62 total_vm
<< (PAGE_SHIFT
-10),
63 mm
->locked_vm
<< (PAGE_SHIFT
-10),
64 mm
->pinned_vm
<< (PAGE_SHIFT
-10),
65 hiwater_rss
<< (PAGE_SHIFT
-10),
66 total_rss
<< (PAGE_SHIFT
-10),
67 data
<< (PAGE_SHIFT
-10),
68 mm
->stack_vm
<< (PAGE_SHIFT
-10), text
, lib
,
71 swap
<< (PAGE_SHIFT
-10));
74 unsigned long task_vsize(struct mm_struct
*mm
)
76 return PAGE_SIZE
* mm
->total_vm
;
79 unsigned long task_statm(struct mm_struct
*mm
,
80 unsigned long *shared
, unsigned long *text
,
81 unsigned long *data
, unsigned long *resident
)
83 *shared
= get_mm_counter(mm
, MM_FILEPAGES
);
84 *text
= (PAGE_ALIGN(mm
->end_code
) - (mm
->start_code
& PAGE_MASK
))
86 *data
= mm
->total_vm
- mm
->shared_vm
;
87 *resident
= *shared
+ get_mm_counter(mm
, MM_ANONPAGES
);
93 * Save get_task_policy() for show_numa_map().
95 static void hold_task_mempolicy(struct proc_maps_private
*priv
)
97 struct task_struct
*task
= priv
->task
;
100 priv
->task_mempolicy
= get_task_policy(task
);
101 mpol_get(priv
->task_mempolicy
);
104 static void release_task_mempolicy(struct proc_maps_private
*priv
)
106 mpol_put(priv
->task_mempolicy
);
109 static void hold_task_mempolicy(struct proc_maps_private
*priv
)
112 static void release_task_mempolicy(struct proc_maps_private
*priv
)
117 static void vma_stop(struct proc_maps_private
*priv
)
119 struct mm_struct
*mm
= priv
->mm
;
121 release_task_mempolicy(priv
);
122 up_read(&mm
->mmap_sem
);
126 static struct vm_area_struct
*
127 m_next_vma(struct proc_maps_private
*priv
, struct vm_area_struct
*vma
)
129 if (vma
== priv
->tail_vma
)
131 return vma
->vm_next
?: priv
->tail_vma
;
134 static void m_cache_vma(struct seq_file
*m
, struct vm_area_struct
*vma
)
136 if (m
->count
< m
->size
) /* vma is copied successfully */
137 m
->version
= m_next_vma(m
->private, vma
) ? vma
->vm_start
: -1UL;
140 static void *m_start(struct seq_file
*m
, loff_t
*ppos
)
142 struct proc_maps_private
*priv
= m
->private;
143 unsigned long last_addr
= m
->version
;
144 struct mm_struct
*mm
;
145 struct vm_area_struct
*vma
;
146 unsigned int pos
= *ppos
;
148 /* See m_cache_vma(). Zero at the start or after lseek. */
149 if (last_addr
== -1UL)
152 priv
->task
= get_proc_task(priv
->inode
);
154 return ERR_PTR(-ESRCH
);
157 if (!mm
|| !atomic_inc_not_zero(&mm
->mm_users
))
160 down_read(&mm
->mmap_sem
);
161 hold_task_mempolicy(priv
);
162 priv
->tail_vma
= get_gate_vma(mm
);
165 vma
= find_vma(mm
, last_addr
);
166 if (vma
&& (vma
= m_next_vma(priv
, vma
)))
171 if (pos
< mm
->map_count
) {
172 for (vma
= mm
->mmap
; pos
; pos
--) {
173 m
->version
= vma
->vm_start
;
179 /* we do not bother to update m->version in this case */
180 if (pos
== mm
->map_count
&& priv
->tail_vma
)
181 return priv
->tail_vma
;
187 static void *m_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
189 struct proc_maps_private
*priv
= m
->private;
190 struct vm_area_struct
*next
;
193 next
= m_next_vma(priv
, v
);
199 static void m_stop(struct seq_file
*m
, void *v
)
201 struct proc_maps_private
*priv
= m
->private;
203 if (!IS_ERR_OR_NULL(v
))
206 put_task_struct(priv
->task
);
211 static int proc_maps_open(struct inode
*inode
, struct file
*file
,
212 const struct seq_operations
*ops
, int psize
)
214 struct proc_maps_private
*priv
= __seq_open_private(file
, ops
, psize
);
220 priv
->mm
= proc_mem_open(inode
, PTRACE_MODE_READ
);
221 if (IS_ERR(priv
->mm
)) {
222 int err
= PTR_ERR(priv
->mm
);
224 seq_release_private(inode
, file
);
231 static int proc_map_release(struct inode
*inode
, struct file
*file
)
233 struct seq_file
*seq
= file
->private_data
;
234 struct proc_maps_private
*priv
= seq
->private;
239 return seq_release_private(inode
, file
);
242 static int do_maps_open(struct inode
*inode
, struct file
*file
,
243 const struct seq_operations
*ops
)
245 return proc_maps_open(inode
, file
, ops
,
246 sizeof(struct proc_maps_private
));
249 static pid_t
pid_of_stack(struct proc_maps_private
*priv
,
250 struct vm_area_struct
*vma
, bool is_pid
)
252 struct inode
*inode
= priv
->inode
;
253 struct task_struct
*task
;
257 task
= pid_task(proc_pid(inode
), PIDTYPE_PID
);
259 task
= task_of_stack(task
, vma
, is_pid
);
261 ret
= task_pid_nr_ns(task
, inode
->i_sb
->s_fs_info
);
269 show_map_vma(struct seq_file
*m
, struct vm_area_struct
*vma
, int is_pid
)
271 struct mm_struct
*mm
= vma
->vm_mm
;
272 struct file
*file
= vma
->vm_file
;
273 struct proc_maps_private
*priv
= m
->private;
274 vm_flags_t flags
= vma
->vm_flags
;
275 unsigned long ino
= 0;
276 unsigned long long pgoff
= 0;
277 unsigned long start
, end
;
279 const char *name
= NULL
;
282 struct inode
*inode
= file_inode(vma
->vm_file
);
283 dev
= inode
->i_sb
->s_dev
;
285 pgoff
= ((loff_t
)vma
->vm_pgoff
) << PAGE_SHIFT
;
288 /* We don't show the stack guard page in /proc/maps */
289 start
= vma
->vm_start
;
290 if (stack_guard_page_start(vma
, start
))
293 if (stack_guard_page_end(vma
, end
))
296 seq_setwidth(m
, 25 + sizeof(void *) * 6 - 1);
297 seq_printf(m
, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
300 flags
& VM_READ
? 'r' : '-',
301 flags
& VM_WRITE
? 'w' : '-',
302 flags
& VM_EXEC
? 'x' : '-',
303 flags
& VM_MAYSHARE
? 's' : 'p',
305 MAJOR(dev
), MINOR(dev
), ino
);
308 * Print the dentry name for named mappings, and a
309 * special [heap] marker for the heap:
313 seq_file_path(m
, file
, "\n");
317 if (vma
->vm_ops
&& vma
->vm_ops
->name
) {
318 name
= vma
->vm_ops
->name(vma
);
323 name
= arch_vma_name(vma
);
332 if (vma
->vm_start
<= mm
->brk
&&
333 vma
->vm_end
>= mm
->start_brk
) {
338 tid
= pid_of_stack(priv
, vma
, is_pid
);
341 * Thread stack in /proc/PID/task/TID/maps or
342 * the main process stack.
344 if (!is_pid
|| (vma
->vm_start
<= mm
->start_stack
&&
345 vma
->vm_end
>= mm
->start_stack
)) {
348 /* Thread stack in /proc/PID/maps */
350 seq_printf(m
, "[stack:%d]", tid
);
363 static int show_map(struct seq_file
*m
, void *v
, int is_pid
)
365 show_map_vma(m
, v
, is_pid
);
370 static int show_pid_map(struct seq_file
*m
, void *v
)
372 return show_map(m
, v
, 1);
375 static int show_tid_map(struct seq_file
*m
, void *v
)
377 return show_map(m
, v
, 0);
380 static const struct seq_operations proc_pid_maps_op
= {
387 static const struct seq_operations proc_tid_maps_op
= {
394 static int pid_maps_open(struct inode
*inode
, struct file
*file
)
396 return do_maps_open(inode
, file
, &proc_pid_maps_op
);
399 static int tid_maps_open(struct inode
*inode
, struct file
*file
)
401 return do_maps_open(inode
, file
, &proc_tid_maps_op
);
404 const struct file_operations proc_pid_maps_operations
= {
405 .open
= pid_maps_open
,
408 .release
= proc_map_release
,
411 const struct file_operations proc_tid_maps_operations
= {
412 .open
= tid_maps_open
,
415 .release
= proc_map_release
,
419 * Proportional Set Size(PSS): my share of RSS.
421 * PSS of a process is the count of pages it has in memory, where each
422 * page is divided by the number of processes sharing it. So if a
423 * process has 1000 pages all to itself, and 1000 shared with one other
424 * process, its PSS will be 1500.
426 * To keep (accumulated) division errors low, we adopt a 64bit
427 * fixed-point pss counter to minimize division errors. So (pss >>
428 * PSS_SHIFT) would be the real byte count.
430 * A shift of 12 before division means (assuming 4K page size):
431 * - 1M 3-user-pages add up to 8KB errors;
432 * - supports mapcount up to 2^24, or 16M;
433 * - supports PSS up to 2^52 bytes, or 4PB.
437 #ifdef CONFIG_PROC_PAGE_MONITOR
438 struct mem_size_stats
{
439 unsigned long resident
;
440 unsigned long shared_clean
;
441 unsigned long shared_dirty
;
442 unsigned long private_clean
;
443 unsigned long private_dirty
;
444 unsigned long referenced
;
445 unsigned long anonymous
;
446 unsigned long anonymous_thp
;
451 static void smaps_account(struct mem_size_stats
*mss
, struct page
*page
,
452 unsigned long size
, bool young
, bool dirty
)
457 mss
->anonymous
+= size
;
459 mss
->resident
+= size
;
460 /* Accumulate the size in pages that have been accessed. */
461 if (young
|| PageReferenced(page
))
462 mss
->referenced
+= size
;
463 mapcount
= page_mapcount(page
);
467 if (dirty
|| PageDirty(page
))
468 mss
->shared_dirty
+= size
;
470 mss
->shared_clean
+= size
;
471 pss_delta
= (u64
)size
<< PSS_SHIFT
;
472 do_div(pss_delta
, mapcount
);
473 mss
->pss
+= pss_delta
;
475 if (dirty
|| PageDirty(page
))
476 mss
->private_dirty
+= size
;
478 mss
->private_clean
+= size
;
479 mss
->pss
+= (u64
)size
<< PSS_SHIFT
;
483 static void smaps_pte_entry(pte_t
*pte
, unsigned long addr
,
484 struct mm_walk
*walk
)
486 struct mem_size_stats
*mss
= walk
->private;
487 struct vm_area_struct
*vma
= walk
->vma
;
488 struct page
*page
= NULL
;
490 if (pte_present(*pte
)) {
491 page
= vm_normal_page(vma
, addr
, *pte
);
492 } else if (is_swap_pte(*pte
)) {
493 swp_entry_t swpent
= pte_to_swp_entry(*pte
);
495 if (!non_swap_entry(swpent
))
496 mss
->swap
+= PAGE_SIZE
;
497 else if (is_migration_entry(swpent
))
498 page
= migration_entry_to_page(swpent
);
503 smaps_account(mss
, page
, PAGE_SIZE
, pte_young(*pte
), pte_dirty(*pte
));
506 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
507 static void smaps_pmd_entry(pmd_t
*pmd
, unsigned long addr
,
508 struct mm_walk
*walk
)
510 struct mem_size_stats
*mss
= walk
->private;
511 struct vm_area_struct
*vma
= walk
->vma
;
514 /* FOLL_DUMP will return -EFAULT on huge zero page */
515 page
= follow_trans_huge_pmd(vma
, addr
, pmd
, FOLL_DUMP
);
516 if (IS_ERR_OR_NULL(page
))
518 mss
->anonymous_thp
+= HPAGE_PMD_SIZE
;
519 smaps_account(mss
, page
, HPAGE_PMD_SIZE
,
520 pmd_young(*pmd
), pmd_dirty(*pmd
));
523 static void smaps_pmd_entry(pmd_t
*pmd
, unsigned long addr
,
524 struct mm_walk
*walk
)
529 static int smaps_pte_range(pmd_t
*pmd
, unsigned long addr
, unsigned long end
,
530 struct mm_walk
*walk
)
532 struct vm_area_struct
*vma
= walk
->vma
;
536 if (pmd_trans_huge_lock(pmd
, vma
, &ptl
) == 1) {
537 smaps_pmd_entry(pmd
, addr
, walk
);
542 if (pmd_trans_unstable(pmd
))
545 * The mmap_sem held all the way back in m_start() is what
546 * keeps khugepaged out of here and from collapsing things
549 pte
= pte_offset_map_lock(vma
->vm_mm
, pmd
, addr
, &ptl
);
550 for (; addr
!= end
; pte
++, addr
+= PAGE_SIZE
)
551 smaps_pte_entry(pte
, addr
, walk
);
552 pte_unmap_unlock(pte
- 1, ptl
);
557 static void show_smap_vma_flags(struct seq_file
*m
, struct vm_area_struct
*vma
)
560 * Don't forget to update Documentation/ on changes.
562 static const char mnemonics
[BITS_PER_LONG
][2] = {
564 * In case if we meet a flag we don't know about.
566 [0 ... (BITS_PER_LONG
-1)] = "??",
568 [ilog2(VM_READ
)] = "rd",
569 [ilog2(VM_WRITE
)] = "wr",
570 [ilog2(VM_EXEC
)] = "ex",
571 [ilog2(VM_SHARED
)] = "sh",
572 [ilog2(VM_MAYREAD
)] = "mr",
573 [ilog2(VM_MAYWRITE
)] = "mw",
574 [ilog2(VM_MAYEXEC
)] = "me",
575 [ilog2(VM_MAYSHARE
)] = "ms",
576 [ilog2(VM_GROWSDOWN
)] = "gd",
577 [ilog2(VM_PFNMAP
)] = "pf",
578 [ilog2(VM_DENYWRITE
)] = "dw",
579 #ifdef CONFIG_X86_INTEL_MPX
580 [ilog2(VM_MPX
)] = "mp",
582 [ilog2(VM_LOCKED
)] = "lo",
583 [ilog2(VM_IO
)] = "io",
584 [ilog2(VM_SEQ_READ
)] = "sr",
585 [ilog2(VM_RAND_READ
)] = "rr",
586 [ilog2(VM_DONTCOPY
)] = "dc",
587 [ilog2(VM_DONTEXPAND
)] = "de",
588 [ilog2(VM_ACCOUNT
)] = "ac",
589 [ilog2(VM_NORESERVE
)] = "nr",
590 [ilog2(VM_HUGETLB
)] = "ht",
591 [ilog2(VM_ARCH_1
)] = "ar",
592 [ilog2(VM_DONTDUMP
)] = "dd",
593 #ifdef CONFIG_MEM_SOFT_DIRTY
594 [ilog2(VM_SOFTDIRTY
)] = "sd",
596 [ilog2(VM_MIXEDMAP
)] = "mm",
597 [ilog2(VM_HUGEPAGE
)] = "hg",
598 [ilog2(VM_NOHUGEPAGE
)] = "nh",
599 [ilog2(VM_MERGEABLE
)] = "mg",
600 [ilog2(VM_UFFD_MISSING
)]= "um",
601 [ilog2(VM_UFFD_WP
)] = "uw",
605 seq_puts(m
, "VmFlags: ");
606 for (i
= 0; i
< BITS_PER_LONG
; i
++) {
607 if (vma
->vm_flags
& (1UL << i
)) {
608 seq_printf(m
, "%c%c ",
609 mnemonics
[i
][0], mnemonics
[i
][1]);
615 static int show_smap(struct seq_file
*m
, void *v
, int is_pid
)
617 struct vm_area_struct
*vma
= v
;
618 struct mem_size_stats mss
;
619 struct mm_walk smaps_walk
= {
620 .pmd_entry
= smaps_pte_range
,
625 memset(&mss
, 0, sizeof mss
);
626 /* mmap_sem is held in m_start */
627 walk_page_vma(vma
, &smaps_walk
);
629 show_map_vma(m
, vma
, is_pid
);
635 "Shared_Clean: %8lu kB\n"
636 "Shared_Dirty: %8lu kB\n"
637 "Private_Clean: %8lu kB\n"
638 "Private_Dirty: %8lu kB\n"
639 "Referenced: %8lu kB\n"
640 "Anonymous: %8lu kB\n"
641 "AnonHugePages: %8lu kB\n"
643 "KernelPageSize: %8lu kB\n"
644 "MMUPageSize: %8lu kB\n"
646 (vma
->vm_end
- vma
->vm_start
) >> 10,
648 (unsigned long)(mss
.pss
>> (10 + PSS_SHIFT
)),
649 mss
.shared_clean
>> 10,
650 mss
.shared_dirty
>> 10,
651 mss
.private_clean
>> 10,
652 mss
.private_dirty
>> 10,
653 mss
.referenced
>> 10,
655 mss
.anonymous_thp
>> 10,
657 vma_kernel_pagesize(vma
) >> 10,
658 vma_mmu_pagesize(vma
) >> 10,
659 (vma
->vm_flags
& VM_LOCKED
) ?
660 (unsigned long)(mss
.pss
>> (10 + PSS_SHIFT
)) : 0);
662 show_smap_vma_flags(m
, vma
);
667 static int show_pid_smap(struct seq_file
*m
, void *v
)
669 return show_smap(m
, v
, 1);
672 static int show_tid_smap(struct seq_file
*m
, void *v
)
674 return show_smap(m
, v
, 0);
677 static const struct seq_operations proc_pid_smaps_op
= {
681 .show
= show_pid_smap
684 static const struct seq_operations proc_tid_smaps_op
= {
688 .show
= show_tid_smap
691 static int pid_smaps_open(struct inode
*inode
, struct file
*file
)
693 return do_maps_open(inode
, file
, &proc_pid_smaps_op
);
696 static int tid_smaps_open(struct inode
*inode
, struct file
*file
)
698 return do_maps_open(inode
, file
, &proc_tid_smaps_op
);
701 const struct file_operations proc_pid_smaps_operations
= {
702 .open
= pid_smaps_open
,
705 .release
= proc_map_release
,
708 const struct file_operations proc_tid_smaps_operations
= {
709 .open
= tid_smaps_open
,
712 .release
= proc_map_release
,
716 * We do not want to have constant page-shift bits sitting in
717 * pagemap entries and are about to reuse them some time soon.
719 * Here's the "migration strategy":
720 * 1. when the system boots these bits remain what they are,
721 * but a warning about future change is printed in log;
722 * 2. once anyone clears soft-dirty bits via clear_refs file,
723 * these flag is set to denote, that user is aware of the
724 * new API and those page-shift bits change their meaning.
725 * The respective warning is printed in dmesg;
726 * 3. In a couple of releases we will remove all the mentions
727 * of page-shift in pagemap entries.
730 static bool soft_dirty_cleared __read_mostly
;
732 enum clear_refs_types
{
736 CLEAR_REFS_SOFT_DIRTY
,
737 CLEAR_REFS_MM_HIWATER_RSS
,
741 struct clear_refs_private
{
742 enum clear_refs_types type
;
745 #ifdef CONFIG_MEM_SOFT_DIRTY
746 static inline void clear_soft_dirty(struct vm_area_struct
*vma
,
747 unsigned long addr
, pte_t
*pte
)
750 * The soft-dirty tracker uses #PF-s to catch writes
751 * to pages, so write-protect the pte as well. See the
752 * Documentation/vm/soft-dirty.txt for full description
753 * of how soft-dirty works.
757 if (pte_present(ptent
)) {
758 ptent
= pte_wrprotect(ptent
);
759 ptent
= pte_clear_flags(ptent
, _PAGE_SOFT_DIRTY
);
760 } else if (is_swap_pte(ptent
)) {
761 ptent
= pte_swp_clear_soft_dirty(ptent
);
764 set_pte_at(vma
->vm_mm
, addr
, pte
, ptent
);
767 static inline void clear_soft_dirty_pmd(struct vm_area_struct
*vma
,
768 unsigned long addr
, pmd_t
*pmdp
)
772 pmd
= pmd_wrprotect(pmd
);
773 pmd
= pmd_clear_flags(pmd
, _PAGE_SOFT_DIRTY
);
775 if (vma
->vm_flags
& VM_SOFTDIRTY
)
776 vma
->vm_flags
&= ~VM_SOFTDIRTY
;
778 set_pmd_at(vma
->vm_mm
, addr
, pmdp
, pmd
);
783 static inline void clear_soft_dirty(struct vm_area_struct
*vma
,
784 unsigned long addr
, pte_t
*pte
)
788 static inline void clear_soft_dirty_pmd(struct vm_area_struct
*vma
,
789 unsigned long addr
, pmd_t
*pmdp
)
794 static int clear_refs_pte_range(pmd_t
*pmd
, unsigned long addr
,
795 unsigned long end
, struct mm_walk
*walk
)
797 struct clear_refs_private
*cp
= walk
->private;
798 struct vm_area_struct
*vma
= walk
->vma
;
803 if (pmd_trans_huge_lock(pmd
, vma
, &ptl
) == 1) {
804 if (cp
->type
== CLEAR_REFS_SOFT_DIRTY
) {
805 clear_soft_dirty_pmd(vma
, addr
, pmd
);
809 page
= pmd_page(*pmd
);
811 /* Clear accessed and referenced bits. */
812 pmdp_test_and_clear_young(vma
, addr
, pmd
);
813 ClearPageReferenced(page
);
819 if (pmd_trans_unstable(pmd
))
822 pte
= pte_offset_map_lock(vma
->vm_mm
, pmd
, addr
, &ptl
);
823 for (; addr
!= end
; pte
++, addr
+= PAGE_SIZE
) {
826 if (cp
->type
== CLEAR_REFS_SOFT_DIRTY
) {
827 clear_soft_dirty(vma
, addr
, pte
);
831 if (!pte_present(ptent
))
834 page
= vm_normal_page(vma
, addr
, ptent
);
838 /* Clear accessed and referenced bits. */
839 ptep_test_and_clear_young(vma
, addr
, pte
);
840 ClearPageReferenced(page
);
842 pte_unmap_unlock(pte
- 1, ptl
);
847 static int clear_refs_test_walk(unsigned long start
, unsigned long end
,
848 struct mm_walk
*walk
)
850 struct clear_refs_private
*cp
= walk
->private;
851 struct vm_area_struct
*vma
= walk
->vma
;
853 if (vma
->vm_flags
& VM_PFNMAP
)
857 * Writing 1 to /proc/pid/clear_refs affects all pages.
858 * Writing 2 to /proc/pid/clear_refs only affects anonymous pages.
859 * Writing 3 to /proc/pid/clear_refs only affects file mapped pages.
860 * Writing 4 to /proc/pid/clear_refs affects all pages.
862 if (cp
->type
== CLEAR_REFS_ANON
&& vma
->vm_file
)
864 if (cp
->type
== CLEAR_REFS_MAPPED
&& !vma
->vm_file
)
869 static ssize_t
clear_refs_write(struct file
*file
, const char __user
*buf
,
870 size_t count
, loff_t
*ppos
)
872 struct task_struct
*task
;
873 char buffer
[PROC_NUMBUF
];
874 struct mm_struct
*mm
;
875 struct vm_area_struct
*vma
;
876 enum clear_refs_types type
;
880 memset(buffer
, 0, sizeof(buffer
));
881 if (count
> sizeof(buffer
) - 1)
882 count
= sizeof(buffer
) - 1;
883 if (copy_from_user(buffer
, buf
, count
))
885 rv
= kstrtoint(strstrip(buffer
), 10, &itype
);
888 type
= (enum clear_refs_types
)itype
;
889 if (type
< CLEAR_REFS_ALL
|| type
>= CLEAR_REFS_LAST
)
892 if (type
== CLEAR_REFS_SOFT_DIRTY
) {
893 soft_dirty_cleared
= true;
894 pr_warn_once("The pagemap bits 55-60 has changed their meaning!"
895 " See the linux/Documentation/vm/pagemap.txt for "
899 task
= get_proc_task(file_inode(file
));
902 mm
= get_task_mm(task
);
904 struct clear_refs_private cp
= {
907 struct mm_walk clear_refs_walk
= {
908 .pmd_entry
= clear_refs_pte_range
,
909 .test_walk
= clear_refs_test_walk
,
914 if (type
== CLEAR_REFS_MM_HIWATER_RSS
) {
916 * Writing 5 to /proc/pid/clear_refs resets the peak
917 * resident set size to this mm's current rss value.
919 down_write(&mm
->mmap_sem
);
920 reset_mm_hiwater_rss(mm
);
921 up_write(&mm
->mmap_sem
);
925 down_read(&mm
->mmap_sem
);
926 if (type
== CLEAR_REFS_SOFT_DIRTY
) {
927 for (vma
= mm
->mmap
; vma
; vma
= vma
->vm_next
) {
928 if (!(vma
->vm_flags
& VM_SOFTDIRTY
))
930 up_read(&mm
->mmap_sem
);
931 down_write(&mm
->mmap_sem
);
932 for (vma
= mm
->mmap
; vma
; vma
= vma
->vm_next
) {
933 vma
->vm_flags
&= ~VM_SOFTDIRTY
;
934 vma_set_page_prot(vma
);
936 downgrade_write(&mm
->mmap_sem
);
939 mmu_notifier_invalidate_range_start(mm
, 0, -1);
941 walk_page_range(0, ~0UL, &clear_refs_walk
);
942 if (type
== CLEAR_REFS_SOFT_DIRTY
)
943 mmu_notifier_invalidate_range_end(mm
, 0, -1);
945 up_read(&mm
->mmap_sem
);
949 put_task_struct(task
);
954 const struct file_operations proc_clear_refs_operations
= {
955 .write
= clear_refs_write
,
956 .llseek
= noop_llseek
,
964 int pos
, len
; /* units: PM_ENTRY_BYTES, not bytes */
965 pagemap_entry_t
*buffer
;
969 #define PAGEMAP_WALK_SIZE (PMD_SIZE)
970 #define PAGEMAP_WALK_MASK (PMD_MASK)
972 #define PM_ENTRY_BYTES sizeof(pagemap_entry_t)
973 #define PM_STATUS_BITS 3
974 #define PM_STATUS_OFFSET (64 - PM_STATUS_BITS)
975 #define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET)
976 #define PM_STATUS(nr) (((nr) << PM_STATUS_OFFSET) & PM_STATUS_MASK)
977 #define PM_PSHIFT_BITS 6
978 #define PM_PSHIFT_OFFSET (PM_STATUS_OFFSET - PM_PSHIFT_BITS)
979 #define PM_PSHIFT_MASK (((1LL << PM_PSHIFT_BITS) - 1) << PM_PSHIFT_OFFSET)
980 #define __PM_PSHIFT(x) (((u64) (x) << PM_PSHIFT_OFFSET) & PM_PSHIFT_MASK)
981 #define PM_PFRAME_MASK ((1LL << PM_PSHIFT_OFFSET) - 1)
982 #define PM_PFRAME(x) ((x) & PM_PFRAME_MASK)
983 /* in "new" pagemap pshift bits are occupied with more status bits */
984 #define PM_STATUS2(v2, x) (__PM_PSHIFT(v2 ? x : PAGE_SHIFT))
986 #define __PM_SOFT_DIRTY (1LL)
987 #define PM_PRESENT PM_STATUS(4LL)
988 #define PM_SWAP PM_STATUS(2LL)
989 #define PM_FILE PM_STATUS(1LL)
990 #define PM_NOT_PRESENT(v2) PM_STATUS2(v2, 0)
991 #define PM_END_OF_BUFFER 1
993 static inline pagemap_entry_t
make_pme(u64 val
)
995 return (pagemap_entry_t
) { .pme
= val
};
998 static int add_to_pagemap(unsigned long addr
, pagemap_entry_t
*pme
,
999 struct pagemapread
*pm
)
1001 pm
->buffer
[pm
->pos
++] = *pme
;
1002 if (pm
->pos
>= pm
->len
)
1003 return PM_END_OF_BUFFER
;
1007 static int pagemap_pte_hole(unsigned long start
, unsigned long end
,
1008 struct mm_walk
*walk
)
1010 struct pagemapread
*pm
= walk
->private;
1011 unsigned long addr
= start
;
1014 while (addr
< end
) {
1015 struct vm_area_struct
*vma
= find_vma(walk
->mm
, addr
);
1016 pagemap_entry_t pme
= make_pme(PM_NOT_PRESENT(pm
->v2
));
1017 /* End of address space hole, which we mark as non-present. */
1018 unsigned long hole_end
;
1021 hole_end
= min(end
, vma
->vm_start
);
1025 for (; addr
< hole_end
; addr
+= PAGE_SIZE
) {
1026 err
= add_to_pagemap(addr
, &pme
, pm
);
1034 /* Addresses in the VMA. */
1035 if (vma
->vm_flags
& VM_SOFTDIRTY
)
1036 pme
.pme
|= PM_STATUS2(pm
->v2
, __PM_SOFT_DIRTY
);
1037 for (; addr
< min(end
, vma
->vm_end
); addr
+= PAGE_SIZE
) {
1038 err
= add_to_pagemap(addr
, &pme
, pm
);
1047 static void pte_to_pagemap_entry(pagemap_entry_t
*pme
, struct pagemapread
*pm
,
1048 struct vm_area_struct
*vma
, unsigned long addr
, pte_t pte
)
1051 struct page
*page
= NULL
;
1054 if (pte_present(pte
)) {
1055 frame
= pte_pfn(pte
);
1057 page
= vm_normal_page(vma
, addr
, pte
);
1058 if (pte_soft_dirty(pte
))
1059 flags2
|= __PM_SOFT_DIRTY
;
1060 } else if (is_swap_pte(pte
)) {
1062 if (pte_swp_soft_dirty(pte
))
1063 flags2
|= __PM_SOFT_DIRTY
;
1064 entry
= pte_to_swp_entry(pte
);
1065 frame
= swp_type(entry
) |
1066 (swp_offset(entry
) << MAX_SWAPFILES_SHIFT
);
1068 if (is_migration_entry(entry
))
1069 page
= migration_entry_to_page(entry
);
1071 if (vma
->vm_flags
& VM_SOFTDIRTY
)
1072 flags2
|= __PM_SOFT_DIRTY
;
1073 *pme
= make_pme(PM_NOT_PRESENT(pm
->v2
) | PM_STATUS2(pm
->v2
, flags2
));
1077 if (page
&& !PageAnon(page
))
1079 if ((vma
->vm_flags
& VM_SOFTDIRTY
))
1080 flags2
|= __PM_SOFT_DIRTY
;
1082 *pme
= make_pme(PM_PFRAME(frame
) | PM_STATUS2(pm
->v2
, flags2
) | flags
);
1085 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
1086 static void thp_pmd_to_pagemap_entry(pagemap_entry_t
*pme
, struct pagemapread
*pm
,
1087 pmd_t pmd
, int offset
, int pmd_flags2
)
1090 * Currently pmd for thp is always present because thp can not be
1091 * swapped-out, migrated, or HWPOISONed (split in such cases instead.)
1092 * This if-check is just to prepare for future implementation.
1094 if (pmd_present(pmd
))
1095 *pme
= make_pme(PM_PFRAME(pmd_pfn(pmd
) + offset
)
1096 | PM_STATUS2(pm
->v2
, pmd_flags2
) | PM_PRESENT
);
1098 *pme
= make_pme(PM_NOT_PRESENT(pm
->v2
) | PM_STATUS2(pm
->v2
, pmd_flags2
));
1101 static inline void thp_pmd_to_pagemap_entry(pagemap_entry_t
*pme
, struct pagemapread
*pm
,
1102 pmd_t pmd
, int offset
, int pmd_flags2
)
1107 static int pagemap_pte_range(pmd_t
*pmd
, unsigned long addr
, unsigned long end
,
1108 struct mm_walk
*walk
)
1110 struct vm_area_struct
*vma
= walk
->vma
;
1111 struct pagemapread
*pm
= walk
->private;
1113 pte_t
*pte
, *orig_pte
;
1116 if (pmd_trans_huge_lock(pmd
, vma
, &ptl
) == 1) {
1119 if ((vma
->vm_flags
& VM_SOFTDIRTY
) || pmd_soft_dirty(*pmd
))
1120 pmd_flags2
= __PM_SOFT_DIRTY
;
1124 for (; addr
!= end
; addr
+= PAGE_SIZE
) {
1125 unsigned long offset
;
1126 pagemap_entry_t pme
;
1128 offset
= (addr
& ~PAGEMAP_WALK_MASK
) >>
1130 thp_pmd_to_pagemap_entry(&pme
, pm
, *pmd
, offset
, pmd_flags2
);
1131 err
= add_to_pagemap(addr
, &pme
, pm
);
1139 if (pmd_trans_unstable(pmd
))
1143 * We can assume that @vma always points to a valid one and @end never
1144 * goes beyond vma->vm_end.
1146 orig_pte
= pte
= pte_offset_map_lock(walk
->mm
, pmd
, addr
, &ptl
);
1147 for (; addr
< end
; pte
++, addr
+= PAGE_SIZE
) {
1148 pagemap_entry_t pme
;
1150 pte_to_pagemap_entry(&pme
, pm
, vma
, addr
, *pte
);
1151 err
= add_to_pagemap(addr
, &pme
, pm
);
1155 pte_unmap_unlock(orig_pte
, ptl
);
1162 #ifdef CONFIG_HUGETLB_PAGE
1163 static void huge_pte_to_pagemap_entry(pagemap_entry_t
*pme
, struct pagemapread
*pm
,
1164 pte_t pte
, int offset
, int flags2
)
1166 if (pte_present(pte
))
1167 *pme
= make_pme(PM_PFRAME(pte_pfn(pte
) + offset
) |
1168 PM_STATUS2(pm
->v2
, flags2
) |
1171 *pme
= make_pme(PM_NOT_PRESENT(pm
->v2
) |
1172 PM_STATUS2(pm
->v2
, flags2
));
1175 /* This function walks within one hugetlb entry in the single call */
1176 static int pagemap_hugetlb_range(pte_t
*pte
, unsigned long hmask
,
1177 unsigned long addr
, unsigned long end
,
1178 struct mm_walk
*walk
)
1180 struct pagemapread
*pm
= walk
->private;
1181 struct vm_area_struct
*vma
= walk
->vma
;
1184 pagemap_entry_t pme
;
1186 if (vma
->vm_flags
& VM_SOFTDIRTY
)
1187 flags2
= __PM_SOFT_DIRTY
;
1191 for (; addr
!= end
; addr
+= PAGE_SIZE
) {
1192 int offset
= (addr
& ~hmask
) >> PAGE_SHIFT
;
1193 huge_pte_to_pagemap_entry(&pme
, pm
, *pte
, offset
, flags2
);
1194 err
= add_to_pagemap(addr
, &pme
, pm
);
1203 #endif /* HUGETLB_PAGE */
1206 * /proc/pid/pagemap - an array mapping virtual pages to pfns
1208 * For each page in the address space, this file contains one 64-bit entry
1209 * consisting of the following:
1211 * Bits 0-54 page frame number (PFN) if present
1212 * Bits 0-4 swap type if swapped
1213 * Bits 5-54 swap offset if swapped
1214 * Bits 55-60 page shift (page size = 1<<page shift)
1215 * Bit 61 page is file-page or shared-anon
1216 * Bit 62 page swapped
1217 * Bit 63 page present
1219 * If the page is not present but in swap, then the PFN contains an
1220 * encoding of the swap file number and the page's offset into the
1221 * swap. Unmapped pages return a null PFN. This allows determining
1222 * precisely which pages are mapped (or in swap) and comparing mapped
1223 * pages between processes.
1225 * Efficient users of this interface will use /proc/pid/maps to
1226 * determine which areas of memory are actually mapped and llseek to
1227 * skip over unmapped regions.
1229 static ssize_t
pagemap_read(struct file
*file
, char __user
*buf
,
1230 size_t count
, loff_t
*ppos
)
1232 struct mm_struct
*mm
= file
->private_data
;
1233 struct pagemapread pm
;
1234 struct mm_walk pagemap_walk
= {};
1236 unsigned long svpfn
;
1237 unsigned long start_vaddr
;
1238 unsigned long end_vaddr
;
1239 int ret
= 0, copied
= 0;
1241 if (!mm
|| !atomic_inc_not_zero(&mm
->mm_users
))
1245 /* file position must be aligned */
1246 if ((*ppos
% PM_ENTRY_BYTES
) || (count
% PM_ENTRY_BYTES
))
1253 pm
.v2
= soft_dirty_cleared
;
1254 pm
.len
= (PAGEMAP_WALK_SIZE
>> PAGE_SHIFT
);
1255 pm
.buffer
= kmalloc(pm
.len
* PM_ENTRY_BYTES
, GFP_TEMPORARY
);
1260 pagemap_walk
.pmd_entry
= pagemap_pte_range
;
1261 pagemap_walk
.pte_hole
= pagemap_pte_hole
;
1262 #ifdef CONFIG_HUGETLB_PAGE
1263 pagemap_walk
.hugetlb_entry
= pagemap_hugetlb_range
;
1265 pagemap_walk
.mm
= mm
;
1266 pagemap_walk
.private = &pm
;
1269 svpfn
= src
/ PM_ENTRY_BYTES
;
1270 start_vaddr
= svpfn
<< PAGE_SHIFT
;
1271 end_vaddr
= mm
->task_size
;
1273 /* watch out for wraparound */
1274 if (svpfn
> mm
->task_size
>> PAGE_SHIFT
)
1275 start_vaddr
= end_vaddr
;
1278 * The odds are that this will stop walking way
1279 * before end_vaddr, because the length of the
1280 * user buffer is tracked in "pm", and the walk
1281 * will stop when we hit the end of the buffer.
1284 while (count
&& (start_vaddr
< end_vaddr
)) {
1289 end
= (start_vaddr
+ PAGEMAP_WALK_SIZE
) & PAGEMAP_WALK_MASK
;
1291 if (end
< start_vaddr
|| end
> end_vaddr
)
1293 down_read(&mm
->mmap_sem
);
1294 ret
= walk_page_range(start_vaddr
, end
, &pagemap_walk
);
1295 up_read(&mm
->mmap_sem
);
1298 len
= min(count
, PM_ENTRY_BYTES
* pm
.pos
);
1299 if (copy_to_user(buf
, pm
.buffer
, len
)) {
1308 if (!ret
|| ret
== PM_END_OF_BUFFER
)
1319 static int pagemap_open(struct inode
*inode
, struct file
*file
)
1321 struct mm_struct
*mm
;
1323 /* do not disclose physical addresses: attack vector */
1324 if (!capable(CAP_SYS_ADMIN
))
1326 pr_warn_once("Bits 55-60 of /proc/PID/pagemap entries are about "
1327 "to stop being page-shift some time soon. See the "
1328 "linux/Documentation/vm/pagemap.txt for details.\n");
1330 mm
= proc_mem_open(inode
, PTRACE_MODE_READ
);
1333 file
->private_data
= mm
;
1337 static int pagemap_release(struct inode
*inode
, struct file
*file
)
1339 struct mm_struct
*mm
= file
->private_data
;
1346 const struct file_operations proc_pagemap_operations
= {
1347 .llseek
= mem_lseek
, /* borrow this */
1348 .read
= pagemap_read
,
1349 .open
= pagemap_open
,
1350 .release
= pagemap_release
,
1352 #endif /* CONFIG_PROC_PAGE_MONITOR */
1357 unsigned long pages
;
1359 unsigned long active
;
1360 unsigned long writeback
;
1361 unsigned long mapcount_max
;
1362 unsigned long dirty
;
1363 unsigned long swapcache
;
1364 unsigned long node
[MAX_NUMNODES
];
1367 struct numa_maps_private
{
1368 struct proc_maps_private proc_maps
;
1369 struct numa_maps md
;
1372 static void gather_stats(struct page
*page
, struct numa_maps
*md
, int pte_dirty
,
1373 unsigned long nr_pages
)
1375 int count
= page_mapcount(page
);
1377 md
->pages
+= nr_pages
;
1378 if (pte_dirty
|| PageDirty(page
))
1379 md
->dirty
+= nr_pages
;
1381 if (PageSwapCache(page
))
1382 md
->swapcache
+= nr_pages
;
1384 if (PageActive(page
) || PageUnevictable(page
))
1385 md
->active
+= nr_pages
;
1387 if (PageWriteback(page
))
1388 md
->writeback
+= nr_pages
;
1391 md
->anon
+= nr_pages
;
1393 if (count
> md
->mapcount_max
)
1394 md
->mapcount_max
= count
;
1396 md
->node
[page_to_nid(page
)] += nr_pages
;
1399 static struct page
*can_gather_numa_stats(pte_t pte
, struct vm_area_struct
*vma
,
1405 if (!pte_present(pte
))
1408 page
= vm_normal_page(vma
, addr
, pte
);
1412 if (PageReserved(page
))
1415 nid
= page_to_nid(page
);
1416 if (!node_isset(nid
, node_states
[N_MEMORY
]))
1422 static int gather_pte_stats(pmd_t
*pmd
, unsigned long addr
,
1423 unsigned long end
, struct mm_walk
*walk
)
1425 struct numa_maps
*md
= walk
->private;
1426 struct vm_area_struct
*vma
= walk
->vma
;
1431 if (pmd_trans_huge_lock(pmd
, vma
, &ptl
) == 1) {
1432 pte_t huge_pte
= *(pte_t
*)pmd
;
1435 page
= can_gather_numa_stats(huge_pte
, vma
, addr
);
1437 gather_stats(page
, md
, pte_dirty(huge_pte
),
1438 HPAGE_PMD_SIZE
/PAGE_SIZE
);
1443 if (pmd_trans_unstable(pmd
))
1445 orig_pte
= pte
= pte_offset_map_lock(walk
->mm
, pmd
, addr
, &ptl
);
1447 struct page
*page
= can_gather_numa_stats(*pte
, vma
, addr
);
1450 gather_stats(page
, md
, pte_dirty(*pte
), 1);
1452 } while (pte
++, addr
+= PAGE_SIZE
, addr
!= end
);
1453 pte_unmap_unlock(orig_pte
, ptl
);
1456 #ifdef CONFIG_HUGETLB_PAGE
1457 static int gather_hugetlb_stats(pte_t
*pte
, unsigned long hmask
,
1458 unsigned long addr
, unsigned long end
, struct mm_walk
*walk
)
1460 struct numa_maps
*md
;
1463 if (!pte_present(*pte
))
1466 page
= pte_page(*pte
);
1471 gather_stats(page
, md
, pte_dirty(*pte
), 1);
1476 static int gather_hugetlb_stats(pte_t
*pte
, unsigned long hmask
,
1477 unsigned long addr
, unsigned long end
, struct mm_walk
*walk
)
1484 * Display pages allocated per node and memory policy via /proc.
1486 static int show_numa_map(struct seq_file
*m
, void *v
, int is_pid
)
1488 struct numa_maps_private
*numa_priv
= m
->private;
1489 struct proc_maps_private
*proc_priv
= &numa_priv
->proc_maps
;
1490 struct vm_area_struct
*vma
= v
;
1491 struct numa_maps
*md
= &numa_priv
->md
;
1492 struct file
*file
= vma
->vm_file
;
1493 struct mm_struct
*mm
= vma
->vm_mm
;
1494 struct mm_walk walk
= {
1495 .hugetlb_entry
= gather_hugetlb_stats
,
1496 .pmd_entry
= gather_pte_stats
,
1500 struct mempolicy
*pol
;
1507 /* Ensure we start with an empty set of numa_maps statistics. */
1508 memset(md
, 0, sizeof(*md
));
1510 pol
= __get_vma_policy(vma
, vma
->vm_start
);
1512 mpol_to_str(buffer
, sizeof(buffer
), pol
);
1515 mpol_to_str(buffer
, sizeof(buffer
), proc_priv
->task_mempolicy
);
1518 seq_printf(m
, "%08lx %s", vma
->vm_start
, buffer
);
1521 seq_puts(m
, " file=");
1522 seq_file_path(m
, file
, "\n\t= ");
1523 } else if (vma
->vm_start
<= mm
->brk
&& vma
->vm_end
>= mm
->start_brk
) {
1524 seq_puts(m
, " heap");
1526 pid_t tid
= pid_of_stack(proc_priv
, vma
, is_pid
);
1529 * Thread stack in /proc/PID/task/TID/maps or
1530 * the main process stack.
1532 if (!is_pid
|| (vma
->vm_start
<= mm
->start_stack
&&
1533 vma
->vm_end
>= mm
->start_stack
))
1534 seq_puts(m
, " stack");
1536 seq_printf(m
, " stack:%d", tid
);
1540 if (is_vm_hugetlb_page(vma
))
1541 seq_puts(m
, " huge");
1543 /* mmap_sem is held by m_start */
1544 walk_page_vma(vma
, &walk
);
1550 seq_printf(m
, " anon=%lu", md
->anon
);
1553 seq_printf(m
, " dirty=%lu", md
->dirty
);
1555 if (md
->pages
!= md
->anon
&& md
->pages
!= md
->dirty
)
1556 seq_printf(m
, " mapped=%lu", md
->pages
);
1558 if (md
->mapcount_max
> 1)
1559 seq_printf(m
, " mapmax=%lu", md
->mapcount_max
);
1562 seq_printf(m
, " swapcache=%lu", md
->swapcache
);
1564 if (md
->active
< md
->pages
&& !is_vm_hugetlb_page(vma
))
1565 seq_printf(m
, " active=%lu", md
->active
);
1568 seq_printf(m
, " writeback=%lu", md
->writeback
);
1570 for_each_node_state(nid
, N_MEMORY
)
1572 seq_printf(m
, " N%d=%lu", nid
, md
->node
[nid
]);
1574 seq_printf(m
, " kernelpagesize_kB=%lu", vma_kernel_pagesize(vma
) >> 10);
1577 m_cache_vma(m
, vma
);
1581 static int show_pid_numa_map(struct seq_file
*m
, void *v
)
1583 return show_numa_map(m
, v
, 1);
1586 static int show_tid_numa_map(struct seq_file
*m
, void *v
)
1588 return show_numa_map(m
, v
, 0);
1591 static const struct seq_operations proc_pid_numa_maps_op
= {
1595 .show
= show_pid_numa_map
,
1598 static const struct seq_operations proc_tid_numa_maps_op
= {
1602 .show
= show_tid_numa_map
,
1605 static int numa_maps_open(struct inode
*inode
, struct file
*file
,
1606 const struct seq_operations
*ops
)
1608 return proc_maps_open(inode
, file
, ops
,
1609 sizeof(struct numa_maps_private
));
1612 static int pid_numa_maps_open(struct inode
*inode
, struct file
*file
)
1614 return numa_maps_open(inode
, file
, &proc_pid_numa_maps_op
);
1617 static int tid_numa_maps_open(struct inode
*inode
, struct file
*file
)
1619 return numa_maps_open(inode
, file
, &proc_tid_numa_maps_op
);
1622 const struct file_operations proc_pid_numa_maps_operations
= {
1623 .open
= pid_numa_maps_open
,
1625 .llseek
= seq_lseek
,
1626 .release
= proc_map_release
,
1629 const struct file_operations proc_tid_numa_maps_operations
= {
1630 .open
= tid_numa_maps_open
,
1632 .llseek
= seq_lseek
,
1633 .release
= proc_map_release
,
1635 #endif /* CONFIG_NUMA */