From: Christian König <christian.koe...@amd.com>

This allows device drivers to specify an additional badness for the OOM
and low memory killer when they allocate memory on behalf of userspace.

Signed-off-by: Christian König <christian.koenig at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
---
 fs/file_table.c    | 1 +
 include/linux/fs.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/fs/file_table.c b/fs/file_table.c
index 294174d..23b797d 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -136,6 +136,7 @@ struct file *get_empty_filp(void)
        spin_lock_init(&f->f_lock);
        mutex_init(&f->f_pos_lock);
        eventpoll_init_file(f);
+       atomic_long_set(&f->f_oom_badness, 0);
        /* f->f_version: 0 */
        return f;

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 35ec87e..5a5d20a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -861,6 +861,7 @@ struct file {
        struct list_head        f_tfile_llink;
 #endif /* #ifdef CONFIG_EPOLL */
        struct address_space    *f_mapping;
+       atomic_long_t           f_oom_badness;
 } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */

 struct file_handle {
-- 
1.9.1

Reply via email to