Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1577593 > unrolled thread
| Started by | peter enderborg <peter.enderborg@sonymobile.com> |
|---|---|
| First post | 2017-02-09 14:40 +0100 |
| Last post | 2017-02-10 12:10 +0100 |
| Articles | 13 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller peter enderborg <peter.enderborg@sonymobile.com> - 2017-02-09 14:40 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-09 15:10 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Michal Hocko <mhocko@kernel.org> - 2017-02-09 20:30 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-09 21:40 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Michal Hocko <mhocko@kernel.org> - 2017-02-09 22:00 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller peter enderborg <peter.enderborg@sonymobile.com> - 2017-02-10 09:00 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Michal Hocko <mhocko@kernel.org> - 2017-02-10 09:00 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller peter enderborg <peter.enderborg@sonymobile.com> - 2017-02-10 10:20 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Michal Hocko <mhocko@kernel.org> - 2017-02-10 10:20 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller peter enderborg <peter.enderborg@sonymobile.com> - 2017-02-13 16:50 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-10 09:00 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller peter enderborg <peter.enderborg@sonymobile.com> - 2017-02-10 10:20 +0100
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-10 12:10 +0100
| From | peter enderborg <peter.enderborg@sonymobile.com> |
|---|---|
| Date | 2017-02-09 14:40 +0100 |
| Subject | [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller |
| Message-ID | <t8X76-6JS-79@gated-at.bofh.it> |
This collects stats for shrinker calls and how much
waste work we do within the lowmemorykiller.
Signed-off-by: Peter Enderborg <peter.enderborg@sonymobile.com>
---
drivers/staging/android/Kconfig | 11 ++++
drivers/staging/android/Makefile | 1 +
drivers/staging/android/lowmemorykiller.c | 9 ++-
drivers/staging/android/lowmemorykiller_stats.c | 85 +++++++++++++++++++++++++
drivers/staging/android/lowmemorykiller_stats.h | 29 +++++++++
5 files changed, 134 insertions(+), 1 deletion(-)
create mode 100644 drivers/staging/android/lowmemorykiller_stats.c
create mode 100644 drivers/staging/android/lowmemorykiller_stats.h
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 6c00d6f..96e86c7 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -24,6 +24,17 @@ config ANDROID_LOW_MEMORY_KILLER
scripts (/init.rc), and it defines priority values with minimum free memory size
for each priority.
+config ANDROID_LOW_MEMORY_KILLER_STATS
+ bool "Android Low Memory Killer: collect statistics"
+ depends on ANDROID_LOW_MEMORY_KILLER
+ default n
+ help
+ Create a file in /proc/lmkstats that includes
+ collected statistics about kills, scans and counts
+ and interaction with the shrinker. Its content
+ will be different depeding on lmk implementation used.
+
+
source "drivers/staging/android/ion/Kconfig"
endif # if ANDROID
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index 7ed1be7..d710eb2 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -4,3 +4,4 @@ obj-y += ion/
obj-$(CONFIG_ASHMEM) += ashmem.o
obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
+obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER_STATS) += lowmemorykiller_stats.o
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index ec3b665..15c1b38 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -42,6 +42,7 @@
#include <linux/rcupdate.h>
#include <linux/profile.h>
#include <linux/notifier.h>
+#include "lowmemorykiller_stats.h"
static u32 lowmem_debug_level = 1;
static short lowmem_adj[6] = {
@@ -72,6 +73,7 @@ static unsigned long lowmem_deathpending_timeout;
static unsigned long lowmem_count(struct shrinker *s,
struct shrink_control *sc)
{
+ lmk_inc_stats(LMK_COUNT);
return global_node_page_state(NR_ACTIVE_ANON) +
global_node_page_state(NR_ACTIVE_FILE) +
global_node_page_state(NR_INACTIVE_ANON) +
@@ -95,6 +97,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
global_node_page_state(NR_SHMEM) -
total_swapcache_pages();
+ lmk_inc_stats(LMK_SCAN);
if (lowmem_adj_size < array_size)
array_size = lowmem_adj_size;
if (lowmem_minfree_size < array_size)
@@ -134,6 +137,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
if (task_lmk_waiting(p) &&
time_before_eq(jiffies, lowmem_deathpending_timeout)) {
task_unlock(p);
+ lmk_inc_stats(LMK_TIMEOUT);
rcu_read_unlock();
return 0;
}
@@ -179,7 +183,9 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
other_free * (long)(PAGE_SIZE / 1024));
lowmem_deathpending_timeout = jiffies + HZ;
rem += selected_tasksize;
- }
+ lmk_inc_stats(LMK_KILL);
+ } else
+ lmk_inc_stats(LMK_WASTE);
lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
sc->nr_to_scan, sc->gfp_mask, rem);
@@ -196,6 +202,7 @@ static struct shrinker lowmem_shrinker = {
static int __init lowmem_init(void)
{
register_shrinker(&lowmem_shrinker);
+ init_procfs_lmk();
return 0;
}
device_initcall(lowmem_init);
diff --git a/drivers/staging/android/lowmemorykiller_stats.c b/drivers/staging/android/lowmemorykiller_stats.c
new file mode 100644
index 0000000..673691c
--- /dev/null
+++ b/drivers/staging/android/lowmemorykiller_stats.c
@@ -0,0 +1,85 @@
+/*
+ * lowmemorykiller_stats
+ *
+ * Copyright (C) 2017 Sony Mobile Communications Inc.
+ *
+ * Author: Peter Enderborg <peter.enderborg@sonymobile.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/* This code is bookkeeping of statistical information
+ * from lowmemorykiller and provide a node in proc "/proc/lmkstats".
+ */
+
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include "lowmemorykiller_stats.h"
+
+struct lmk_stats {
+ atomic_long_t scans; /* counter as in shrinker scans */
+ atomic_long_t kills; /* the number of sigkills sent */
+ atomic_long_t waste; /* the numer of extensive calls that did
+ * not lead to anything
+ */
+ atomic_long_t timeout; /* counter for shrinker calls that needed
+ * to be cancelled due to pending kills
+ */
+ atomic_long_t count; /* number of shrinker count calls */
+ atomic_long_t unknown; /* internal */
+} st;
+
+void lmk_inc_stats(int key)
+{
+ switch (key) {
+ case LMK_SCAN:
+ atomic_long_inc(&st.scans);
+ break;
+ case LMK_KILL:
+ atomic_long_inc(&st.kills);
+ break;
+ case LMK_WASTE:
+ atomic_long_inc(&st.waste);
+ break;
+ case LMK_TIMEOUT:
+ atomic_long_inc(&st.timeout);
+ break;
+ case LMK_COUNT:
+ atomic_long_inc(&st.count);
+ break;
+ default:
+ atomic_long_inc(&st.unknown);
+ break;
+ }
+}
+
+static int lmk_proc_show(struct seq_file *m, void *v)
+{
+ seq_printf(m, "kill: %ld\n", atomic_long_read(&st.kills));
+ seq_printf(m, "scan: %ld\n", atomic_long_read(&st.scans));
+ seq_printf(m, "waste: %ld\n", atomic_long_read(&st.waste));
+ seq_printf(m, "timeout: %ld\n", atomic_long_read(&st.timeout));
+ seq_printf(m, "count: %ld\n", atomic_long_read(&st.count));
+ seq_printf(m, "unknown: %ld (internal)\n",
+ atomic_long_read(&st.unknown));
+
+ return 0;
+}
+
+static int lmk_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, lmk_proc_show, PDE_DATA(inode));
+}
+
+static const struct file_operations lmk_proc_fops = {
+ .open = lmk_proc_open,
+ .read = seq_read,
+ .release = single_release
+};
+
+int __init init_procfs_lmk(void)
+{
+ proc_create_data(LMK_PROCFS_NAME, 0444, NULL, &lmk_proc_fops, NULL);
+ return 0;
+}
diff --git a/drivers/staging/android/lowmemorykiller_stats.h b/drivers/staging/android/lowmemorykiller_stats.h
new file mode 100644
index 0000000..abeb6924
--- /dev/null
+++ b/drivers/staging/android/lowmemorykiller_stats.h
@@ -0,0 +1,29 @@
+/*
+ * lowmemorykiller_stats interface
+ *
+ * Copyright (C) 2017 Sony Mobile Communications Inc.
+ *
+ * Author: Peter Enderborg <peter.enderborg@sonymobile.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+enum lmk_kill_stats {
+ LMK_SCAN = 1,
+ LMK_KILL = 2,
+ LMK_WASTE = 3,
+ LMK_TIMEOUT = 4,
+ LMK_COUNT = 5
+};
+
+#define LMK_PROCFS_NAME "lmkstats"
+
+#ifdef CONFIG_ANDROID_LOW_MEMORY_KILLER_STATS
+void lmk_inc_stats(int key);
+int __init init_procfs_lmk(void);
+#else
+static inline void lmk_inc_stats(int key) { return; };
+static inline int __init init_procfs_lmk(void) { return 0; };
+#endif
--
2.4.2
[toc] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-02-09 15:10 +0100 |
| Message-ID | <t8XA5-79s-9@gated-at.bofh.it> |
| In reply to | #1577593 |
On Thu, Feb 09, 2017 at 02:21:45PM +0100, peter enderborg wrote:
> This collects stats for shrinker calls and how much
> waste work we do within the lowmemorykiller.
>
> Signed-off-by: Peter Enderborg <peter.enderborg@sonymobile.com>
> ---
> drivers/staging/android/Kconfig | 11 ++++
> drivers/staging/android/Makefile | 1 +
> drivers/staging/android/lowmemorykiller.c | 9 ++-
> drivers/staging/android/lowmemorykiller_stats.c | 85 +++++++++++++++++++++++++
> drivers/staging/android/lowmemorykiller_stats.h | 29 +++++++++
> 5 files changed, 134 insertions(+), 1 deletion(-)
> create mode 100644 drivers/staging/android/lowmemorykiller_stats.c
> create mode 100644 drivers/staging/android/lowmemorykiller_stats.h
>
> diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
> index 6c00d6f..96e86c7 100644
> --- a/drivers/staging/android/Kconfig
> +++ b/drivers/staging/android/Kconfig
> @@ -24,6 +24,17 @@ config ANDROID_LOW_MEMORY_KILLER
> scripts (/init.rc), and it defines priority values with minimum free memory size
> for each priority.
>
> +config ANDROID_LOW_MEMORY_KILLER_STATS
> + bool "Android Low Memory Killer: collect statistics"
> + depends on ANDROID_LOW_MEMORY_KILLER
> + default n
> + help
> + Create a file in /proc/lmkstats that includes
> + collected statistics about kills, scans and counts
> + and interaction with the shrinker. Its content
> + will be different depeding on lmk implementation used.
> +
> +
> source "drivers/staging/android/ion/Kconfig"
>
> endif # if ANDROID
> diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
> index 7ed1be7..d710eb2 100644
> --- a/drivers/staging/android/Makefile
> +++ b/drivers/staging/android/Makefile
> @@ -4,3 +4,4 @@ obj-y += ion/
>
> obj-$(CONFIG_ASHMEM) += ashmem.o
> obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
> +obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER_STATS) += lowmemorykiller_stats.o
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> index ec3b665..15c1b38 100644
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ b/drivers/staging/android/lowmemorykiller.c
> @@ -42,6 +42,7 @@
> #include <linux/rcupdate.h>
> #include <linux/profile.h>
> #include <linux/notifier.h>
> +#include "lowmemorykiller_stats.h"
>
> static u32 lowmem_debug_level = 1;
> static short lowmem_adj[6] = {
> @@ -72,6 +73,7 @@ static unsigned long lowmem_deathpending_timeout;
> static unsigned long lowmem_count(struct shrinker *s,
> struct shrink_control *sc)
> {
> + lmk_inc_stats(LMK_COUNT);
> return global_node_page_state(NR_ACTIVE_ANON) +
> global_node_page_state(NR_ACTIVE_FILE) +
> global_node_page_state(NR_INACTIVE_ANON) +
Your patch is corrupted and can not be applied :(
all of them are like this.
greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-02-09 20:30 +0100 |
| Message-ID | <t92zM-1JF-25@gated-at.bofh.it> |
| In reply to | #1577593 |
On Thu 09-02-17 14:21:45, peter enderborg wrote:
> This collects stats for shrinker calls and how much
> waste work we do within the lowmemorykiller.
This doesn't explain why do we need this information and who is going to
use it. Not to mention it exports it in /proc which is considered a
stable user API. This is a no-go, especially for something that is still
lingering in the staging tree without any actuall effort to make it
fully supported MM feature. I am actually strongly inclined to simply
drop lmk from the tree completely.
> Signed-off-by: Peter Enderborg <peter.enderborg@sonymobile.com>
Nacked-by: Michal Hocko <mhocko@suse.com>
> ---
> drivers/staging/android/Kconfig | 11 ++++
> drivers/staging/android/Makefile | 1 +
> drivers/staging/android/lowmemorykiller.c | 9 ++-
> drivers/staging/android/lowmemorykiller_stats.c | 85 +++++++++++++++++++++++++
> drivers/staging/android/lowmemorykiller_stats.h | 29 +++++++++
> 5 files changed, 134 insertions(+), 1 deletion(-)
> create mode 100644 drivers/staging/android/lowmemorykiller_stats.c
> create mode 100644 drivers/staging/android/lowmemorykiller_stats.h
>
> diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
> index 6c00d6f..96e86c7 100644
> --- a/drivers/staging/android/Kconfig
> +++ b/drivers/staging/android/Kconfig
> @@ -24,6 +24,17 @@ config ANDROID_LOW_MEMORY_KILLER
> scripts (/init.rc), and it defines priority values with minimum free memory size
> for each priority.
>
> +config ANDROID_LOW_MEMORY_KILLER_STATS
> + bool "Android Low Memory Killer: collect statistics"
> + depends on ANDROID_LOW_MEMORY_KILLER
> + default n
> + help
> + Create a file in /proc/lmkstats that includes
> + collected statistics about kills, scans and counts
> + and interaction with the shrinker. Its content
> + will be different depeding on lmk implementation used.
> +
> +
> source "drivers/staging/android/ion/Kconfig"
>
> endif # if ANDROID
> diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
> index 7ed1be7..d710eb2 100644
> --- a/drivers/staging/android/Makefile
> +++ b/drivers/staging/android/Makefile
> @@ -4,3 +4,4 @@ obj-y += ion/
>
> obj-$(CONFIG_ASHMEM) += ashmem.o
> obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
> +obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER_STATS) += lowmemorykiller_stats.o
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> index ec3b665..15c1b38 100644
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ b/drivers/staging/android/lowmemorykiller.c
> @@ -42,6 +42,7 @@
> #include <linux/rcupdate.h>
> #include <linux/profile.h>
> #include <linux/notifier.h>
> +#include "lowmemorykiller_stats.h"
>
> static u32 lowmem_debug_level = 1;
> static short lowmem_adj[6] = {
> @@ -72,6 +73,7 @@ static unsigned long lowmem_deathpending_timeout;
> static unsigned long lowmem_count(struct shrinker *s,
> struct shrink_control *sc)
> {
> + lmk_inc_stats(LMK_COUNT);
> return global_node_page_state(NR_ACTIVE_ANON) +
> global_node_page_state(NR_ACTIVE_FILE) +
> global_node_page_state(NR_INACTIVE_ANON) +
> @@ -95,6 +97,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> global_node_page_state(NR_SHMEM) -
> total_swapcache_pages();
>
> + lmk_inc_stats(LMK_SCAN);
> if (lowmem_adj_size < array_size)
> array_size = lowmem_adj_size;
> if (lowmem_minfree_size < array_size)
> @@ -134,6 +137,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> if (task_lmk_waiting(p) &&
> time_before_eq(jiffies, lowmem_deathpending_timeout)) {
> task_unlock(p);
> + lmk_inc_stats(LMK_TIMEOUT);
> rcu_read_unlock();
> return 0;
> }
> @@ -179,7 +183,9 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> other_free * (long)(PAGE_SIZE / 1024));
> lowmem_deathpending_timeout = jiffies + HZ;
> rem += selected_tasksize;
> - }
> + lmk_inc_stats(LMK_KILL);
> + } else
> + lmk_inc_stats(LMK_WASTE);
>
> lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
> sc->nr_to_scan, sc->gfp_mask, rem);
> @@ -196,6 +202,7 @@ static struct shrinker lowmem_shrinker = {
> static int __init lowmem_init(void)
> {
> register_shrinker(&lowmem_shrinker);
> + init_procfs_lmk();
> return 0;
> }
> device_initcall(lowmem_init);
> diff --git a/drivers/staging/android/lowmemorykiller_stats.c b/drivers/staging/android/lowmemorykiller_stats.c
> new file mode 100644
> index 0000000..673691c
> --- /dev/null
> +++ b/drivers/staging/android/lowmemorykiller_stats.c
> @@ -0,0 +1,85 @@
> +/*
> + * lowmemorykiller_stats
> + *
> + * Copyright (C) 2017 Sony Mobile Communications Inc.
> + *
> + * Author: Peter Enderborg <peter.enderborg@sonymobile.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +/* This code is bookkeeping of statistical information
> + * from lowmemorykiller and provide a node in proc "/proc/lmkstats".
> + */
> +
> +#include <linux/proc_fs.h>
> +#include <linux/seq_file.h>
> +#include "lowmemorykiller_stats.h"
> +
> +struct lmk_stats {
> + atomic_long_t scans; /* counter as in shrinker scans */
> + atomic_long_t kills; /* the number of sigkills sent */
> + atomic_long_t waste; /* the numer of extensive calls that did
> + * not lead to anything
> + */
> + atomic_long_t timeout; /* counter for shrinker calls that needed
> + * to be cancelled due to pending kills
> + */
> + atomic_long_t count; /* number of shrinker count calls */
> + atomic_long_t unknown; /* internal */
> +} st;
> +
> +void lmk_inc_stats(int key)
> +{
> + switch (key) {
> + case LMK_SCAN:
> + atomic_long_inc(&st.scans);
> + break;
> + case LMK_KILL:
> + atomic_long_inc(&st.kills);
> + break;
> + case LMK_WASTE:
> + atomic_long_inc(&st.waste);
> + break;
> + case LMK_TIMEOUT:
> + atomic_long_inc(&st.timeout);
> + break;
> + case LMK_COUNT:
> + atomic_long_inc(&st.count);
> + break;
> + default:
> + atomic_long_inc(&st.unknown);
> + break;
> + }
> +}
> +
> +static int lmk_proc_show(struct seq_file *m, void *v)
> +{
> + seq_printf(m, "kill: %ld\n", atomic_long_read(&st.kills));
> + seq_printf(m, "scan: %ld\n", atomic_long_read(&st.scans));
> + seq_printf(m, "waste: %ld\n", atomic_long_read(&st.waste));
> + seq_printf(m, "timeout: %ld\n", atomic_long_read(&st.timeout));
> + seq_printf(m, "count: %ld\n", atomic_long_read(&st.count));
> + seq_printf(m, "unknown: %ld (internal)\n",
> + atomic_long_read(&st.unknown));
> +
> + return 0;
> +}
> +
> +static int lmk_proc_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, lmk_proc_show, PDE_DATA(inode));
> +}
> +
> +static const struct file_operations lmk_proc_fops = {
> + .open = lmk_proc_open,
> + .read = seq_read,
> + .release = single_release
> +};
> +
> +int __init init_procfs_lmk(void)
> +{
> + proc_create_data(LMK_PROCFS_NAME, 0444, NULL, &lmk_proc_fops, NULL);
> + return 0;
> +}
> diff --git a/drivers/staging/android/lowmemorykiller_stats.h b/drivers/staging/android/lowmemorykiller_stats.h
> new file mode 100644
> index 0000000..abeb6924
> --- /dev/null
> +++ b/drivers/staging/android/lowmemorykiller_stats.h
> @@ -0,0 +1,29 @@
> +/*
> + * lowmemorykiller_stats interface
> + *
> + * Copyright (C) 2017 Sony Mobile Communications Inc.
> + *
> + * Author: Peter Enderborg <peter.enderborg@sonymobile.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +enum lmk_kill_stats {
> + LMK_SCAN = 1,
> + LMK_KILL = 2,
> + LMK_WASTE = 3,
> + LMK_TIMEOUT = 4,
> + LMK_COUNT = 5
> +};
> +
> +#define LMK_PROCFS_NAME "lmkstats"
> +
> +#ifdef CONFIG_ANDROID_LOW_MEMORY_KILLER_STATS
> +void lmk_inc_stats(int key);
> +int __init init_procfs_lmk(void);
> +#else
> +static inline void lmk_inc_stats(int key) { return; };
> +static inline int __init init_procfs_lmk(void) { return 0; };
> +#endif
> --
> 2.4.2
>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-02-09 21:40 +0100 |
| Message-ID | <t93Fv-2mP-1@gated-at.bofh.it> |
| In reply to | #1577897 |
On Thu, Feb 09, 2017 at 08:26:41PM +0100, Michal Hocko wrote: > On Thu 09-02-17 14:21:45, peter enderborg wrote: > > This collects stats for shrinker calls and how much > > waste work we do within the lowmemorykiller. > > This doesn't explain why do we need this information and who is going to > use it. Not to mention it exports it in /proc which is considered a > stable user API. This is a no-go, especially for something that is still > lingering in the staging tree without any actuall effort to make it > fully supported MM feature. I am actually strongly inclined to simply > drop lmk from the tree completely. I thought that someone was working to get the "native" mm features to work properly with the lmk "feature" Do you recall if that work got rejected, or just never happened? thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-02-09 22:00 +0100 |
| Message-ID | <t93YS-2u7-17@gated-at.bofh.it> |
| In reply to | #1577938 |
On Thu 09-02-17 21:07:37, Greg KH wrote:
> On Thu, Feb 09, 2017 at 08:26:41PM +0100, Michal Hocko wrote:
> > On Thu 09-02-17 14:21:45, peter enderborg wrote:
> > > This collects stats for shrinker calls and how much
> > > waste work we do within the lowmemorykiller.
> >
> > This doesn't explain why do we need this information and who is going to
> > use it. Not to mention it exports it in /proc which is considered a
> > stable user API. This is a no-go, especially for something that is still
> > lingering in the staging tree without any actuall effort to make it
> > fully supported MM feature. I am actually strongly inclined to simply
> > drop lmk from the tree completely.
>
> I thought that someone was working to get the "native" mm features to
> work properly with the lmk "feature" Do you recall if that work got
> rejected, or just never happened?
Never happened AFAIR. There were some attempts to tune the current
behavior which has been rejected for one reason or another but I am not
really aware of anybody working on moving the code from staging area.
I already have this in the to-send queue, just didn't get to post it yet
because I planned to polish the reasoning some more.
---
From 9f871b54a387e0a7cdfaf0fa256d1440093e427c Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.com>
Date: Wed, 1 Feb 2017 10:37:30 +0100
Subject: [PATCH] staging, android: remove lowmemory killer from the tree
Lowmemory killer is sitting in the staging tree since 2008 without any
serious interest for fixing issues brought up by the MM folks. The main
objection is that the implementation is basically broken by design:
- it hooks into slab shrinker API which is not suitable for this
purpose. lowmem_count implementation just shows this nicely.
There is no scaling based on the memory pressure and no
feedback to the generic shrinker infrastructure.
- it is not reclaim context aware - no NUMA and/or memcg
awareness.
As the code stands right now it just adds a maintenance overhead when
core MM changes have to update lowmemorykiller.c as well.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
drivers/staging/android/Kconfig | 10 --
drivers/staging/android/Makefile | 1 -
drivers/staging/android/lowmemorykiller.c | 212 ------------------------------
include/linux/sched.h | 4 -
4 files changed, 227 deletions(-)
delete mode 100644 drivers/staging/android/lowmemorykiller.c
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 6c00d6f765c6..71a50b99caff 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -14,16 +14,6 @@ config ASHMEM
It is, in theory, a good memory allocator for low-memory devices,
because it can discard shared memory units when under memory pressure.
-config ANDROID_LOW_MEMORY_KILLER
- bool "Android Low Memory Killer"
- ---help---
- Registers processes to be killed when low memory conditions, this is useful
- as there is no particular swap space on android.
-
- The registered process will kill according to the priorities in android init
- scripts (/init.rc), and it defines priority values with minimum free memory size
- for each priority.
-
source "drivers/staging/android/ion/Kconfig"
endif # if ANDROID
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index 7ed1be798909..7cf1564a49a5 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -3,4 +3,3 @@ ccflags-y += -I$(src) # needed for trace events
obj-y += ion/
obj-$(CONFIG_ASHMEM) += ashmem.o
-obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
deleted file mode 100644
index ec3b66561412..000000000000
--- a/drivers/staging/android/lowmemorykiller.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* drivers/misc/lowmemorykiller.c
- *
- * The lowmemorykiller driver lets user-space specify a set of memory thresholds
- * where processes with a range of oom_score_adj values will get killed. Specify
- * the minimum oom_score_adj values in
- * /sys/module/lowmemorykiller/parameters/adj and the number of free pages in
- * /sys/module/lowmemorykiller/parameters/minfree. Both files take a comma
- * separated list of numbers in ascending order.
- *
- * For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
- * "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill
- * processes with a oom_score_adj value of 8 or higher when the free memory
- * drops below 4096 pages and kill processes with a oom_score_adj value of 0 or
- * higher when the free memory drops below 1024 pages.
- *
- * The driver considers memory used for caches to be free, but if a large
- * percentage of the cached memory is locked this can be very inaccurate
- * and processes may not get killed until the normal oom killer is triggered.
- *
- * Copyright (C) 2007-2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/init.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/oom.h>
-#include <linux/sched.h>
-#include <linux/swap.h>
-#include <linux/rcupdate.h>
-#include <linux/profile.h>
-#include <linux/notifier.h>
-
-static u32 lowmem_debug_level = 1;
-static short lowmem_adj[6] = {
- 0,
- 1,
- 6,
- 12,
-};
-
-static int lowmem_adj_size = 4;
-static int lowmem_minfree[6] = {
- 3 * 512, /* 6MB */
- 2 * 1024, /* 8MB */
- 4 * 1024, /* 16MB */
- 16 * 1024, /* 64MB */
-};
-
-static int lowmem_minfree_size = 4;
-
-static unsigned long lowmem_deathpending_timeout;
-
-#define lowmem_print(level, x...) \
- do { \
- if (lowmem_debug_level >= (level)) \
- pr_info(x); \
- } while (0)
-
-static unsigned long lowmem_count(struct shrinker *s,
- struct shrink_control *sc)
-{
- return global_node_page_state(NR_ACTIVE_ANON) +
- global_node_page_state(NR_ACTIVE_FILE) +
- global_node_page_state(NR_INACTIVE_ANON) +
- global_node_page_state(NR_INACTIVE_FILE);
-}
-
-static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
-{
- struct task_struct *tsk;
- struct task_struct *selected = NULL;
- unsigned long rem = 0;
- int tasksize;
- int i;
- short min_score_adj = OOM_SCORE_ADJ_MAX + 1;
- int minfree = 0;
- int selected_tasksize = 0;
- short selected_oom_score_adj;
- int array_size = ARRAY_SIZE(lowmem_adj);
- int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
- int other_file = global_node_page_state(NR_FILE_PAGES) -
- global_node_page_state(NR_SHMEM) -
- total_swapcache_pages();
-
- if (lowmem_adj_size < array_size)
- array_size = lowmem_adj_size;
- if (lowmem_minfree_size < array_size)
- array_size = lowmem_minfree_size;
- for (i = 0; i < array_size; i++) {
- minfree = lowmem_minfree[i];
- if (other_free < minfree && other_file < minfree) {
- min_score_adj = lowmem_adj[i];
- break;
- }
- }
-
- lowmem_print(3, "lowmem_scan %lu, %x, ofree %d %d, ma %hd\n",
- sc->nr_to_scan, sc->gfp_mask, other_free,
- other_file, min_score_adj);
-
- if (min_score_adj == OOM_SCORE_ADJ_MAX + 1) {
- lowmem_print(5, "lowmem_scan %lu, %x, return 0\n",
- sc->nr_to_scan, sc->gfp_mask);
- return 0;
- }
-
- selected_oom_score_adj = min_score_adj;
-
- rcu_read_lock();
- for_each_process(tsk) {
- struct task_struct *p;
- short oom_score_adj;
-
- if (tsk->flags & PF_KTHREAD)
- continue;
-
- p = find_lock_task_mm(tsk);
- if (!p)
- continue;
-
- if (task_lmk_waiting(p) &&
- time_before_eq(jiffies, lowmem_deathpending_timeout)) {
- task_unlock(p);
- rcu_read_unlock();
- return 0;
- }
- oom_score_adj = p->signal->oom_score_adj;
- if (oom_score_adj < min_score_adj) {
- task_unlock(p);
- continue;
- }
- tasksize = get_mm_rss(p->mm);
- task_unlock(p);
- if (tasksize <= 0)
- continue;
- if (selected) {
- if (oom_score_adj < selected_oom_score_adj)
- continue;
- if (oom_score_adj == selected_oom_score_adj &&
- tasksize <= selected_tasksize)
- continue;
- }
- selected = p;
- selected_tasksize = tasksize;
- selected_oom_score_adj = oom_score_adj;
- lowmem_print(2, "select '%s' (%d), adj %hd, size %d, to kill\n",
- p->comm, p->pid, oom_score_adj, tasksize);
- }
- if (selected) {
- task_lock(selected);
- send_sig(SIGKILL, selected, 0);
- if (selected->mm)
- task_set_lmk_waiting(selected);
- task_unlock(selected);
- lowmem_print(1, "Killing '%s' (%d), adj %hd,\n"
- " to free %ldkB on behalf of '%s' (%d) because\n"
- " cache %ldkB is below limit %ldkB for oom_score_adj %hd\n"
- " Free memory is %ldkB above reserved\n",
- selected->comm, selected->pid,
- selected_oom_score_adj,
- selected_tasksize * (long)(PAGE_SIZE / 1024),
- current->comm, current->pid,
- other_file * (long)(PAGE_SIZE / 1024),
- minfree * (long)(PAGE_SIZE / 1024),
- min_score_adj,
- other_free * (long)(PAGE_SIZE / 1024));
- lowmem_deathpending_timeout = jiffies + HZ;
- rem += selected_tasksize;
- }
-
- lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
- sc->nr_to_scan, sc->gfp_mask, rem);
- rcu_read_unlock();
- return rem;
-}
-
-static struct shrinker lowmem_shrinker = {
- .scan_objects = lowmem_scan,
- .count_objects = lowmem_count,
- .seeks = DEFAULT_SEEKS * 16
-};
-
-static int __init lowmem_init(void)
-{
- register_shrinker(&lowmem_shrinker);
- return 0;
-}
-device_initcall(lowmem_init);
-
-/*
- * not really modular, but the easiest way to keep compat with existing
- * bootargs behaviour is to continue using module_param here.
- */
-module_param_named(cost, lowmem_shrinker.seeks, int, 0644);
-module_param_array_named(adj, lowmem_adj, short, &lowmem_adj_size, 0644);
-module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size,
- 0644);
-module_param_named(debug_level, lowmem_debug_level, uint, 0644);
-
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e93594b88130..3cc6c650fa6a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2347,7 +2347,6 @@ static inline void memalloc_noio_restore(unsigned int flags)
#define PFA_NO_NEW_PRIVS 0 /* May not gain new privileges. */
#define PFA_SPREAD_PAGE 1 /* Spread page cache over cpuset */
#define PFA_SPREAD_SLAB 2 /* Spread some slab caches over cpuset */
-#define PFA_LMK_WAITING 3 /* Lowmemorykiller is waiting */
#define TASK_PFA_TEST(name, func) \
@@ -2371,9 +2370,6 @@ TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
TASK_PFA_SET(SPREAD_SLAB, spread_slab)
TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)
-TASK_PFA_TEST(LMK_WAITING, lmk_waiting)
-TASK_PFA_SET(LMK_WAITING, lmk_waiting)
-
/*
* task->jobctl flags
*/
--
2.11.0
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | peter enderborg <peter.enderborg@sonymobile.com> |
|---|---|
| Date | 2017-02-10 09:00 +0100 |
| Message-ID | <t9ehA-xE-5@gated-at.bofh.it> |
| In reply to | #1577954 |
Im not speaking for google, but I think there is a work ongoing to
replace this with user-space code. Until then we have to polish
this version as good as we can. It is essential for android as it is now.
On 02/09/2017 09:54 PM, Michal Hocko wrote:
> On Thu 09-02-17 21:07:37, Greg KH wrote:
>> On Thu, Feb 09, 2017 at 08:26:41PM +0100, Michal Hocko wrote:
>>> On Thu 09-02-17 14:21:45, peter enderborg wrote:
>>>> This collects stats for shrinker calls and how much
>>>> waste work we do within the lowmemorykiller.
>>> This doesn't explain why do we need this information and who is going to
>>> use it. Not to mention it exports it in /proc which is considered a
>>> stable user API. This is a no-go, especially for something that is still
>>> lingering in the staging tree without any actuall effort to make it
>>> fully supported MM feature. I am actually strongly inclined to simply
>>> drop lmk from the tree completely.
>> I thought that someone was working to get the "native" mm features to
>> work properly with the lmk "feature" Do you recall if that work got
>> rejected, or just never happened?
> Never happened AFAIR. There were some attempts to tune the current
> behavior which has been rejected for one reason or another but I am not
> really aware of anybody working on moving the code from staging area.
>
> I already have this in the to-send queue, just didn't get to post it yet
> because I planned to polish the reasoning some more.
> ---
> From 9f871b54a387e0a7cdfaf0fa256d1440093e427c Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.com>
> Date: Wed, 1 Feb 2017 10:37:30 +0100
> Subject: [PATCH] staging, android: remove lowmemory killer from the tree
>
> Lowmemory killer is sitting in the staging tree since 2008 without any
> serious interest for fixing issues brought up by the MM folks. The main
> objection is that the implementation is basically broken by design:
> - it hooks into slab shrinker API which is not suitable for this
> purpose. lowmem_count implementation just shows this nicely.
> There is no scaling based on the memory pressure and no
> feedback to the generic shrinker infrastructure.
> - it is not reclaim context aware - no NUMA and/or memcg
> awareness.
>
> As the code stands right now it just adds a maintenance overhead when
> core MM changes have to update lowmemorykiller.c as well.
>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
> drivers/staging/android/Kconfig | 10 --
> drivers/staging/android/Makefile | 1 -
> drivers/staging/android/lowmemorykiller.c | 212 ------------------------------
> include/linux/sched.h | 4 -
> 4 files changed, 227 deletions(-)
> delete mode 100644 drivers/staging/android/lowmemorykiller.c
>
> diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
> index 6c00d6f765c6..71a50b99caff 100644
> --- a/drivers/staging/android/Kconfig
> +++ b/drivers/staging/android/Kconfig
> @@ -14,16 +14,6 @@ config ASHMEM
> It is, in theory, a good memory allocator for low-memory devices,
> because it can discard shared memory units when under memory pressure.
>
> -config ANDROID_LOW_MEMORY_KILLER
> - bool "Android Low Memory Killer"
> - ---help---
> - Registers processes to be killed when low memory conditions, this is useful
> - as there is no particular swap space on android.
> -
> - The registered process will kill according to the priorities in android init
> - scripts (/init.rc), and it defines priority values with minimum free memory size
> - for each priority.
> -
> source "drivers/staging/android/ion/Kconfig"
>
> endif # if ANDROID
> diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
> index 7ed1be798909..7cf1564a49a5 100644
> --- a/drivers/staging/android/Makefile
> +++ b/drivers/staging/android/Makefile
> @@ -3,4 +3,3 @@ ccflags-y += -I$(src) # needed for trace events
> obj-y += ion/
>
> obj-$(CONFIG_ASHMEM) += ashmem.o
> -obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
> diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
> deleted file mode 100644
> index ec3b66561412..000000000000
> --- a/drivers/staging/android/lowmemorykiller.c
> +++ /dev/null
> @@ -1,212 +0,0 @@
> -/* drivers/misc/lowmemorykiller.c
> - *
> - * The lowmemorykiller driver lets user-space specify a set of memory thresholds
> - * where processes with a range of oom_score_adj values will get killed. Specify
> - * the minimum oom_score_adj values in
> - * /sys/module/lowmemorykiller/parameters/adj and the number of free pages in
> - * /sys/module/lowmemorykiller/parameters/minfree. Both files take a comma
> - * separated list of numbers in ascending order.
> - *
> - * For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
> - * "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill
> - * processes with a oom_score_adj value of 8 or higher when the free memory
> - * drops below 4096 pages and kill processes with a oom_score_adj value of 0 or
> - * higher when the free memory drops below 1024 pages.
> - *
> - * The driver considers memory used for caches to be free, but if a large
> - * percentage of the cached memory is locked this can be very inaccurate
> - * and processes may not get killed until the normal oom killer is triggered.
> - *
> - * Copyright (C) 2007-2008 Google, Inc.
> - *
> - * This software is licensed under the terms of the GNU General Public
> - * License version 2, as published by the Free Software Foundation, and
> - * may be copied, distributed, and modified under those terms.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - */
> -
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
> -#include <linux/init.h>
> -#include <linux/moduleparam.h>
> -#include <linux/kernel.h>
> -#include <linux/mm.h>
> -#include <linux/oom.h>
> -#include <linux/sched.h>
> -#include <linux/swap.h>
> -#include <linux/rcupdate.h>
> -#include <linux/profile.h>
> -#include <linux/notifier.h>
> -
> -static u32 lowmem_debug_level = 1;
> -static short lowmem_adj[6] = {
> - 0,
> - 1,
> - 6,
> - 12,
> -};
> -
> -static int lowmem_adj_size = 4;
> -static int lowmem_minfree[6] = {
> - 3 * 512, /* 6MB */
> - 2 * 1024, /* 8MB */
> - 4 * 1024, /* 16MB */
> - 16 * 1024, /* 64MB */
> -};
> -
> -static int lowmem_minfree_size = 4;
> -
> -static unsigned long lowmem_deathpending_timeout;
> -
> -#define lowmem_print(level, x...) \
> - do { \
> - if (lowmem_debug_level >= (level)) \
> - pr_info(x); \
> - } while (0)
> -
> -static unsigned long lowmem_count(struct shrinker *s,
> - struct shrink_control *sc)
> -{
> - return global_node_page_state(NR_ACTIVE_ANON) +
> - global_node_page_state(NR_ACTIVE_FILE) +
> - global_node_page_state(NR_INACTIVE_ANON) +
> - global_node_page_state(NR_INACTIVE_FILE);
> -}
> -
> -static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
> -{
> - struct task_struct *tsk;
> - struct task_struct *selected = NULL;
> - unsigned long rem = 0;
> - int tasksize;
> - int i;
> - short min_score_adj = OOM_SCORE_ADJ_MAX + 1;
> - int minfree = 0;
> - int selected_tasksize = 0;
> - short selected_oom_score_adj;
> - int array_size = ARRAY_SIZE(lowmem_adj);
> - int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
> - int other_file = global_node_page_state(NR_FILE_PAGES) -
> - global_node_page_state(NR_SHMEM) -
> - total_swapcache_pages();
> -
> - if (lowmem_adj_size < array_size)
> - array_size = lowmem_adj_size;
> - if (lowmem_minfree_size < array_size)
> - array_size = lowmem_minfree_size;
> - for (i = 0; i < array_size; i++) {
> - minfree = lowmem_minfree[i];
> - if (other_free < minfree && other_file < minfree) {
> - min_score_adj = lowmem_adj[i];
> - break;
> - }
> - }
> -
> - lowmem_print(3, "lowmem_scan %lu, %x, ofree %d %d, ma %hd\n",
> - sc->nr_to_scan, sc->gfp_mask, other_free,
> - other_file, min_score_adj);
> -
> - if (min_score_adj == OOM_SCORE_ADJ_MAX + 1) {
> - lowmem_print(5, "lowmem_scan %lu, %x, return 0\n",
> - sc->nr_to_scan, sc->gfp_mask);
> - return 0;
> - }
> -
> - selected_oom_score_adj = min_score_adj;
> -
> - rcu_read_lock();
> - for_each_process(tsk) {
> - struct task_struct *p;
> - short oom_score_adj;
> -
> - if (tsk->flags & PF_KTHREAD)
> - continue;
> -
> - p = find_lock_task_mm(tsk);
> - if (!p)
> - continue;
> -
> - if (task_lmk_waiting(p) &&
> - time_before_eq(jiffies, lowmem_deathpending_timeout)) {
> - task_unlock(p);
> - rcu_read_unlock();
> - return 0;
> - }
> - oom_score_adj = p->signal->oom_score_adj;
> - if (oom_score_adj < min_score_adj) {
> - task_unlock(p);
> - continue;
> - }
> - tasksize = get_mm_rss(p->mm);
> - task_unlock(p);
> - if (tasksize <= 0)
> - continue;
> - if (selected) {
> - if (oom_score_adj < selected_oom_score_adj)
> - continue;
> - if (oom_score_adj == selected_oom_score_adj &&
> - tasksize <= selected_tasksize)
> - continue;
> - }
> - selected = p;
> - selected_tasksize = tasksize;
> - selected_oom_score_adj = oom_score_adj;
> - lowmem_print(2, "select '%s' (%d), adj %hd, size %d, to kill\n",
> - p->comm, p->pid, oom_score_adj, tasksize);
> - }
> - if (selected) {
> - task_lock(selected);
> - send_sig(SIGKILL, selected, 0);
> - if (selected->mm)
> - task_set_lmk_waiting(selected);
> - task_unlock(selected);
> - lowmem_print(1, "Killing '%s' (%d), adj %hd,\n"
> - " to free %ldkB on behalf of '%s' (%d) because\n"
> - " cache %ldkB is below limit %ldkB for oom_score_adj %hd\n"
> - " Free memory is %ldkB above reserved\n",
> - selected->comm, selected->pid,
> - selected_oom_score_adj,
> - selected_tasksize * (long)(PAGE_SIZE / 1024),
> - current->comm, current->pid,
> - other_file * (long)(PAGE_SIZE / 1024),
> - minfree * (long)(PAGE_SIZE / 1024),
> - min_score_adj,
> - other_free * (long)(PAGE_SIZE / 1024));
> - lowmem_deathpending_timeout = jiffies + HZ;
> - rem += selected_tasksize;
> - }
> -
> - lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
> - sc->nr_to_scan, sc->gfp_mask, rem);
> - rcu_read_unlock();
> - return rem;
> -}
> -
> -static struct shrinker lowmem_shrinker = {
> - .scan_objects = lowmem_scan,
> - .count_objects = lowmem_count,
> - .seeks = DEFAULT_SEEKS * 16
> -};
> -
> -static int __init lowmem_init(void)
> -{
> - register_shrinker(&lowmem_shrinker);
> - return 0;
> -}
> -device_initcall(lowmem_init);
> -
> -/*
> - * not really modular, but the easiest way to keep compat with existing
> - * bootargs behaviour is to continue using module_param here.
> - */
> -module_param_named(cost, lowmem_shrinker.seeks, int, 0644);
> -module_param_array_named(adj, lowmem_adj, short, &lowmem_adj_size, 0644);
> -module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size,
> - 0644);
> -module_param_named(debug_level, lowmem_debug_level, uint, 0644);
> -
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index e93594b88130..3cc6c650fa6a 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2347,7 +2347,6 @@ static inline void memalloc_noio_restore(unsigned int flags)
> #define PFA_NO_NEW_PRIVS 0 /* May not gain new privileges. */
> #define PFA_SPREAD_PAGE 1 /* Spread page cache over cpuset */
> #define PFA_SPREAD_SLAB 2 /* Spread some slab caches over cpuset */
> -#define PFA_LMK_WAITING 3 /* Lowmemorykiller is waiting */
>
>
> #define TASK_PFA_TEST(name, func) \
> @@ -2371,9 +2370,6 @@ TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
> TASK_PFA_SET(SPREAD_SLAB, spread_slab)
> TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)
>
> -TASK_PFA_TEST(LMK_WAITING, lmk_waiting)
> -TASK_PFA_SET(LMK_WAITING, lmk_waiting)
> -
> /*
> * task->jobctl flags
> */
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-02-10 09:00 +0100 |
| Message-ID | <t9ehB-xE-41@gated-at.bofh.it> |
| In reply to | #1578246 |
On Fri 10-02-17 08:51:49, Greg KH wrote: > On Fri, Feb 10, 2017 at 08:21:32AM +0100, peter enderborg wrote: [...] > > Until then we have to polish this version as good as we can. It is > > essential for android as it is now. > > But if no one is willing to do the work to fix the reported issues, why > should it remain? Can you do the work here? You're already working on > fixing some of the issues in a differnt way, why not do the "real work" > here instead for everyone to benifit from? Well, to be honest, I do not think that the current code is easily fixable. The approach was wrong from the day 1. Abusing slab shrinkers is just a bad place to stick this logic. This all belongs to the userspace. For that we need a proper mm pressure notification which is supposed to be vmpressure but that one also doesn't seem to work all that great. So rather than trying to fix unfixable I would stronly suggest focusing on making vmpressure work reliably. -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | peter enderborg <peter.enderborg@sonymobile.com> |
|---|---|
| Date | 2017-02-10 10:20 +0100 |
| Message-ID | <t9fwZ-1tL-3@gated-at.bofh.it> |
| In reply to | #1578257 |
On 02/10/2017 08:59 AM, Michal Hocko wrote: > On Fri 10-02-17 08:51:49, Greg KH wrote: >> On Fri, Feb 10, 2017 at 08:21:32AM +0100, peter enderborg wrote: > [...] >>> Until then we have to polish this version as good as we can. It is >>> essential for android as it is now. >> But if no one is willing to do the work to fix the reported issues, why >> should it remain? Can you do the work here? You're already working on >> fixing some of the issues in a differnt way, why not do the "real work" >> here instead for everyone to benifit from? > Well, to be honest, I do not think that the current code is easily > fixable. This patch improves the current situation and address some of the issues that makes android devices behaviour different than other linux systems. > The approach was wrong from the day 1. Abusing slab shrinkers > is just a bad place to stick this logic. This all belongs to the > userspace. But now it is there and we have to stick with it. > For that we need a proper mm pressure notification which is > supposed to be vmpressure but that one also doesn't seem to work all > that great. So rather than trying to fix unfixable I would stronly > suggest focusing on making vmpressure work reliably.
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-02-10 10:20 +0100 |
| Message-ID | <t9fwZ-1tL-1@gated-at.bofh.it> |
| In reply to | #1578319 |
On Fri 10-02-17 10:05:34, peter enderborg wrote: > On 02/10/2017 08:59 AM, Michal Hocko wrote: [...] > > The approach was wrong from the day 1. Abusing slab shrinkers > > is just a bad place to stick this logic. This all belongs to the > > userspace. > > But now it is there and we have to stick with it. It is also adding maintenance cost. Just have a look at the git log and check how many patches were just a result of the core changes which needed a sync. I seriously doubt that any of the android devices can run natively on the Vanilla kernel so insisting on keeping this code in staging doesn't give much sense to me. -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | peter enderborg <peter.enderborg@sonymobile.com> |
|---|---|
| Date | 2017-02-13 16:50 +0100 |
| Message-ID | <tar36-5BW-53@gated-at.bofh.it> |
| In reply to | #1578320 |
On 02/10/2017 10:15 AM, Michal Hocko wrote: > On Fri 10-02-17 10:05:34, peter enderborg wrote: >> On 02/10/2017 08:59 AM, Michal Hocko wrote: > [...] >>> The approach was wrong from the day 1. Abusing slab shrinkers >>> is just a bad place to stick this logic. This all belongs to the >>> userspace. >> But now it is there and we have to stick with it. > It is also adding maintenance cost. Just have a look at the git log and > check how many patches were just a result of the core changes which > needed a sync. > > I seriously doubt that any of the android devices can run natively on > the Vanilla kernel so insisting on keeping this code in staging doesn't > give much sense to me. I guess that we more than a few that would like to see that. We have http://developer.sonymobile.com/open-devices/how-to-build-and-flash-a-linux-kernel/how-to-build-mainline-linux-for-xperia-devices/ It is not the latest on anything and it is not on par with commercial bundled software.
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-02-10 09:00 +0100 |
| Message-ID | <t9ehA-xE-31@gated-at.bofh.it> |
| In reply to | #1578246 |
On Fri, Feb 10, 2017 at 08:21:32AM +0100, peter enderborg wrote: > Im not speaking for google, but I think there is a work ongoing to > replace this with user-space code. Really? I have not heard this at all, any pointers to whom in Google is doing it? > Until then we have to polish this version as good as we can. It is > essential for android as it is now. But if no one is willing to do the work to fix the reported issues, why should it remain? Can you do the work here? You're already working on fixing some of the issues in a differnt way, why not do the "real work" here instead for everyone to benifit from? thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | peter enderborg <peter.enderborg@sonymobile.com> |
|---|---|
| Date | 2017-02-10 10:20 +0100 |
| Message-ID | <t9fwZ-1tL-9@gated-at.bofh.it> |
| In reply to | #1578259 |
On 02/10/2017 08:51 AM, Greg Kroah-Hartman wrote: > On Fri, Feb 10, 2017 at 08:21:32AM +0100, peter enderborg wrote: >> Im not speaking for google, but I think there is a work ongoing to >> replace this with user-space code. > Really? I have not heard this at all, any pointers to whom in Google is > doing it? > I think it was mention some of the google conferences. The idea is the lmkd that uses memory pressure events to trigger this. From git log in lmkd i think Colin Cross is involved. >> Until then we have to polish this version as good as we can. It is >> essential for android as it is now. > But if no one is willing to do the work to fix the reported issues, why > should it remain? It is needed by billions of phones. > Can you do the work here? No. Change the kernel is only one small part of the solution. > You're already working on > fixing some of the issues in a differnt way, why not do the "real work" > here instead for everyone to benifit from? The long term solution is something from AOSP. As you know we tried to contribute this to AOSP. As OEM we can't turn android upside down. It has to be a step by step. > thanks, > > greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-02-10 12:10 +0100 |
| Message-ID | <t9hfs-2El-29@gated-at.bofh.it> |
| In reply to | #1578323 |
On Fri, Feb 10, 2017 at 10:05:12AM +0100, peter enderborg wrote: > On 02/10/2017 08:51 AM, Greg Kroah-Hartman wrote: > > On Fri, Feb 10, 2017 at 08:21:32AM +0100, peter enderborg wrote: > >> Im not speaking for google, but I think there is a work ongoing to > >> replace this with user-space code. > > Really? I have not heard this at all, any pointers to whom in Google is > > doing it? > > > I think it was mention some of the google conferences. The idea > is the lmkd that uses memory pressure events to trigger this. > From git log in lmkd i think Colin Cross is involved. Great, care to add him to this thread? > >> Until then we have to polish this version as good as we can. It is > >> essential for android as it is now. > > But if no one is willing to do the work to fix the reported issues, why > > should it remain? > It is needed by billions of phones. Well, something is needed, not necessarily this solution :) > > Can you do the work here? > No. Change the kernel is only one small part of the solution. Why can't you work on the whole thing? > > You're already working on > > fixing some of the issues in a differnt way, why not do the "real work" > > here instead for everyone to benifit from? > The long term solution is something from AOSP. As you know > we tried to contribute this to AOSP. As OEM we can't turn android > upside down. It has to be a step by step. I posted in AOSP that you should post the patches here as AOSP shouldn't be taking patches that the community rejects. There's no reason you can't also provide the "fix the userspace side" patches into AOSP at the same time, and provide the "correct" solution here as well. The kernel community doesn't care abotu AOSP, nor should anyone expect it to. You are going to have to work across both boundries/communities in order to resolve this properly. If not, as the kernel developers have pointed out, the in-kernel stuff will probably be removed as it's causing problems for the upstream developers, and no one is stepping up to fix it "correctly". thanks, greg k-h
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web