Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Wed, Feb 15, 2017 at 09:21:56AM +0100, peter enderborg wrote: > On 02/14/2017 05:51 PM, Greg KH wrote: > > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > > wrote: > >> From: Peter Enderborg> >> > >> This collects stats for shrinker calls and how much > >> waste work we do within the lowmemorykiller. > >> > >> Signed-off-by: Peter Enderborg > > Wait, what changed from the previous versions of this patch? Did you > > take the review comments into consideration, or is this just a resend of > > the original patches in a format that isn't corrupted? > > > > thanks, > > > > greg k-h > > This is just a send with git-send-email that seems to work better. Nothing > else than tab-spaces should be different. I would like to have some positive > feedback from google/android before I start to send updated patches to the > list. > If google are ready for the userspace solution this patch set is pointless for > upstream kernel. > > Michal Hocko is very negative to hole thing, but we have addressed at least > some > issues he pointed out on the list in 2015. Is there any idea to continue? If Michal rejected this solution, then I wouldn't be spending much time on it at all. Instead, I strongly suggest you try to do what he pointed out should be done instead. If that requires userspace help, great, try that and see what happens. thanks, greg k-h
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Wed, Feb 15, 2017 at 09:21:56AM +0100, peter enderborg wrote: > On 02/14/2017 05:51 PM, Greg KH wrote: > > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > > wrote: > >> From: Peter Enderborg > >> > >> This collects stats for shrinker calls and how much > >> waste work we do within the lowmemorykiller. > >> > >> Signed-off-by: Peter Enderborg > > Wait, what changed from the previous versions of this patch? Did you > > take the review comments into consideration, or is this just a resend of > > the original patches in a format that isn't corrupted? > > > > thanks, > > > > greg k-h > > This is just a send with git-send-email that seems to work better. Nothing > else than tab-spaces should be different. I would like to have some positive > feedback from google/android before I start to send updated patches to the > list. > If google are ready for the userspace solution this patch set is pointless for > upstream kernel. > > Michal Hocko is very negative to hole thing, but we have addressed at least > some > issues he pointed out on the list in 2015. Is there any idea to continue? If Michal rejected this solution, then I wouldn't be spending much time on it at all. Instead, I strongly suggest you try to do what he pointed out should be done instead. If that requires userspace help, great, try that and see what happens. thanks, greg k-h
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Wed, Feb 15, 2017 at 09:22:10AM +0100, peter enderborg wrote: > On 02/14/2017 05:50 PM, Greg KH wrote: > > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > > wrote: > >> From: Peter Enderborg> >> > >> This collects stats for shrinker calls and how much > >> waste work we do within the lowmemorykiller. > >> > >> Signed-off-by: Peter Enderborg > >> --- > >> 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. > > Ick, no new /proc files please, this isn't a "process" value. What's > > wrong with debugfs? > This is intended for android. Android users are very limited in their access > to linux part of the system on commercial models and lmk activity has a bad > impact on the performance > of the device. Even the application developers has not much access so it > seems to be fair to give > the users the information about why there is a problem. Why would you want to give "all users" this information at all? This is a debugging tool, your debugging userspace framework can use whatever interface you create to access it (i.e. debugfs). Again, do not add debugging stuff to /proc/ that's not ok, sorry. thanks, greg k-h
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Wed, Feb 15, 2017 at 09:22:10AM +0100, peter enderborg wrote: > On 02/14/2017 05:50 PM, Greg KH wrote: > > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > > wrote: > >> From: Peter Enderborg > >> > >> This collects stats for shrinker calls and how much > >> waste work we do within the lowmemorykiller. > >> > >> Signed-off-by: Peter Enderborg > >> --- > >> 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. > > Ick, no new /proc files please, this isn't a "process" value. What's > > wrong with debugfs? > This is intended for android. Android users are very limited in their access > to linux part of the system on commercial models and lmk activity has a bad > impact on the performance > of the device. Even the application developers has not much access so it > seems to be fair to give > the users the information about why there is a problem. Why would you want to give "all users" this information at all? This is a debugging tool, your debugging userspace framework can use whatever interface you create to access it (i.e. debugfs). Again, do not add debugging stuff to /proc/ that's not ok, sorry. thanks, greg k-h
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On 02/14/2017 05:50 PM, Greg KH wrote: > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > wrote: >> From: Peter Enderborg>> >> This collects stats for shrinker calls and how much >> waste work we do within the lowmemorykiller. >> >> Signed-off-by: Peter Enderborg >> --- >> 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. > Ick, no new /proc files please, this isn't a "process" value. What's > wrong with debugfs? This is intended for android. Android users are very limited in their access to linux part of the system on commercial models and lmk activity has a bad impact on the performance of the device. Even the application developers has not much access so it seems to be fair to give the users the information about why there is a problem. > Also note the minor ' ' usage in your first sentence of the help text. > >> 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 >> #include >> #include >> +#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 = {
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On 02/14/2017 05:50 PM, Greg KH wrote: > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > wrote: >> From: Peter Enderborg >> >> This collects stats for shrinker calls and how much >> waste work we do within the lowmemorykiller. >> >> Signed-off-by: Peter Enderborg >> --- >> 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. > Ick, no new /proc files please, this isn't a "process" value. What's > wrong with debugfs? This is intended for android. Android users are very limited in their access to linux part of the system on commercial models and lmk activity has a bad impact on the performance of the device. Even the application developers has not much access so it seems to be fair to give the users the information about why there is a problem. > Also note the minor ' ' usage in your first sentence of the help text. > >> 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 >> #include >> #include >> +#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) >> { >>
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On 02/14/2017 05:51 PM, Greg KH wrote: > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > wrote: >> From: Peter Enderborg>> >> This collects stats for shrinker calls and how much >> waste work we do within the lowmemorykiller. >> >> Signed-off-by: Peter Enderborg > Wait, what changed from the previous versions of this patch? Did you > take the review comments into consideration, or is this just a resend of > the original patches in a format that isn't corrupted? > > thanks, > > greg k-h This is just a send with git-send-email that seems to work better. Nothing else than tab-spaces should be different. I would like to have some positive feedback from google/android before I start to send updated patches to the list. If google are ready for the userspace solution this patch set is pointless for upstream kernel. Michal Hocko is very negative to hole thing, but we have addressed at least some issues he pointed out on the list in 2015. Is there any idea to continue?
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On 02/14/2017 05:51 PM, Greg KH wrote: > On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com > wrote: >> From: Peter Enderborg >> >> This collects stats for shrinker calls and how much >> waste work we do within the lowmemorykiller. >> >> Signed-off-by: Peter Enderborg > Wait, what changed from the previous versions of this patch? Did you > take the review comments into consideration, or is this just a resend of > the original patches in a format that isn't corrupted? > > thanks, > > greg k-h This is just a send with git-send-email that seems to work better. Nothing else than tab-spaces should be different. I would like to have some positive feedback from google/android before I start to send updated patches to the list. If google are ready for the userspace solution this patch set is pointless for upstream kernel. Michal Hocko is very negative to hole thing, but we have addressed at least some issues he pointed out on the list in 2015. Is there any idea to continue?
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com wrote: > From: Peter Enderborg> > This collects stats for shrinker calls and how much > waste work we do within the lowmemorykiller. > > Signed-off-by: Peter Enderborg Wait, what changed from the previous versions of this patch? Did you take the review comments into consideration, or is this just a resend of the original patches in a format that isn't corrupted? thanks, greg k-h
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com wrote: > From: Peter Enderborg > > This collects stats for shrinker calls and how much > waste work we do within the lowmemorykiller. > > Signed-off-by: Peter Enderborg Wait, what changed from the previous versions of this patch? Did you take the review comments into consideration, or is this just a resend of the original patches in a format that isn't corrupted? thanks, greg k-h
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com wrote: > From: Peter Enderborg> > This collects stats for shrinker calls and how much > waste work we do within the lowmemorykiller. > > Signed-off-by: Peter Enderborg > --- > 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. Ick, no new /proc files please, this isn't a "process" value. What's wrong with debugfs? Also note the minor ' ' usage in your first sentence of the help text. > 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 > #include > #include > +#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(_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 000..673691c > --- /dev/null > +++ b/drivers/staging/android/lowmemorykiller_stats.c > @@ -0,0 +1,85 @@ > +/* > + * lowmemorykiller_stats > + *
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
On Tue, Feb 14, 2017 at 05:09:30PM +0100, peter.enderb...@sonymobile.com wrote: > From: Peter Enderborg > > This collects stats for shrinker calls and how much > waste work we do within the lowmemorykiller. > > Signed-off-by: Peter Enderborg > --- > 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. Ick, no new /proc files please, this isn't a "process" value. What's wrong with debugfs? Also note the minor ' ' usage in your first sentence of the help text. > 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 > #include > #include > +#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(_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 000..673691c > --- /dev/null > +++ b/drivers/staging/android/lowmemorykiller_stats.c > @@ -0,0 +1,85 @@ > +/* > + * lowmemorykiller_stats > + * > + * Copyright (C) 2017 Sony Mobile Communications Inc. > + *
[PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
From: Peter EnderborgThis collects stats for shrinker calls and how much waste work we do within the lowmemorykiller. Signed-off-by: Peter Enderborg --- 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 #include #include +#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(_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 000..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 + * + * 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
[PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
From: Peter Enderborg This collects stats for shrinker calls and how much waste work we do within the lowmemorykiller. Signed-off-by: Peter Enderborg --- 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 #include #include +#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(_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 000..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 + * + * 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 +#include +#include
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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.
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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.
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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.
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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.
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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> 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 > --- > 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.. > --- 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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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 > 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 > --- > 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.. > --- 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 > - *
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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 HockoDate: 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 --- 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.. --- 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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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 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 --- 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.. --- 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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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 EnderborgNacked-by: Michal Hocko > --- > 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 > #include > #include > +#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(_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 000..673691c > --- /dev/null > +++ b/drivers/staging/android/lowmemorykiller_stats.c > @@ -0,0 +1,85 @@ > +/* > + * lowmemorykiller_stats > + * > + *
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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 Nacked-by: Michal Hocko > --- > 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 > #include > #include > +#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(_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 000..673691c > --- /dev/null > +++ b/drivers/staging/android/lowmemorykiller_stats.c > @@ -0,0 +1,85 @@ > +/* > + * lowmemorykiller_stats > + * > + * Copyright (C) 2017 Sony Mobile Communications Inc. >
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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> --- > 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 > #include > #include > +#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
Re: [PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
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 > --- > 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 > #include > #include > +#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
[PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
This collects stats for shrinker calls and how much waste work we do within the lowmemorykiller. Signed-off-by: Peter Enderborg--- 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 #include #include +#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(_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 000..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 + * + * 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 +#include +#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
[PATCH 1/3 staging-next] android: Collect statistics from lowmemorykiller
This collects stats for shrinker calls and how much waste work we do within the lowmemorykiller. Signed-off-by: Peter Enderborg --- 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 #include #include +#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(_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 000..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 + * + * 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 +#include +#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 + */