mm: Per process reclaim
Subsystems (11)
PATCH 1/6 mm: Per process reclaim
These day, there are many platforms avaiable in the embedded market and they are smarter than kernel which has very limited information about working set so they want to involve memory management more heavily like android's lowmemory killer and ashmem or recent many lowmemory notifier(there was several trial for various company NOKIA, SAMSUNG, Linaro, Google ChromeOS, Redhat).
One of the simple imagine scenario about userspace's intelligence is that platform can manage tasks as forground and backgroud so it would be better to reclaim background's task pages for end-user's *responsibility* although it has frequent referenced pages.
This patch adds new knob "reclaim under proc/<pid>/" so task manager can reclaim any target process anytime, anywhere. It could give another method to platform for using memory efficiently.
It can avoid process killing for getting free memory, which was really terrible experience because I lost my best score of game I had ever after I switch the phone call while I enjoyed the game.
Writing 1 to /proc/pid/reclaim reclaims only file pages. Writing 2 to /proc/pid/reclaim reclaims only anonymous pages. Writing 3 to /proc/pid/reclaim reclaims all pages from target process.
---
This patch is based on mmotm-20130417, which is mainatained by Michal Hocko.git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git
fs/proc/base.c | 3 ++ fs/proc/internal.h | 1 + fs/proc/task_mmu.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/rmap.h | 4 ++ mm/Kconfig | 13 ++++++ mm/internal.h | 7 +--- mm/vmscan.c | 59 ++++++++++++++++++++++++++ 7 files changed, 196 insertions(+), 6 deletions(-)
fs/proc/base.c +3 -0
@@ -2532,6 +2532,9 @@ static const struct pid_entry tgid_base_stuff[] = {REG ("mounts" ,S_IRUGO , proc_mounts_operations),REG ("mountinfo" ,S_IRUGO , proc_mountinfo_operations),REG ("mountstats" ,S_IRUSR , proc_mountstats_operations), +#ifdef CONFIG_PROCESS_RECLAIM +REG ("reclaim" ,S_IWUSR , proc_reclaim_operations), +#endif #ifdef CONFIG_PROC_PAGE_MONITORREG ("clear_refs" ,S_IWUSR , proc_clear_refs_operations), REG("smaps", S_IRUGO, proc_pid_smaps_operations),
fs/proc/internal.h +1 -0
@@ -52,6 +52,7 @@ extern const struct file_operations proc_pagemap2_operations;extern const struct file_operations proc_net_operations;extern const struct inode_operations proc_net_inode_operations;extern const struct inode_operations proc_pid_link_inode_operations; +extern const struct file_operations proc_reclaim_operations;struct proc_maps_private {struct pid *pid;
fs/proc/task_mmu.c +115 -0
127 lines not on this page · raw message
include/linux/rmap.h +4 -0
@@ -10,6 +10,10 @@#include <linux/rwsem.h> #include <linux/memcontrol.h> +extern int isolate_lru_page (struct page *page); +extern void putback_lru_page (struct page *page); +extern unsigned long reclaim_pages_from_list (struct list_head *page_list); +/* * The anon_vma heads a list of private "related" vmas, to scan if * an anonymous page pointing to this anon_vma needs to be unmapped:
mm/Kconfig +13 -0
@@ -479,3 +479,16 @@ config MEM_SOFT_DIRTY it can be cleared by hands. See Documentation/vm/soft-dirty.txt for more details. + +config PROCESS_RECLAIM + bool "Enable per process reclaim" + depends on PROC_FS + default n + help + It allows to reclaim pages of the process by /proc/pid/reclaim. + + (echo 1 > /proc/PID/reclaim) reclaims file-backed pages only. + (echo 2 > /proc/PID/reclaim) reclaims anonymous pages only. + (echo 3 > /proc/PID/reclaim) reclaims all pages. + + Any other vaule is ignored.
mm/internal.h +1 -6
@@ -86,12 +86,6 @@ static inline void get_page_foll(struct page *page)extern unsigned long highest_memmap_pfn;/* -* in mm/vmscan.c: -*/ -extern int isolate_lru_page (struct page *page); -extern void putback_lru_page (struct page *page); - -/* * in mm/rmap.c: */ extern pmd_t *mm_find_pmd (struct mm_struct *mm,unsigned long address);
@@ -360,6 +354,7 @@ extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,extern void set_pageblock_order (void );unsigned long reclaim_clean_pages_from_list (struct zone *zone,struct list_head *page_list); +/* The ALLOC_WMARK bits are used as an index to zone->watermark */ #define ALLOC_WMARK_MIN WMARK_MIN#define ALLOC_WMARK_LOW WMARK_LOW
mm/vmscan.c +59 -0
65 lines not on this page · raw message
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/6 mm: make shrink_page_list with pages work from multiple zones
Shrink_page_list expects all pages come from a same zone but it's too limited to use.
This patch removes the dependency so next patch can use shrink_page_list with pages from multiple zones.
--- mm/vmscan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/vmscan.c +3 -2
@@ -706,7 +706,8 @@ static unsigned long shrink_page_list(struct list_head *page_list, goto keep;VM_BUG_ON (PageActive (page)); -VM_BUG_ON (page_zone (page) != zone); +if (zone) +VM_BUG_ON (page_zone (page) != zone); sc->nr_scanned++;
@@ -952,7 +953,7 @@ keep:* back off and wait for congestion to clear because further reclaim * will encounter the same problem */ -if (nr_dirty && nr_dirty == nr_congested &&global_reclaim (sc)) +if (nr_dirty && nr_dirty == nr_congested &&global_reclaim (sc) && zone)zone_set_flag (zone,ZONE_CONGESTED );free_hot_cold_page_list (&free_pages,1 );
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/6 mm: Remove shrink_page
In reply to Minchan KimBy previous patch, shrink_page_list can handle pages from multiple zone so let's remove shrink_page.
--- mm/vmscan.c | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-)
mm/vmscan.c +14 -33
@@ -924,6 +924,13 @@ free_it:* appear not as the counts should be low */ list_add (&page->lru, &free_pages); +/* +* If pagelist are from multiple zones, we should decrease +* NR_ISOLATED_ANON + x on freed pages in here. +*/ +if (!zone) +dec_zone_page_state (page,NR_ISOLATED_ANON + +page_is_file_cache (page));continue ; cull_mlocked:
@@ -994,28 +1001,6 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, } #ifdef CONFIG_PROCESS_RECLAIM -static unsigned long shrink_page(struct page *page, - struct zone *zone, - struct scan_control *sc, - enum ttu_flags ttu_flags, - unsigned long *ret_nr_dirty, - unsigned long *ret_nr_writeback, - bool force_reclaim, - struct list_head *ret_pages) -{ - int reclaimed; - LIST_HEAD(page_list); - list_add(&page->lru, &page_list); - - reclaimed = shrink_page_list(&page_list, zone, sc, ttu_flags, - ret_nr_dirty, ret_nr_writeback, - force_reclaim); - if (!reclaimed) - list_splice(&page_list, ret_pages); - - return reclaimed; -} - unsigned long reclaim_pages_from_list(struct list_head *page_list) { struct scan_control sc = {
@@ -1025,23 +1010,19 @@ unsigned long reclaim_pages_from_list(struct list_head *page_list) .may_swap = 1, }; -LIST_HEAD (ret_pages); +unsigned long nr_reclaimed;struct page *page;unsigned long dummy1, dummy2; -unsigned long nr_reclaimed =0 ; - -while (!list_empty (page_list)) { - page =lru_to_page (page_list); -list_del (&page->lru); +list_for_each_entry (page, page_list, lru)ClearPageActive (page); - nr_reclaimed +=shrink_page (page,page_zone (page), &sc, + + nr_reclaimed =shrink_page_list (page_list,NULL , &sc,TTU_UNMAP |TTU_IGNORE_ACCESS , - &dummy1, &dummy2, true, &ret_pages); - } + &dummy1, &dummy2, true); -while (!list_empty (&ret_pages)) { - page =lru_to_page (&ret_pages); +while (!list_empty (page_list)) { + page =lru_to_page (page_list);list_del (&page->lru);dec_zone_page_state (page,NR_ISOLATED_ANON +page_is_file_cache (page));
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/6 mm: Enhance per process reclaim to consider shared pages
In reply to Minchan KimSome pages could be shared by several processes. (ex, libc) In case of that, it's too bad to reclaim them from the beginnig.
This patch causes VM to keep them on memory until last task try to reclaim them so shared pages will be reclaimed only if all of task has gone swapping out.
This feature doesn't handle non-linear mapping on ramfs because it's very time-consuming and doesn't make sure of reclaiming and not common.
--- fs/proc/task_mmu.c | 2 +- include/linux/ksm.h | 6 ++++-- include/linux/rmap.h | 8 +++++--- mm/ksm.c | 9 ++++++++- mm/memory-failure.c | 2 +- mm/migrate.c | 6 ++++-- mm/rmap.c | 57 +++++++++++++++++++++++++++++++++++++--------------- mm/vmscan.c | 14 +++++++++++-- 8 files changed, 76 insertions(+), 28 deletions(-)
fs/proc/task_mmu.c +1 -1
@@ -1220,7 +1220,7 @@ cont:break ; }pte_unmap_unlock (pte -1 , ptl); -reclaim_pages_from_list (&page_list); +reclaim_pages_from_list (&page_list, vma);if (addr != end) goto cont;
include/linux/ksm.h +4 -2
@@ -75,7 +75,8 @@ struct page *ksm_might_need_to_copy(struct page *page,int page_referenced_ksm (struct page *page,struct mem_cgroup *memcg,unsigned long *vm_flags); -int try_to_unmap_ksm (struct page *page,enum ttu_flags flags); +int try_to_unmap_ksm (struct page *page, +enum ttu_flags flags,struct vm_area_struct *vma);int rmap_walk_ksm (struct page *page,int (*rmap_one)(struct page *,struct vm_area_struct *,unsigned long ,void *),void *arg);void ksm_migrate_page (struct page *newpage,struct page *oldpage);
@@ -115,7 +116,8 @@ static inline int page_referenced_ksm(struct page *page,return 0 ; } -static inline int try_to_unmap_ksm (struct page *page,enum ttu_flags flags) +static inline int try_to_unmap_ksm (struct page *page, +enum ttu_flags flags,struct vm_area_struct *target_vma) {return 0 ; }
include/linux/rmap.h +5 -3
@@ -12,7 +12,8 @@extern int isolate_lru_page (struct page *page);extern void putback_lru_page (struct page *page); -extern unsigned long reclaim_pages_from_list (struct list_head *page_list); +extern unsigned long reclaim_pages_from_list (struct list_head *page_list, +struct vm_area_struct *vma);/* * The anon_vma heads a list of private "related" vmas, to scan if
@@ -192,7 +193,8 @@ int page_referenced_one(struct page *, struct vm_area_struct *,#define TTU_ACTION (x) ((x) & TTU_ACTION_MASK) -int try_to_unmap (struct page *,enum ttu_flags flags); +int try_to_unmap (struct page *,enum ttu_flags flags, +struct vm_area_struct *vma);int try_to_unmap_one (struct page *,struct vm_area_struct *,unsigned long address,enum ttu_flags flags);
@@ -259,7 +261,7 @@ static inline int page_referenced(struct page *page, int is_locked,return 0 ; } -#define try_to_unmap (page, refs) SWAP_FAIL +#define try_to_unmap (page, refs, vma) SWAP_FAILstatic inline int page_mkclean (struct page *page) {
mm/ksm.c +8 -1
@@ -1949,7 +1949,8 @@ out:return referenced; } -int try_to_unmap_ksm (struct page *page,enum ttu_flags flags) +int try_to_unmap_ksm (struct page *page,enum ttu_flags flags, +struct vm_area_struct *target_vma) {struct stable_node *stable_node;struct hlist_node *hlist;
@@ -1963,6 +1964,12 @@ int try_to_unmap_ksm(struct page *page, enum ttu_flags flags) stable_node =page_stable_node (page);if (!stable_node)return SWAP_FAIL ; + +if (target_vma) { +unsigned long address =vma_address (page, target_vma); + ret =try_to_unmap_one (page, target_vma, address, flags); + goto out; + } again:hlist_for_each_entry (rmap_item, hlist, &stable_node->hlist, hlist) {struct anon_vma *anon_vma = rmap_item->anon_vma;
mm/memory-failure.c +1 -1
@@ -955,7 +955,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,if (hpage != ppage)lock_page (ppage); - ret =try_to_unmap (ppage, ttu); + ret =try_to_unmap (ppage, ttu,NULL );if (ret !=SWAP_SUCCESS )printk (KERN_ERR "MCE %#lx: failed to unmap page (mapcount=%d)\n" , pfn,page_mapcount (ppage));
mm/migrate.c +4 -2
@@ -820,7 +820,8 @@ static int __unmap_and_move(struct page *page, struct page *newpage, }/* Establish migration ptes or remove ptes */ -try_to_unmap (page,TTU_MIGRATION |TTU_IGNORE_MLOCK |TTU_IGNORE_ACCESS ); +try_to_unmap (page,TTU_MIGRATION |TTU_IGNORE_MLOCK |TTU_IGNORE_ACCESS , +NULL ); skip_unmap:if (!page_mapped (page))
@@ -947,7 +948,8 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,if (PageAnon (hpage)) anon_vma =page_get_anon_vma (hpage); -try_to_unmap (hpage,TTU_MIGRATION |TTU_IGNORE_MLOCK |TTU_IGNORE_ACCESS ); +try_to_unmap (hpage,TTU_MIGRATION |TTU_IGNORE_MLOCK |TTU_IGNORE_ACCESS , +NULL );if (!page_mapped (hpage)) rc =move_to_new_page (new_hpage, hpage,1 , mode);
mm/rmap.c +41 -16
140 lines not on this page · raw message
mm/vmscan.c +12 -2
@@ -93,6 +93,13 @@ struct scan_control {* are scanned. */ nodemask_t *nodemask; + +/* +* Reclaim pages from a vma. If the page is shared by other tasks +* it is zapped from a vma without reclaim so it ends up remaining +* on memory until last task zap it. +*/ +struct vm_area_struct *target_vma; };#define lru_to_page (_head) (list_entry((_head)->prev, struct page, lru))
@@ -794,7 +801,8 @@ static unsigned long shrink_page_list(struct list_head *page_list,* processes. Try to unmap it here. */ if (page_mapped (page) && mapping) { -switch (try_to_unmap (page, ttu_flags)) { +switch (try_to_unmap (page, + ttu_flags, sc->target_vma)) {case SWAP_FAIL : goto activate_locked;case SWAP_AGAIN :
@@ -1001,13 +1009,15 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, }#ifdef CONFIG_PROCESS_RECLAIM -unsigned long reclaim_pages_from_list (struct list_head *page_list) +unsigned long reclaim_pages_from_list (struct list_head *page_list, +struct vm_area_struct *vma) {struct scan_control sc = { .gfp_mask =GFP_KERNEL , .priority =DEF_PRIORITY , .may_unmap =1 , .may_swap =1 , + .target_vma = vma, };unsigned long nr_reclaimed;
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/6 mm: Support address range reclaim
In reply to Minchan KimThis patch adds address range reclaim of a process. The requirement is following as,
Like webkit1, it uses a address space for handling multi tabs. IOW, it uses *one* process model so all tabs shares address space of the process. In such scenario, per-process reclaim is rather coarse-grained so this patch supports more fine-grained reclaim for being able to reclaim target address range of the process. For reclaim target range, you should use following format.
echo 4 [address] [size] > /proc/pid/reclaim
So reclaim konb's interface is following as.
echo 1 > /proc/pid/reclaim
reclaim file-backed pages only
echo 2 > /proc/pid/reclaim
reclaim anonymous pages only
echo 3 > /proc/pid/reclaim
reclaim all pages
echo 4 $((1<<20)) 4096 > /proc/pid/reclaim
reclaim file-backed pages in (0x100000 - 0x101000) echo 5 $((1<<20)) 4096 > /proc/pid/reclaim reclaim anonymous pages in (0x100000 - 0x101000) echo 6 $((1<<20)) 4096 > /proc/pid/reclaim reclaim all pages in (0x100000 - 0x101000)
--- fs/proc/task_mmu.c | 123 ++++++++++++++++++++++++++++++++++++++++------------- mm/internal.h | 3 ++ 2 files changed, 96 insertions(+), 30 deletions(-)
fs/proc/task_mmu.c +93 -30
@@ -1228,67 +1228,130 @@ cont:return 0 ; } -#define RECLAIM_FILE (1 << 0) -#define RECLAIM_ANON (1 << 1) -#define RECLAIM_ALL (RECLAIM_FILE | RECLAIM_ANON) +enum reclaim_type { +RECLAIM_FILE =1 , +RECLAIM_ANON , +RECLAIM_ALL , +RECLAIM_FILE_RANGE , +RECLAIM_ANON_RANGE , +RECLAIM_BOTH_RANGE , +};static ssize_t reclaim_write (struct file *file,const char __user *buf,size_t count,loff_t *ppos) {struct task_struct *task; -char buffer[PROC_NUMBUF ]; +char buffer[200 ];struct mm_struct *mm;struct vm_area_struct *vma;int type; -int rv; +int ret; +char *sptr, *token; +unsigned long len_in; +unsigned long start =0 ; +unsigned long end =0 ; +struct mm_walk reclaim_walk = {};memset (buffer,0 ,sizeof (buffer));if (count >sizeof (buffer) -1 ) - count =sizeof (buffer) -1 ; + goto out_err; +if (copy_from_user (buffer, buf, count))return -EFAULT ; - rv =kstrtoint (strstrip (buffer),10 , &type); -if (rv <0 ) -return rv; -if (type <RECLAIM_FILE || type >RECLAIM_ALL ) -return -EINVAL ; + + sptr =strstrip (buffer); + token =strsep (&sptr," " ); +if (!token) + goto out_err; + ret =kstrtoint (token,10 , &type); +if (ret <0 || (type <RECLAIM_FILE || type >RECLAIM_BOTH_RANGE )) + goto out_err; + +if (type >RECLAIM_ALL ) { +size_t len; + token =strsep (&sptr," " ); +if (!token) + goto out_err; + ret =kstrtoul (token,10 , &start); +if (ret <0 ) + goto out_err; + + token =strsep (&sptr," " ); +if (!token) + goto out_err; + ret =kstrtoul (token,10 , &len_in); +if (ret <0 ) + goto out_err; + len = (len_in + ~PAGE_MASK ) &PAGE_MASK ; + +/* +* Check to see whether len was rounded up from small -ve +* to zero. +*/ +if (len_in && !len) + goto out_err; + + end = start + len; +if (end < start) + goto out_err; + } + task =get_proc_task (file->f_path.dentry->d_inode);if (!task)return -ESRCH ; + mm =get_task_mm (task); -if (mm) { -struct mm_walk reclaim_walk = { - .pmd_entry = reclaim_pte_range, - .mm = mm, - }; -down_read (&mm->mmap_sem); +if (!mm) + goto out; + + reclaim_walk.mm = mm; + reclaim_walk.pmd_entry = reclaim_pte_range; + +down_read (&mm->mmap_sem); +if (type >RECLAIM_ALL ) { + vma =find_vma (mm, start); +while (vma) { +if (vma->vm_start > end) +break ; + + reclaim_walk.private = vma; +if (is_vm_hugetlb_page (vma)) +continue ; +if (type ==RECLAIM_ANON_RANGE && vma->vm_file) +continue ; +if (type ==RECLAIM_FILE_RANGE && !vma->vm_file) +continue ; + +walk_page_range (max (vma->vm_start, start), +min (vma->vm_end, end), + &reclaim_walk); + + vma = vma->vm_next; + } + }else {for (vma = mm->mmap; vma; vma = vma->vm_next) { reclaim_walk.private = vma;if (is_vm_hugetlb_page (vma))continue ; -/* -* Writing 1 to /proc/pid/reclaim only affects file -* mapped pages. -* -* Writing 2 to /proc/pid/reclaim enly affects -* anonymous pages. -* -* Writing 3 to /proc/pid/reclaim affects all pages. -*/ if (type ==RECLAIM_ANON && vma->vm_file)continue ;if (type ==RECLAIM_FILE && !vma->vm_file)continue ;walk_page_range (vma->vm_start, vma->vm_end, - &reclaim_walk); + &reclaim_walk); } -flush_tlb_mm (mm); -up_read (&mm->mmap_sem); -mmput (mm); } + +flush_tlb_mm (mm); +up_read (&mm->mmap_sem); +mmput (mm); +out:put_task_struct (task);return count; + +out_err: +return -EINVAL ; }const struct file_operations proc_reclaim_operations = {
mm/internal.h +3 -0
@@ -85,6 +85,9 @@ static inline void get_page_foll(struct page *page)extern unsigned long highest_memmap_pfn; +extern int isolate_lru_page (struct page *page); +extern void putback_lru_page (struct page *page); +/* * in mm/rmap.c: */
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/6 add documentation on proc.txt
In reply to Minchan KimThis patch adds documentation about new reclaim field in proc.txt
--- Documentation/filesystems/proc.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
Documentation/filesystems/proc.txt +24 -0
@@ -136,6 +136,7 @@ Table 1-1: Process specific entries in /proc maps Memory maps to executables and library files (2.4) mem Memory held by this process root Link to the root directory of this process + reclaim Reclaim pages in this process stat Process status statm Process memory status information status Process status in human readable form
@@ -489,6 +490,29 @@ To clear the soft-dirty bit Any other value written to /proc/PID/clear_refs will have no effect. +The /proc/PID/reclaim is used to reclaim pages in this process. +To reclaim file-backed pages, + > echo 1 > /proc/PID/reclaim + +To reclaim anonymous pages, + > echo 2 > /proc/PID/reclaim + +To reclaim both pages, + > echo 3 > /proc/PID/reclaim + +Also, you can specify address range of process so part of address space +will be reclaimed. The format is following as + > echo 4 addr size > /proc/PID/reclaim + +To reclaim file-backed pages in address range, + > echo 4 $((1<<20) 4096 > /proc/PID/reclaim + +To reclaim anonymous pages in address range, + > echo 5 $((1<<20) 4096 > /proc/PID/reclaim + +To reclaim both pages in address range, + > echo 6 $((1<<20) 4096 > /proc/PID/reclaim + The /proc/pid/pagemap gives the PFN, which can be used to find the pageflags using /proc/kpageflags and number of times a page is mapped using /proc/kpagecount. For detailed explanation, see Documentation/vm/pagemap.txt.
Signature · 7 lines
1.8.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] add documentation on proc.txt
Quoted 22 lines · Minchan Kim
This patch adds documentation about new reclaim field in proc.txt
Cc Rob Landley <[email protected]>Signed-off-by Minchan Kim <[email protected]>--- Documentation/filesystems/proc.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)Documentation/filesystems/proc.txt +1
-0@@ -136,6 +136,7 @@ Table 1-1: Process specific entries in /proc maps Memory maps to executables and library files (2.4) mem Memory held by this process root Link to the root directory of this process + reclaim Reclaim pages in this process stat Process status statm Process memory status informationstatus Process status in human readable form
Documentation/filesystems/proc.txt To clear the soft-dirty bit · line 493
Quoted 4 lines
Documentation/filesystems/proc.txt +1
-0@@ -489,6 +490,29 @@ To clear the soft-dirty bit Any other value written to /proc/PID/clear_refs will have no effect. +The /proc/PID/reclaim is used to reclaim pages in this process.
Trivial nitpick: Either start with "The file" or just /proc/PID/reclaim
Documentation/filesystems/proc.txt To clear the soft-dirty bit · line 505
Quoted 13 lines
Documentation/filesystems/proc.txt +10
-0+To reclaim file-backed pages, + > echo 1 > /proc/PID/reclaim + +To reclaim anonymous pages, + > echo 2 > /proc/PID/reclaim + +To reclaim both pages, + > echo 3 > /proc/PID/reclaim + +Also, you can specify address range of process so part of addressspace
Documentation/filesystems/proc.txt +2
-0+will be reclaimed. The format is following as + > echo 4 addr size > /proc/PID/reclaim
Size is in bytes or pages? (I'm guessing bytes. It must be a multiple of pages?)
So the following examples are telling it to reclaim a specific page?
Quoted 10 lines
Documentation/filesystems/proc.txt +9
-0+To reclaim file-backed pages in address range, + > echo 4 $((1<<20) 4096 > /proc/PID/reclaim + +To reclaim anonymous pages in address range, + > echo 5 $((1<<20) 4096 > /proc/PID/reclaim + +To reclaim both pages in address range, + > echo 6 $((1<<20) 4096 > /proc/PID/reclaim + The /proc/pid/pagemap gives the PFN, which can be used to find the
Quoted 4 lines
pageflags
using/proc/kpageflagsand number of times a page is mapped using/proc/kpagecount. For detailed explanation, seeDocumentation/vm/pagemap.txt.
Otherwise, if the series goes in I'm fine with this going in with it.
Rob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] add documentation on proc.txt
In reply to Minchan KimDocumentation/filesystems/proc.txt To clear the soft-dirty bit · line 501
Quoted 9 lines · Minchan Kim
Documentation/filesystems/proc.txt +9
-0+The /proc/PID/reclaim is used to reclaim pages in this process. +To reclaim file-backed pages, + > echo 1 > /proc/PID/reclaim + +To reclaim anonymous pages, + > echo 2 > /proc/PID/reclaim + +To reclaim both pages, + > echo 3 > /proc/PID/reclaim
This seems to be in the same spirit as /proc/sys/vm/drop_caches. That's not a sin in and of itself. But, why use numbers here?
Any chance I could talk you in to using some strings, say like:
echo 'anonymous' > /proc/PID/reclaim
echo 'anonymous|file' > /proc/PID/reclaim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] add documentation on proc.txt
In reply to Rob LandleyHello Rob,
Quoted 24 lines · Rob Landley
Quoted 23 lines · Minchan Kim
This patch adds documentation about new reclaim field in proc.txt
Cc Rob Landley <[email protected]>Signed-off-by Minchan Kim <[email protected]>---
Documentation/filesystems/proc.txt| 24 ++++++++++++++++++++++++1 file changed, 24 insertions(+)Documentation/filesystems/proc.txt +1
-0@@ -136,6 +136,7 @@ Table 1-1: Process specific entries in /proc maps Memory maps to executables and library files (2.4) mem Memory held by this process root Link to the root directory of this process + reclaim Reclaim pages in this process stat Process status statm Process memory status information status Process status in human readable form@@ -489,6 +490,29 @@ To clear the soft-dirty bit
Quoted 5 lines
Quoted 3 lines
Any other value written to
/proc/PID/clear_refswill have no effect.+The
/proc/PID/reclaimis used to reclaim pages in this process.Trivial nitpick: Either start with "The file" or just
/proc/PID/reclaim
I prefer "The file".
Quoted 17 lines
Quoted 12 lines
Documentation/filesystems/proc.txt +10
-0+To reclaim file-backed pages, + > echo 1 > /proc/PID/reclaim + +To reclaim anonymous pages, + > echo 2 > /proc/PID/reclaim + +To reclaim both pages, + > echo 3 > /proc/PID/reclaim + +Also, you can specify address range of process so part of addressspace
Documentation/filesystems/proc.txt To clear the soft-dirty bit · line 505
Quoted 2 lines
Documentation/filesystems/proc.txt +2
-0+will be reclaimed. The format is following as + > echo 4 addr size > /proc/PID/reclaimSize is in bytes or pages? (I'm guessing bytes. It must be a multiple of pages?)
Hmm, current implementation doesn't force it but it sounds good. I will do it in next spin. addr should be page-aligned but not necessary to be for size.
Quoted 2 lines
So the following examples are telling it to reclaim a specific page?
Right.
Quoted 18 lines
Quoted 10 lines
Documentation/filesystems/proc.txt +9
-0+To reclaim file-backed pages in address range, + > echo 4 $((1<<20) 4096 > /proc/PID/reclaim + +To reclaim anonymous pages in address range, + > echo 5 $((1<<20) 4096 > /proc/PID/reclaim + +To reclaim both pages in address range, + > echo 6 $((1<<20) 4096 > /proc/PID/reclaim +Quoted 5 lines
The
/proc/pid/pagemapgives the PFN, which can be used to find the pageflags
using/proc/kpageflagsand number of times a page is mapped using/proc/kpagecount. For detailed explanation, seeDocumentation/vm/pagemap.txt.Otherwise, if the series goes in I'm fine with this going in with it.
Quoted 1 line
Acked-by Rob Landley <[email protected]>
Thanks for the review!
Quoted 7 lines
Rob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] add documentation on proc.txt
In reply to Dave HansenHello Dave,
Quoted 14 lines · Dave Hansen
Documentation/filesystems/proc.txt To clear the soft-dirty bit · line 501
Quoted 9 lines · Minchan Kim
Documentation/filesystems/proc.txt +9
-0+The /proc/PID/reclaim is used to reclaim pages in this process. +To reclaim file-backed pages, + > echo 1 > /proc/PID/reclaim + +To reclaim anonymous pages, + > echo 2 > /proc/PID/reclaim + +To reclaim both pages, + > echo 3 > /proc/PID/reclaimThis seems to be in the same spirit as
/proc/sys/vm/drop_caches. That's not a sin in and of itself. But, why use numbers here?
Quoted 4 lines
Any chance I could talk you in to using some strings, say like:
echo 'anonymous' >
/proc/PID/reclaim
echo 'anonymous|file' >/proc/PID/reclaim
I discussed with Namhyung about interface.
His suggestion looks sane to me.
echo 'file' > /proc/PID/reclaim
echo 'anon' > /proc/PID/reclaim
echo 'both' > /proc/PID/reclaim
For range reclaim,
echo $((1<<20)) 8192 > /proc/PID/reclaim.
IOW, we don't need any type for range reclaim because only thing user takes care is address range which has mapped page regardless of that it's anon or file.
Does it make sense to you?
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] add documentation on proc.txt
Quoted 6 lines · Minchan Kim
echo 'file' >
/proc/PID/reclaim
echo 'anon' >/proc/PID/reclaim
echo 'both' >/proc/PID/reclaimFor range reclaim,
Quoted 7 lines
echo $((1<<20)) 8192 >
/proc/PID/reclaim.IOW, we don't need any type for range reclaim because only thing user takes care is address range which has mapped page regardless of that it's anon or file.
Does it make sense to you?
That looks very nice! Although, I'd probably use 'all' instead of 'both'. It leaves you more wiggle room to add more types in the future, like volatile pages.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/6] add documentation on proc.txt
Hello Dave,
Quoted 13 lines · Dave Hansen
Quoted 12 lines · Minchan Kim
echo 'file' >
/proc/PID/reclaim
echo 'anon' >/proc/PID/reclaim
echo 'both' >/proc/PID/reclaimFor range reclaim,
echo $((1<<20)) 8192 >
/proc/PID/reclaim.IOW, we don't need any type for range reclaim because only thing user takes care is address range which has mapped page regardless of that it's anon or file.
Quoted 5 lines
Quoted 1 line
Does it make sense to you?
That looks very nice! Although, I'd probably use 'all' instead of 'both'. It leaves you more wiggle room to add more types in the future, like volatile pages.
Fair enough.
Thanks for the review.
I just sent a new.
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>