2013-03-07 10:42:53

by Oskar Andero

[permalink] [raw]
Subject: [PATCH] lowmemorykiller: Use ktimer instead of jiffies

From: Peter Enderborg <[email protected]>

Reviewed-by: Radovan Lekanovic <[email protected]>
Signed-off-by: Peter Enderborg <[email protected]>
Signed-off-by: Oskar Andero <[email protected]>
---
drivers/staging/android/lowmemorykiller.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 3b91b0f..6da9416 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -38,6 +38,7 @@
#include <linux/rcupdate.h>
#include <linux/profile.h>
#include <linux/notifier.h>
+#include <linux/ktime.h>

static uint32_t lowmem_debug_level = 2;
static short lowmem_adj[6] = {
@@ -55,7 +56,7 @@ static int lowmem_minfree[6] = {
};
static int lowmem_minfree_size = 4;

-static unsigned long lowmem_deathpending_timeout;
+static ktime_t lowmem_deathpending_timeout;

#define lowmem_print(level, x...) \
do { \
@@ -117,7 +118,8 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
continue;

if (test_tsk_thread_flag(p, TIF_MEMDIE) &&
- time_before_eq(jiffies, lowmem_deathpending_timeout)) {
+ ktime_us_delta(ktime_get(),
+ lowmem_deathpending_timeout) < 0) {
task_unlock(p);
rcu_read_unlock();
return 0;
@@ -148,7 +150,8 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n",
selected->pid, selected->comm,
selected_oom_score_adj, selected_tasksize);
- lowmem_deathpending_timeout = jiffies + HZ;
+ lowmem_deathpending_timeout = ktime_add_ns(ktime_get(),
+ NSEC_PER_SEC/2);
send_sig(SIGKILL, selected, 0);
set_tsk_thread_flag(selected, TIF_MEMDIE);
rem -= selected_tasksize;
--
1.7.8.6


2013-03-07 17:24:49

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] lowmemorykiller: Use ktimer instead of jiffies

On Thu, Mar 07, 2013 at 11:32:39AM +0100, [email protected] wrote:
> From: Peter Enderborg <[email protected]>
>
> Reviewed-by: Radovan Lekanovic <[email protected]>
> Signed-off-by: Peter Enderborg <[email protected]>
> Signed-off-by: Oskar Andero <[email protected]>
> ---

No changelog entry saying why you want this change? You need to explain
this, otherwise I'll assume it's not needed at all, and just drop it...

thanks,

greg k-h

2013-03-08 08:08:53

by Oskar Andero

[permalink] [raw]
Subject: Re: [PATCH] lowmemorykiller: Use ktimer instead of jiffies

On 18:25 Thu 07 Mar , Greg KH wrote:
> On Thu, Mar 07, 2013 at 11:32:39AM +0100, [email protected] wrote:
> > From: Peter Enderborg <[email protected]>
> >
> > Reviewed-by: Radovan Lekanovic <[email protected]>
> > Signed-off-by: Peter Enderborg <[email protected]>
> > Signed-off-by: Oskar Andero <[email protected]>
> > ---
>
> No changelog entry saying why you want this change? You need to explain
> this, otherwise I'll assume it's not needed at all, and just drop it...

Point taken. I will update the commit message.

Thanks!

-Oskar