Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a249fa9f authored by TARKZiM's avatar TARKZiM
Browse files

Revert "mm: per-process reclaim"

This reverts commit fdb14c28.
parent c95c7144
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -2878,9 +2878,6 @@ 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_IWUGO, proc_reclaim_operations),
#endif
#ifdef CONFIG_PROC_PAGE_MONITOR
	REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
	REG("smaps",      S_IRUGO, proc_pid_smaps_operations),
+0 −1
Original line number Diff line number Diff line
@@ -205,7 +205,6 @@ struct pde_opener {
extern const struct inode_operations proc_link_inode_operations;

extern const struct inode_operations proc_pid_link_inode_operations;
extern const struct file_operations proc_reclaim_operations;

extern void proc_init_inodecache(void);
extern struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *);
+0 −139
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@
#include <linux/rmap.h>
#include <linux/swap.h>
#include <linux/swapops.h>
#include <linux/mm_inline.h>

#include <asm/elf.h>
#include <asm/uaccess.h>
@@ -1206,144 +1205,6 @@ const struct file_operations proc_pagemap_operations = {
};
#endif /* CONFIG_PROC_PAGE_MONITOR */

#ifdef CONFIG_PROCESS_RECLAIM
enum reclaim_type {
	RECLAIM_FILE,
	RECLAIM_ANON,
	RECLAIM_ALL,
};

static int reclaim_pmd_range(pmd_t *pmd, unsigned long addr,
				unsigned long end, struct mm_walk *walk)
{
	pte_t *orig_pte, *pte, ptent;
	spinlock_t *ptl;
	LIST_HEAD(page_list);
	struct page *page;
	int isolated = 0;
	struct vm_area_struct *vma = walk->vma;

	orig_pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
	for (pte = orig_pte; addr < end; pte++, addr += PAGE_SIZE) {
		ptent = *pte;
		if (!pte_present(ptent))
			continue;

		page = vm_normal_page(vma, addr, ptent);
		if (!page)
			continue;
		/*
		 * XXX: we don't handle compound page at this moment but
		 * it should revisit for THP page before upstream.
		 */
		if (PageCompound(page)) {
			unsigned int order = compound_order(page);
			unsigned int nr_pages = (1 << order) - 1;

			addr += (nr_pages * PAGE_SIZE);
			pte += nr_pages;
			continue;
		}

		if (!PageLRU(page))
			continue;

		if (page_mapcount(page) > 1)
			continue;

		if (isolate_lru_page(page))
			continue;

		isolated++;
		list_add(&page->lru, &page_list);
		if (isolated >= SWAP_CLUSTER_MAX) {
			pte_unmap_unlock(orig_pte, ptl);
			reclaim_pages(&page_list);
			isolated = 0;
			pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
			orig_pte = pte;
		}
	}

	pte_unmap_unlock(orig_pte, ptl);
	reclaim_pages(&page_list);

	cond_resched();
	return 0;
}

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];
	struct mm_struct *mm;
	struct vm_area_struct *vma;
	enum reclaim_type type;
	char *type_buf;

	if (!capable(CAP_SYS_NICE))
		return -EPERM;

	memset(buffer, 0, sizeof(buffer));
	if (count > sizeof(buffer) - 1)
		count = sizeof(buffer) - 1;

	if (copy_from_user(buffer, buf, count))
		return -EFAULT;

	type_buf = strstrip(buffer);
	if (!strcmp(type_buf, "file"))
		type = RECLAIM_FILE;
	else if (!strcmp(type_buf, "anon"))
		type = RECLAIM_ANON;
	else if (!strcmp(type_buf, "all"))
		type = RECLAIM_ALL;
	else
		return -EINVAL;

	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_pmd_range,
			.mm = mm,
		};

		down_read(&mm->mmap_sem);
		for (vma = mm->mmap; vma; vma = vma->vm_next) {
			if (is_vm_hugetlb_page(vma))
				continue;

			if (vma->vm_flags & VM_LOCKED)
				continue;

			if (type == RECLAIM_ANON && vma->vm_ops)
				continue;
			if (type == RECLAIM_FILE && !vma->vm_ops)
				continue;

			walk_page_range(vma->vm_start, vma->vm_end,
					&reclaim_walk);
		}
		flush_tlb_mm(mm);
		up_read(&mm->mmap_sem);
		mmput(mm);
	}
	put_task_struct(task);

	return count;
}

const struct file_operations proc_reclaim_operations = {
	.write		= reclaim_write,
	.llseek		= noop_llseek,
};
#endif

#ifdef CONFIG_NUMA

struct numa_maps {
+0 −4
Original line number Diff line number Diff line
@@ -10,10 +10,6 @@
#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(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:
+0 −12
Original line number Diff line number Diff line
@@ -239,18 +239,6 @@ config COMPACTION
	help
	  Allows the compaction of memory for the allocation of huge pages.

config PROCESS_RECLAIM
	bool "Enable process reclaim"
	depends on PROC_FS
	default n
	help
	 It allows to reclaim pages of the process by /proc/pid/reclaim.

	 (echo file > /proc/PID/reclaim) reclaims file-backed pages only.
	 (echo anon > /proc/PID/reclaim) reclaims anonymous pages only.
	 (echo all > /proc/PID/reclaim) reclaims all pages.

	 Any other value is ignored.
#
# support for page migration
#
Loading