lkml.org 
[lkml]   [2022]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counter
On 9/1/22 11:42 AM, Oscar Salvador wrote:
> +static unsigned long last_stack = 0;

This @last_stack can just be a static local variable in the new
function you wrote, read_page_owner_stacks(), since no other
functions use it.

> +static ssize_t read_page_owner_stacks(struct file *file, char __user *buf,
> + size_t count, loff_t *pos)
> +{
> + char *kbuf;
> + int ret = 0;
> +
> + count = min_t(size_t, count, PAGE_SIZE);
> + kbuf = kmalloc(count, GFP_KERNEL);
> + if (!kbuf)
> + return ENOMEM;

Missing a negative sign, return -ENOMEM;

> + ret += stack_depot_print_stacks_threshold(kbuf, count, pos, &last_stack);
> + if (copy_to_user(buf, kbuf, ret))
> + ret = -EFAULT;
> +
> + if (!ret)
> + last_stack = 0;
> +
> + kfree(kbuf);
> + return ret;
> +}

--
Ammar Faizi

\
 
 \ /
  Last update: 2022-09-01 10:18    [W:0.104 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site