Skip to content

Commit

Permalink
seq_file: account everything to kmemcg
Browse files Browse the repository at this point in the history
All it takes to open a file and read 1 byte from it.

seq_file will be allocated along with any private allocations, and more
importantly seq file buffer which is 1 page by default.

Link: http://lkml.kernel.org/r/20180310085252.GB17121@avx2
Signed-off-by: Alexey Dobriyan <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Glauber Costa <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and torvalds committed Apr 11, 2018
1 parent 0965232 commit d64d01a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/seq_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void seq_set_overflow(struct seq_file *m)

static void *seq_buf_alloc(unsigned long size)
{
return kvmalloc(size, GFP_KERNEL);
return kvmalloc(size, GFP_KERNEL_ACCOUNT);
}

/**
Expand Down Expand Up @@ -566,7 +566,7 @@ static void single_stop(struct seq_file *p, void *v)
int single_open(struct file *file, int (*show)(struct seq_file *, void *),
void *data)
{
struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL_ACCOUNT);
int res = -ENOMEM;

if (op) {
Expand Down Expand Up @@ -628,7 +628,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops,
void *private;
struct seq_file *seq;

private = kzalloc(psize, GFP_KERNEL);
private = kzalloc(psize, GFP_KERNEL_ACCOUNT);
if (private == NULL)
goto out;

Expand Down Expand Up @@ -1112,5 +1112,5 @@ EXPORT_SYMBOL(seq_hlist_next_percpu);

void __init seq_file_init(void)
{
seq_file_cache = KMEM_CACHE(seq_file, SLAB_PANIC);
seq_file_cache = KMEM_CACHE(seq_file, SLAB_ACCOUNT|SLAB_PANIC);
}

0 comments on commit d64d01a

Please sign in to comment.