aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/configs/cyanogenmod_i9100_defconfig1
-rw-r--r--arch/arm/configs/cyanogenmod_i9300_defconfig1
-rw-r--r--drivers/staging/android/lowmemorykiller.c254
-rw-r--r--drivers/staging/zram/Kconfig7
-rw-r--r--drivers/staging/zram/zram_drv.c53
-rw-r--r--drivers/staging/zram/zram_drv.h2
-rw-r--r--drivers/staging/zram/zram_sysfs.c31
-rw-r--r--include/linux/mm_types.h6
-rw-r--r--kernel/power/earlysuspend.c13
-rw-r--r--mm/shmem.c9
-rw-r--r--mm/swapfile.c153
-rw-r--r--mm/vmscan.c78
12 files changed, 10 insertions, 598 deletions
diff --git a/arch/arm/configs/cyanogenmod_i9100_defconfig b/arch/arm/configs/cyanogenmod_i9100_defconfig
index bf8eac8..cfacb41 100644
--- a/arch/arm/configs/cyanogenmod_i9100_defconfig
+++ b/arch/arm/configs/cyanogenmod_i9100_defconfig
@@ -2694,7 +2694,6 @@ CONFIG_XVMALLOC=y
CONFIG_ZRAM=y
CONFIG_ZCACHE=y
# CONFIG_ZRAM_DEBUG is not set
-CONFIG_ZRAM_FOR_ANDROID=y
# CONFIG_FB_SM7XX is not set
# CONFIG_LIRC_STAGING is not set
# CONFIG_EASYCAP is not set
diff --git a/arch/arm/configs/cyanogenmod_i9300_defconfig b/arch/arm/configs/cyanogenmod_i9300_defconfig
index 0239633..3d793b4 100644
--- a/arch/arm/configs/cyanogenmod_i9300_defconfig
+++ b/arch/arm/configs/cyanogenmod_i9300_defconfig
@@ -2875,7 +2875,6 @@ CONFIG_ANDROID_LOW_MEMORY_KILLER=y
CONFIG_XVMALLOC=y
CONFIG_ZRAM=y
# CONFIG_ZRAM_DEBUG is not set
-CONFIG_ZRAM_FOR_ANDROID=y
# CONFIG_FB_SM7XX is not set
# CONFIG_LIRC_STAGING is not set
# CONFIG_EASYCAP is not set
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 15bbcd3..d412581 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -35,12 +35,6 @@
#include <linux/oom.h>
#include <linux/sched.h>
#include <linux/notifier.h>
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-#include <linux/swap.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/mm_inline.h>
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
#define ENHANCED_LMK_ROUTINE
#ifdef ENHANCED_LMK_ROUTINE
@@ -62,35 +56,6 @@ static size_t lowmem_minfree[6] = {
16 * 1024, /* 64MB */
};
static int lowmem_minfree_size = 4;
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-static struct class *lmk_class;
-static struct device *lmk_dev;
-static int lmk_kill_pid = 0;
-static int lmk_kill_ok = 0;
-
-extern atomic_t optimize_comp_on;
-
-extern int isolate_lru_page_compcache(struct page *page);
-extern void putback_lru_page(struct page *page);
-extern unsigned int zone_id_shrink_pagelist(struct zone *zone_id,struct list_head *page_list);
-
-#define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
-
-#define SWAP_PROCESS_DEBUG_LOG 0
-/* free RAM 8M(2048 pages) */
-#define CHECK_FREE_MEMORY 2048
-/* free swap (10240 pages) */
-#define CHECK_FREE_SWAPSPACE 10240
-
-static unsigned int check_free_memory = 0;
-
-enum pageout_io {
- PAGEOUT_IO_ASYNC,
- PAGEOUT_IO_SYNC,
-};
-
-
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
#ifdef ENHANCED_LMK_ROUTINE
static struct task_struct *lowmem_deathpending[LOWMEM_DEATHPENDING_DEPTH] = {NULL,};
@@ -323,229 +288,10 @@ static struct shrinker lowmem_shrinker = {
.seeks = DEFAULT_SEEKS * 16
};
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-/*
- * zone_id_shrink_pagelist() clear page flags,
- * update the memory zone status, and swap pagelist
- */
-
-static unsigned int shrink_pages(struct mm_struct *mm,
- struct list_head *zone0_page_list,
- struct list_head *zone1_page_list,
- unsigned int num_to_scan)
-{
- unsigned long addr;
- unsigned int isolate_pages_countter = 0;
-
- struct vm_area_struct *vma = mm->mmap;
- while (vma != NULL) {
-
- for (addr = vma->vm_start; addr < vma->vm_end;
- addr += PAGE_SIZE) {
- struct page *page;
- /*get the page address from virtual memory address */
- page = follow_page(vma, addr, FOLL_GET);
-
- if (page && !IS_ERR(page)) {
-
- put_page(page);
- /* only moveable, anonymous and not dirty pages can be swapped */
- if ((!PageUnevictable(page))
- && (!PageDirty(page)) && ((PageAnon(page)))
- && (0 == page_is_file_cache(page))) {
- switch (page_zone_id(page)) {
- case 0:
- if (!isolate_lru_page_compcache(page)) {
- /* isolate page from LRU and add to temp list */
- /*create new page list, it will be used in shrink_page_list */
- list_add_tail(&page->lru, zone0_page_list);
- isolate_pages_countter++;
- }
- break;
- case 1:
- if (!isolate_lru_page_compcache(page)) {
- /* isolate page from LRU and add to temp list */
- /*create new page list, it will be used in shrink_page_list */
- list_add_tail(&page->lru, zone1_page_list);
- isolate_pages_countter++;
- }
- break;
- default:
- break;
- }
- }
- }
-
- if (isolate_pages_countter >= num_to_scan) {
- return isolate_pages_countter;
- }
- }
-
- vma = vma->vm_next;
- }
-
- return isolate_pages_countter;
-}
-
-/*
- * swap_application_pages() will search the
- * pages which can be swapped, then call
- * zone_id_shrink_pagelist to update zone
- * status
- */
-static unsigned int swap_pages(struct list_head *zone0_page_list,
- struct list_head *zone1_page_list)
-{
- struct zone *zone_id_0 = &NODE_DATA(0)->node_zones[0];
- struct zone *zone_id_1 = &NODE_DATA(0)->node_zones[1];
- unsigned int pages_counter = 0;
-
- /*if the page list is not empty, call zone_id_shrink_pagelist to update zone status */
- if ((zone_id_0) && (!list_empty(zone0_page_list))) {
- pages_counter +=
- zone_id_shrink_pagelist(zone_id_0, zone0_page_list);
- }
- if ((zone_id_1) && (!list_empty(zone1_page_list))) {
- pages_counter +=
- zone_id_shrink_pagelist(zone_id_1, zone1_page_list);
- }
- return pages_counter;
-}
-
-static ssize_t lmk_state_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sprintf(buf, "%d,%d\n", lmk_kill_pid, lmk_kill_ok);
-}
-
-/*
- * lmk_state_store() will called by framework,
- * the framework will send the pid of process that need to be swapped
- */
-static ssize_t lmk_state_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t size)
-{
- sscanf(buf, "%d,%d", &lmk_kill_pid, &lmk_kill_ok);
-
- /* if the screen on, the optimized compcache will stop */
- if (atomic_read(&optimize_comp_on) != 1)
- return size;
-
- if (lmk_kill_ok == 1) {
- struct task_struct *p;
- struct task_struct *selected = NULL;
- struct sysinfo ramzswap_info = { 0 };
- struct mm_struct *mm_scan = NULL;
-
- /*
- * check the free RAM and swap area,
- * stop the optimized compcache in cpu idle case;
- * leave some swap area for using in low memory case
- */
- si_swapinfo(&ramzswap_info);
- si_meminfo(&ramzswap_info);
-
- if ((ramzswap_info.freeswap < CHECK_FREE_SWAPSPACE) ||
- (ramzswap_info.freeram < check_free_memory)) {
-#if SWAP_PROCESS_DEBUG_LOG > 0
- printk(KERN_INFO "idletime compcache is ignored : free RAM %lu, free swap %lu\n",
- ramzswap_info.freeram, ramzswap_info.freeswap);
-#endif
- lmk_kill_ok = 0;
- return size;
- }
-
- read_lock(&tasklist_lock);
- for_each_process(p) {
- if ((p->pid == lmk_kill_pid) &&
- (__task_cred(p)->uid > 10000)) {
- task_lock(p);
- selected = p;
- if (!selected->mm || !selected->signal) {
- task_unlock(p);
- selected = NULL;
- break;
- }
- mm_scan = selected->mm;
- if (mm_scan) {
- if (selected->flags & PF_KTHREAD)
- mm_scan = NULL;
- else
- atomic_inc(&mm_scan->mm_users);
- }
- task_unlock(selected);
-
-#if SWAP_PROCESS_DEBUG_LOG > 0
- printk(KERN_INFO "idle time compcache: swap process pid %d, name %s, oom %d, task size %ld\n",
- p->pid, p->comm,
- p->signal->oom_adj,
- get_mm_rss(p->mm));
-#endif
- break;
- }
- }
- read_unlock(&tasklist_lock);
-
- if (mm_scan) {
- LIST_HEAD(zone0_page_list);
- LIST_HEAD(zone1_page_list);
- int pages_tofree = 0, pages_freed = 0;
-
- down_read(&mm_scan->mmap_sem);
- pages_tofree =
- shrink_pages(mm_scan, &zone0_page_list,
- &zone1_page_list, 0x7FFFFFFF);
- up_read(&mm_scan->mmap_sem);
- mmput(mm_scan);
- pages_freed =
- swap_pages(&zone0_page_list,
- &zone1_page_list);
- lmk_kill_ok = 0;
-
- }
- }
-
- return size;
-}
-
-static DEVICE_ATTR(lmk_state, 0664, lmk_state_show, lmk_state_store);
-
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
static int __init lowmem_init(void)
{
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- struct zone *zone;
- unsigned int high_wmark = 0;
-#endif
task_free_register(&task_nb);
register_shrinker(&lowmem_shrinker);
-
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- for_each_zone(zone) {
- if (high_wmark < zone->watermark[WMARK_HIGH])
- high_wmark = zone->watermark[WMARK_HIGH];
- }
- check_free_memory = (high_wmark != 0) ? high_wmark : CHECK_FREE_MEMORY;
-
- lmk_class = class_create(THIS_MODULE, "lmk");
- if (IS_ERR(lmk_class)) {
- printk(KERN_ERR "Failed to create class(lmk)\n");
- return 0;
- }
- lmk_dev = device_create(lmk_class, NULL, 0, NULL, "lowmemorykiller");
- if (IS_ERR(lmk_dev)) {
- printk(KERN_ERR
- "Failed to create device(lowmemorykiller)!= %ld\n",
- IS_ERR(lmk_dev));
- return 0;
- }
- if (device_create_file(lmk_dev, &dev_attr_lmk_state) < 0)
- printk(KERN_ERR "Failed to create device file(%s)!\n",
- dev_attr_lmk_state.attr.name);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
return 0;
}
diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig
index 06f741a..3bec4db 100644
--- a/drivers/staging/zram/Kconfig
+++ b/drivers/staging/zram/Kconfig
@@ -28,10 +28,3 @@ config ZRAM_DEBUG
help
This option adds additional debugging code to the compressed
RAM block device driver.
-
-config ZRAM_FOR_ANDROID
- bool "Optimize zram behavior for android"
- depends on ZRAM && ANDROID
- default n
- help
- This option enables modified zram behavior optimized for android
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 5258c78..aab4ec4 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -32,16 +32,12 @@
#include <linux/lzo.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-#include <linux/swap.h>
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
#include "zram_drv.h"
/* Globals */
static int zram_major;
-struct zram *zram_devices;
+struct zram *devices;
/* Module params (documentation at end) */
unsigned int num_devices;
@@ -137,22 +133,6 @@ static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
zram->disksize &= PAGE_MASK;
}
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-/*
- * Swap header (1st page of swap device) contains information
- * about a swap file/partition. Prepare such a header for the
- * given ramzswap device so that swapon can identify it as a
- * swap partition.
- */
-static void setup_swap_header(struct zram *zram, union swap_header *s)
-{
- s->info.version = 1;
- s->info.last_page = (zram->disksize >> PAGE_SHIFT) - 1;
- s->info.nr_badpages = 0;
- memcpy(s->magic.magic, "SWAPSPACE2", 10);
-}
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
static void zram_free_page(struct zram *zram, size_t index)
{
u32 clen;
@@ -521,10 +501,6 @@ int zram_init_device(struct zram *zram)
{
int ret;
size_t num_pages;
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- struct page *page;
- union swap_header *swap_header;
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
mutex_lock(&zram->init_lock);
@@ -559,19 +535,6 @@ int zram_init_device(struct zram *zram)
goto fail;
}
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- page = alloc_page(__GFP_ZERO);
- if (!page) {
- pr_err("Error allocating swap header page\n");
- ret = -ENOMEM;
- goto fail;
- }
- zram->table[0].page = page;
- zram_set_flag(zram, 0, ZRAM_UNCOMPRESSED);
- swap_header = kmap(page);
- setup_swap_header(zram, swap_header);
- kunmap(page);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
/* zram devices sort of resembles non-rotational disks */
@@ -715,14 +678,14 @@ static int __init zram_init(void)
/* Allocate the device array and initialize each one */
pr_info("Creating %u devices ...\n", num_devices);
- zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
- if (!zram_devices) {
+ devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
+ if (!devices) {
ret = -ENOMEM;
goto unregister;
}
for (dev_id = 0; dev_id < num_devices; dev_id++) {
- ret = create_device(&zram_devices[dev_id], dev_id);
+ ret = create_device(&devices[dev_id], dev_id);
if (ret)
goto free_devices;
}
@@ -731,8 +694,8 @@ static int __init zram_init(void)
free_devices:
while (dev_id)
- destroy_device(&zram_devices[--dev_id]);
- kfree(zram_devices);
+ destroy_device(&devices[--dev_id]);
+ kfree(devices);
unregister:
unregister_blkdev(zram_major, "zram");
out:
@@ -745,7 +708,7 @@ static void __exit zram_exit(void)
struct zram *zram;
for (i = 0; i < num_devices; i++) {
- zram = &zram_devices[i];
+ zram = &devices[i];
destroy_device(zram);
if (zram->init_done)
@@ -754,7 +717,7 @@ static void __exit zram_exit(void)
unregister_blkdev(zram_major, "zram");
- kfree(zram_devices);
+ kfree(devices);
pr_debug("Cleanup done!\n");
}
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index 3ad9486..408b2c0 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -120,7 +120,7 @@ struct zram {
struct zram_stats stats;
};
-extern struct zram *zram_devices;
+extern struct zram *devices;
extern unsigned int num_devices;
#ifdef CONFIG_SYSFS
extern struct attribute_group zram_disk_attr_group;
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
index 8a23554..6996eb3 100644
--- a/drivers/staging/zram/zram_sysfs.c
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -35,7 +35,7 @@ static struct zram *dev_to_zram(struct device *dev)
struct zram *zram = NULL;
for (i = 0; i < num_devices; i++) {
- zram = &zram_devices[i];
+ zram = &devices[i];
if (disk_to_dev(zram->disk) == dev)
break;
}
@@ -80,41 +80,12 @@ static ssize_t initstate_show(struct device *dev,
return sprintf(buf, "%u\n", zram->init_done);
}
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-extern int swapon(const char*specialfile, int swap_flags);
-
-static ssize_t initstate_store(struct device *dev,
- struct device_attribute *attr, const char *buf,
- size_t len)
-{
- int ret;
- unsigned long do_init;
- struct zram *zram = dev_to_zram(dev);
-
- if (zram->init_done) {
- pr_info("the device is initialized device\n");
- return -EBUSY;
- }
-
- ret = strict_strtoul(buf, 10, &do_init);
- if (ret)
- return ret;
- if (!do_init)
- return -EINVAL;
-
- zram_init_device(zram);
- swapon("/dev/block/zram0", 0);
- return len;
-}
-#else
static inline ssize_t initstate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
return 0;
}
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
static ssize_t reset_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 0f230ce..059839c 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -198,9 +198,6 @@ struct vm_area_struct {
#ifdef CONFIG_NUMA
struct mempolicy *vm_policy; /* NUMA policy for the VMA */
#endif
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- int vma_swap_done;
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
};
struct core_thread {
@@ -333,9 +330,6 @@ struct mm_struct {
#ifdef CONFIG_CPUMASK_OFFSTACK
struct cpumask cpumask_allocation;
#endif
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- int mm_swap_done;
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
};
static inline void mm_init_cpumask(struct mm_struct *mm)
diff --git a/kernel/power/earlysuspend.c b/kernel/power/earlysuspend.c
index e6303fd..f0fb629 100644
--- a/kernel/power/earlysuspend.c
+++ b/kernel/power/earlysuspend.c
@@ -20,9 +20,6 @@
#include <linux/syscalls.h> /* sys_sync */
#include <linux/wakelock.h>
#include <linux/workqueue.h>
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-#include <asm/atomic.h>
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
#include "power.h"
@@ -32,10 +29,6 @@ enum {
DEBUG_VERBOSE = 1U << 3,
};
static int debug_mask = DEBUG_USER_STATE;
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-atomic_t optimize_comp_on = ATOMIC_INIT(0);
-EXPORT_SYMBOL(optimize_comp_on);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
@@ -102,9 +95,6 @@ static void early_suspend(struct work_struct *work)
mutex_lock(&early_suspend_lock);
spin_lock_irqsave(&state_lock, irqflags);
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- atomic_set(&optimize_comp_on, 1);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
if (state == SUSPEND_REQUESTED)
state |= SUSPENDED;
else
@@ -156,9 +146,6 @@ static void late_resume(struct work_struct *work)
mutex_lock(&early_suspend_lock);
spin_lock_irqsave(&state_lock, irqflags);
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- atomic_set(&optimize_comp_on, 0);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
if (state == SUSPENDED)
state &= ~SUSPENDED;
else
diff --git a/mm/shmem.c b/mm/shmem.c
index a858b67..bcfa97d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1060,17 +1060,8 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
info = SHMEM_I(inode);
if (info->flags & VM_LOCKED)
goto redirty;
-#ifdef CONFIG_ZRAM_FOR_ANDROID
- /*
- * Modification for compcache
- * shmem_writepage can be reason of kernel panic when using swap.
- * This modification prevent using swap by shmem.
- */
- goto redirty;
-#else
if (!total_swap_pages)
goto redirty;
-#endif
/*
* shmem_backing_dev_info's capabilities prevent regular writeback or
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 3e5a3a7..c8f4338 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2012,159 +2012,6 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p,
return nr_extents;
}
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-int swapon(char *name, int swap_flags)
-{
- struct swap_info_struct *p;
-
- struct file *swap_file = NULL;
- struct address_space *mapping;
- int i;
- int prio;
- int error;
- union swap_header *swap_header;
- int nr_extents;
- sector_t span;
- unsigned long maxpages;
- unsigned char *swap_map = NULL;
- struct page *page = NULL;
- struct inode *inode = NULL;
-
- p = alloc_swap_info();
- if (IS_ERR(p))
- return PTR_ERR(p);
-
- swap_file = filp_open(name, O_RDWR | O_LARGEFILE, 0);
- if (IS_ERR(swap_file)) {
- error = PTR_ERR(swap_file);
- swap_file = NULL;
- printk("zfqin, filp_open failed\n");
- goto bad_swap;
- }
-
- printk("zfqin, filp_open succeeded\n");
- p->swap_file = swap_file;
- mapping = swap_file->f_mapping;
-
- for (i = 0; i < nr_swapfiles; i++) {
- struct swap_info_struct *q = swap_info[i];
-
- if (q == p || !q->swap_file)
- continue;
- if (mapping == q->swap_file->f_mapping) {
- error = -EBUSY;
- goto bad_swap;
- }
- }
-
- inode = mapping->host;
- /* If S_ISREG(inode->i_mode) will do mutex_lock(&inode->i_mutex); */
- error = claim_swapfile(p, inode);
- if (unlikely(error))
- goto bad_swap;
-
- /*
- * Read the swap header.
- */
- if (!mapping->a_ops->readpage) {
- error = -EINVAL;
- goto bad_swap;
- }
- page = read_mapping_page(mapping, 0, swap_file);
- if (IS_ERR(page)) {
- error = PTR_ERR(page);
- goto bad_swap;
- }
- swap_header = kmap(page);
-
- maxpages = read_swap_header(p, swap_header, inode);
- if (unlikely(!maxpages)) {
- error = -EINVAL;
- goto bad_swap;
- }
-
- /* OK, set up the swap map and apply the bad block list */
- swap_map = vzalloc(maxpages);
- if (!swap_map) {
- error = -ENOMEM;
- goto bad_swap;
- }
-
- error = swap_cgroup_swapon(p->type, maxpages);
- if (error)
- goto bad_swap;
-
- nr_extents = setup_swap_map_and_extents(p, swap_header, swap_map,
- maxpages, &span);
- if (unlikely(nr_extents < 0)) {
- error = nr_extents;
- goto bad_swap;
- }
-
- if (p->bdev) {
- if (blk_queue_nonrot(bdev_get_queue(p->bdev))) {
- p->flags |= SWP_SOLIDSTATE;
- p->cluster_next = 1 + (random32() % p->highest_bit);
- }
- if (discard_swap(p) == 0 && (swap_flags & SWAP_FLAG_DISCARD))
- p->flags |= SWP_DISCARDABLE;
- }
-
- mutex_lock(&swapon_mutex);
- prio = -1;
- if (swap_flags & SWAP_FLAG_PREFER)
- prio =
- (swap_flags & SWAP_FLAG_PRIO_MASK) >> SWAP_FLAG_PRIO_SHIFT;
- enable_swap_info(p, prio, swap_map);
-
- printk(KERN_INFO "Adding %uk swap on %s. "
- "Priority:%d extents:%d across:%lluk %s%s\n",
- p->pages << (PAGE_SHIFT - 10), name, p->prio,
- nr_extents, (unsigned long long)span << (PAGE_SHIFT - 10),
- (p->flags & SWP_SOLIDSTATE) ? "SS" : "",
- (p->flags & SWP_DISCARDABLE) ? "D" : "");
-
- mutex_unlock(&swapon_mutex);
- atomic_inc(&proc_poll_event);
- wake_up_interruptible(&proc_poll_wait);
-
- if (S_ISREG(inode->i_mode))
- inode->i_flags |= S_SWAPFILE;
- error = 0;
- goto out;
- bad_swap:
- if (inode && S_ISBLK(inode->i_mode) && p->bdev) {
- set_blocksize(p->bdev, p->old_block_size);
- blkdev_put(p->bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
- }
- destroy_swap_extents(p);
- swap_cgroup_swapoff(p->type);
- spin_lock(&swap_lock);
- p->swap_file = NULL;
- p->flags = 0;
- spin_unlock(&swap_lock);
- vfree(swap_map);
- if (swap_file) {
- if (inode && S_ISREG(inode->i_mode)) {
- mutex_unlock(&inode->i_mutex);
- inode = NULL;
- }
- filp_close(swap_file, NULL);
- }
- out:
- if (page && !IS_ERR(page)) {
- kunmap(page);
- page_cache_release(page);
- }
-
- if (inode && S_ISREG(inode->i_mode))
- mutex_unlock(&inode->i_mutex);
- return error;
-}
-
-EXPORT_SYMBOL(swapon);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
{
struct swap_info_struct *p;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 99082fa..08f11e2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -770,9 +770,6 @@ static noinline_for_stack void free_page_list(struct list_head *free_pages)
/*
* shrink_page_list() returns the number of reclaimed pages
*/
-#ifndef CONFIG_ZRAM_FOR_ANDROID
-static
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
unsigned long shrink_page_list(struct list_head *page_list,
struct zone *zone,
struct scan_control *sc)
@@ -1279,9 +1276,6 @@ static unsigned long isolate_pages_global(unsigned long nr,
* clear_active_flags() is a helper for shrink_active_list(), clearing
* any active bits from the pages in the list.
*/
-#ifndef CONFIG_ZRAM_FOR_ANDROID
-static
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
unsigned long clear_active_flags(struct list_head *page_list,
unsigned int *count)
{
@@ -1352,40 +1346,6 @@ int isolate_lru_page(struct page *page)
return ret;
}
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-/**
- * isolate_lru_page_compcache - tries to isolate a page for compcache
- * @page: page to isolate from its LRU list
- *
- * Isolates a @page from an LRU list, clears PageLRU,but
- * does not adjusts the vmstat statistic
- * Returns 0 if the page was removed from an LRU list.
- * Returns -EBUSY if the page was not on an LRU list.
- */
-int isolate_lru_page_compcache(struct page *page)
-{
- int ret = -EBUSY;
-
- VM_BUG_ON(!page_count(page));
-
- if (PageLRU(page)) {
- struct zone *zone = page_zone(page);
-
- spin_lock_irq(&zone->lru_lock);
- if (PageLRU(page)) {
- int lru = page_lru(page);
- ret = 0;
- get_page(page);
- ClearPageLRU(page);
- list_del(&page->lru);
- mem_cgroup_del_lru_list(page, lru);
- }
- spin_unlock_irq(&zone->lru_lock);
- }
- return ret;
-}
-#endif
-
/*
* Are there way too many processes in the direct reclaim path already?
*/
@@ -1622,44 +1582,6 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,
return nr_reclaimed;
}
-#ifdef CONFIG_ZRAM_FOR_ANDROID
-unsigned long
-zone_id_shrink_pagelist(struct zone *zone, struct list_head *page_list)
-{
- unsigned long nr_reclaimed = 0;
- unsigned long nr_anon;
- unsigned long nr_file;
-
- struct scan_control sc = {
- .gfp_mask = GFP_USER,
- .may_writepage = 1,
- .nr_to_reclaim = SWAP_CLUSTER_MAX,
- .may_unmap = 1,
- .may_swap = 1,
- .swappiness = vm_swappiness,
- .order = 0,
- .mem_cgroup = NULL,
- .nodemask = NULL,
- };
-
- spin_lock_irq(&zone->lru_lock);
-
- update_isolated_counts(zone, &sc, &nr_anon, &nr_file, page_list);
-
- spin_unlock_irq(&zone->lru_lock);
-
- nr_reclaimed = shrink_page_list(page_list, zone, &sc);
-
- __count_zone_vm_events(PGSTEAL, zone, nr_reclaimed);
-
- putback_lru_pages(zone, &sc, nr_anon, nr_file, page_list);
-
- return nr_reclaimed;
-}
-
-EXPORT_SYMBOL(zone_id_shrink_pagelist);
-#endif /* CONFIG_ZRAM_FOR_ANDROID */
-
/*
* This moves pages from the active list to the inactive list.
*