@@ -41,6 +41,7 @@
#include <linux/rcupdate.h>
#include <linux/profile.h>
#include <linux/notifier.h>
+#include <linux/fdtable.h>
static uint32_t lowmem_debug_level = 1;
static short lowmem_adj[6] = {
@@ -75,6 +76,13 @@ static unsigned long lowmem_count(struct shrinker *s,
global_page_state(NR_INACTIVE_FILE);
}
+static int lowmem_file_badness(const void *tasksize, struct file *file, unsigned n)
+{
+ *((int*)tasksize) += atomic_long_read(&file->f_oom_badness);
+
+ return 0;
+}
+
static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
{
struct task_struct *tsk;
@@ -139,6 +147,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
continue;
}
tasksize = get_mm_rss(p->mm);
+ iterate_fd(p->files, 0, lowmem_file_badness, &tasksize);
task_unlock(p);
if (tasksize <= 0)
continue;