[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220905124234.635349-1-ammarfaizi2@gnuweeb.org>
Date: Mon, 5 Sep 2022 19:42:34 +0700
From: Ammar Faizi <ammarfaizi2@...weeb.org>
To: Michal Hocko <mhocko@...e.com>
Cc: Ammar Faizi <ammarfaizi2@...weeb.org>,
Oscar Salvador <osalvador@...e.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux Memory Management Mailing List <linux-mm@...ck.org>,
Vlastimil Babka <vbabka@...e.cz>,
Eric Dumazet <edumazet@...gle.com>,
Waiman Long <longman@...hat.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Marco Elver <elver@...gle.com>,
Andrey Konovalov <andreyknvl@...il.com>,
Alexander Potapenko <glider@...gle.com>
Subject: Re: [PATCH v2 3/3] mm,page_owner: Filter out stacks by a threshold counter
On Mon, 5 Sep 2022 14:02:09 +0200, Michal Hocko wrote:
> On Mon 05-09-22 18:54:59, Ammar Faizi wrote:
> > On Mon, 5 Sep 2022 13:31:02 +0200, Michal Hocko wrote:
> [...]
> > > > static ssize_t write_page_owner_threshold(struct file *file, const char __user *buf,
> > > > size_t count, loff_t *pos)
> > > > {
> > > > char kbuf[21];
> > > > int ret;
> > > >
> > > > count = min_t(size_t, count, sizeof(kbuf));
> > > > if (copy_from_user(kbuf, buf, count))
> > > > return -EFAULT;
> > > >
> > > > kbuf[count - 1] = '\0';
> > > > ret = kstrtoul(kbuf, 10, &threshold);
> > > > return ret ? ret : count;
> > > > }
> > >
> > > Isn't there a proc_dointvec counterpart for debugfs?
> >
> > Ah, well. If that's much simpler, we should go with that. I am not
> > familiar proc_dointvec() interface, so I couldn't say about it.
>
> Just to clarify. proc_dointvec is rather specific to proc/sysctl
> interface. I was too lazy to look whether debugfs has something similar
> available. Maybe writing to debugfs is not all that common but I would
> expect a shared code to write a simple value would be there.
I took a look, there is DEFINE_SIMPLE_ATTRIBUTE().
Ref: https://github.com/torvalds/linux/blob/v6.0-rc4/include/linux/fs.h#L3458-L3487
It looks much simpler to me. Untested, but it is something like this:
-----------------
static int page_owner_threshold_get(void *data, u64 *val)
{
*val = threshold;
return 0;
}
static int page_owner_threshold_set(void *data, u64 val)
{
threshold = val;
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
&page_owner_threshold_set, "%lu");
-----------------
And then the init should be the same:
debugfs_create_file("page_owner_threshold", 0600, NULL, NULL,
&proc_page_owner_threshold);
--
Ammar Faizi
Powered by blists - more mailing lists