From: Jonathan Corbet <corbet@lwn.net>
To: Pekka Enberg <penberg@kernel.org>
Cc: Rik van Riel <riel@redhat.com>, Minchan Kim <minchan@kernel.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
leonid.moiseichuk@nokia.com, kamezawa.hiroyu@jp.fujitsu.com,
mel@csn.ul.ie, rientjes@google.com,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ronen Hod <rhod@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Subject: Re: [RFC 1/3] /dev/low_mem_notify
Date: Tue, 24 Jan 2012 14:57:13 -0700 [thread overview]
Message-ID: <20120124145713.20fad866@dt> (raw)
In-Reply-To: <alpine.LFD.2.02.1201172044310.15303@tux.localdomain>
On Tue, 17 Jan 2012 20:51:13 +0200 (EET)
Pekka Enberg <penberg@kernel.org> wrote:
> Ok, so here's a proof of concept patch that implements sample-base
> per-process free threshold VM event watching using perf-like syscall ABI.
> I'd really like to see something like this that's much more extensible and
> clean than the /dev based ABIs that people have proposed so far.
OK, so I'm slow, but better late than never. I plead travel.
I guess the thing that surprises me is that nobody has said this yet: this
looks a lot like an event-reporting mechanism like perf. Is there a reason
these can't be perf-style events integrated with all the rest?
> +struct vmnotify_config {
> + /*
> + * Size of the struct for ABI extensibility.
> + */
> + __u32 size;
> +
> + /*
> + * Notification type bitmask
> + */
> + __u64 type;
> +
> + /*
> + * Free memory threshold in percentages [1..99]
> + */
> + __u32 free_threshold;
Is this an upper-bound threshold or a lower-bound threshold? From your
example, it looks like "free_threshold" is "the amount of memory that is
not free", which seems confusing.
[...]
> new file mode 100644
> index 0000000..6800450
> --- /dev/null
> +++ b/mm/vmnotify.c
> @@ -0,0 +1,235 @@
> +#include <linux/anon_inodes.h>
> +#include <linux/vmnotify.h>
> +#include <linux/syscalls.h>
> +#include <linux/file.h>
> +#include <linux/list.h>
> +#include <linux/poll.h>
> +#include <linux/slab.h>
> +#include <linux/swap.h>
> +
> +#define VMNOTIFY_MAX_FREE_THRESHOD 100
Did we run out of L's here? :)
> +static ssize_t vmnotify_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> +{
> + struct vmnotify_watch *watch = file->private_data;
> + int ret = 0;
> +
> + mutex_lock(&watch->mutex);
> +
> + if (!watch->pending)
> + goto out_unlock;
> +
> + if (copy_to_user(buf, &watch->event, sizeof(struct vmnotify_event))) {
> + ret = -EFAULT;
> + goto out_unlock;
> + }
> +
> + ret = watch->event.size;
> +
> + watch->pending = false;
> +
> +out_unlock:
> + mutex_unlock(&watch->mutex);
> +
> + return ret;
> +}
So this is a nonblocking-only interface? That may surprise some
developers. You already have a wait queue, why not wait on it if need be?
> +static int vmnotify_copy_config(struct vmnotify_config __user *uconfig,
> + struct vmnotify_config *config)
> +{
> + int ret;
> +
> + ret = copy_from_user(config, uconfig, sizeof(struct vmnotify_config));
> + if (ret)
> + return -EFAULT;
> +
> + if (!config->type)
> + return -EINVAL;
> +
> + if (config->type & VMNOTIFY_TYPE_SAMPLE) {
> + if (config->sample_period_ns < NSEC_PER_MSEC)
> + return -EINVAL;
> + }
What happens if the sample period is zero?
jon
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Corbet <corbet@lwn.net>
To: Pekka Enberg <penberg@kernel.org>
Cc: Rik van Riel <riel@redhat.com>, Minchan Kim <minchan@kernel.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
leonid.moiseichuk@nokia.com, kamezawa.hiroyu@jp.fujitsu.com,
mel@csn.ul.ie, rientjes@google.com,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ronen Hod <rhod@redhat.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Subject: Re: [RFC 1/3] /dev/low_mem_notify
Date: Tue, 24 Jan 2012 14:57:13 -0700 [thread overview]
Message-ID: <20120124145713.20fad866@dt> (raw)
In-Reply-To: <alpine.LFD.2.02.1201172044310.15303@tux.localdomain>
On Tue, 17 Jan 2012 20:51:13 +0200 (EET)
Pekka Enberg <penberg@kernel.org> wrote:
> Ok, so here's a proof of concept patch that implements sample-base
> per-process free threshold VM event watching using perf-like syscall ABI.
> I'd really like to see something like this that's much more extensible and
> clean than the /dev based ABIs that people have proposed so far.
OK, so I'm slow, but better late than never. I plead travel.
I guess the thing that surprises me is that nobody has said this yet: this
looks a lot like an event-reporting mechanism like perf. Is there a reason
these can't be perf-style events integrated with all the rest?
> +struct vmnotify_config {
> + /*
> + * Size of the struct for ABI extensibility.
> + */
> + __u32 size;
> +
> + /*
> + * Notification type bitmask
> + */
> + __u64 type;
> +
> + /*
> + * Free memory threshold in percentages [1..99]
> + */
> + __u32 free_threshold;
Is this an upper-bound threshold or a lower-bound threshold? From your
example, it looks like "free_threshold" is "the amount of memory that is
not free", which seems confusing.
[...]
> new file mode 100644
> index 0000000..6800450
> --- /dev/null
> +++ b/mm/vmnotify.c
> @@ -0,0 +1,235 @@
> +#include <linux/anon_inodes.h>
> +#include <linux/vmnotify.h>
> +#include <linux/syscalls.h>
> +#include <linux/file.h>
> +#include <linux/list.h>
> +#include <linux/poll.h>
> +#include <linux/slab.h>
> +#include <linux/swap.h>
> +
> +#define VMNOTIFY_MAX_FREE_THRESHOD 100
Did we run out of L's here? :)
> +static ssize_t vmnotify_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
> +{
> + struct vmnotify_watch *watch = file->private_data;
> + int ret = 0;
> +
> + mutex_lock(&watch->mutex);
> +
> + if (!watch->pending)
> + goto out_unlock;
> +
> + if (copy_to_user(buf, &watch->event, sizeof(struct vmnotify_event))) {
> + ret = -EFAULT;
> + goto out_unlock;
> + }
> +
> + ret = watch->event.size;
> +
> + watch->pending = false;
> +
> +out_unlock:
> + mutex_unlock(&watch->mutex);
> +
> + return ret;
> +}
So this is a nonblocking-only interface? That may surprise some
developers. You already have a wait queue, why not wait on it if need be?
> +static int vmnotify_copy_config(struct vmnotify_config __user *uconfig,
> + struct vmnotify_config *config)
> +{
> + int ret;
> +
> + ret = copy_from_user(config, uconfig, sizeof(struct vmnotify_config));
> + if (ret)
> + return -EFAULT;
> +
> + if (!config->type)
> + return -EINVAL;
> +
> + if (config->type & VMNOTIFY_TYPE_SAMPLE) {
> + if (config->sample_period_ns < NSEC_PER_MSEC)
> + return -EINVAL;
> + }
What happens if the sample period is zero?
jon
next prev parent reply other threads:[~2012-01-24 21:57 UTC|newest]
Thread overview: 124+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-17 8:13 [RFC 0/3] low memory notify Minchan Kim
2012-01-17 8:13 ` Minchan Kim
2012-01-17 8:13 ` [RFC 1/3] /dev/low_mem_notify Minchan Kim
2012-01-17 8:13 ` Minchan Kim
2012-01-17 9:27 ` Pekka Enberg
2012-01-17 9:27 ` Pekka Enberg
2012-01-17 16:35 ` Rik van Riel
2012-01-17 16:35 ` Rik van Riel
2012-01-17 18:51 ` Pekka Enberg
2012-01-17 18:51 ` Pekka Enberg
2012-01-17 19:30 ` Rik van Riel
2012-01-17 19:30 ` Rik van Riel
2012-01-17 19:49 ` Pekka Enberg
2012-01-17 19:49 ` Pekka Enberg
2012-01-17 19:54 ` Pekka Enberg
2012-01-17 19:54 ` Pekka Enberg
2012-01-17 19:57 ` Pekka Enberg
2012-01-17 19:57 ` Pekka Enberg
2012-01-17 23:20 ` Minchan Kim
2012-01-17 23:20 ` Minchan Kim
2012-01-18 7:16 ` Pekka Enberg
2012-01-18 7:16 ` Pekka Enberg
2012-01-18 7:49 ` Minchan Kim
2012-01-18 7:49 ` Minchan Kim
2012-01-18 9:06 ` leonid.moiseichuk
2012-01-18 9:06 ` leonid.moiseichuk
2012-01-18 9:15 ` Pekka Enberg
2012-01-18 9:15 ` Pekka Enberg
2012-01-18 9:41 ` leonid.moiseichuk
2012-01-18 9:41 ` leonid.moiseichuk
2012-01-18 10:40 ` Pekka Enberg
2012-01-18 10:40 ` Pekka Enberg
2012-01-18 10:44 ` leonid.moiseichuk
2012-01-18 10:44 ` leonid.moiseichuk
2012-01-18 23:34 ` Ronen Hod
2012-01-18 23:34 ` Ronen Hod
2012-01-19 7:25 ` Pekka Enberg
2012-01-19 7:25 ` Pekka Enberg
2012-01-19 9:05 ` Ronen Hod
2012-01-19 9:05 ` Ronen Hod
2012-01-19 9:10 ` Pekka Enberg
2012-01-19 9:10 ` Pekka Enberg
2012-01-19 9:20 ` Ronen Hod
2012-01-19 9:20 ` Ronen Hod
2012-01-19 10:53 ` leonid.moiseichuk
2012-01-19 10:53 ` leonid.moiseichuk
2012-01-19 11:07 ` Pekka Enberg
2012-01-19 11:07 ` Pekka Enberg
2012-01-19 11:54 ` leonid.moiseichuk
2012-01-19 11:54 ` leonid.moiseichuk
2012-01-19 11:59 ` Pekka Enberg
2012-01-19 11:59 ` Pekka Enberg
2012-01-19 12:06 ` Pekka Enberg
2012-01-19 12:06 ` Pekka Enberg
2012-01-24 15:38 ` Marcelo Tosatti
2012-01-24 15:38 ` Marcelo Tosatti
2012-01-24 16:08 ` Ronen Hod
2012-01-24 16:08 ` Ronen Hod
2012-01-24 18:10 ` Marcelo Tosatti
2012-01-24 18:10 ` Marcelo Tosatti
2012-01-25 8:52 ` Ronen Hod
2012-01-25 8:52 ` Ronen Hod
2012-01-25 10:12 ` Marcelo Tosatti
2012-01-25 10:12 ` Marcelo Tosatti
2012-01-25 10:48 ` Ronen Hod
2012-01-25 10:48 ` Ronen Hod
2012-01-26 16:17 ` Marcelo Tosatti
2012-01-26 16:17 ` Marcelo Tosatti
2012-01-24 16:10 ` Pekka Enberg
2012-01-24 16:10 ` Pekka Enberg
2012-01-24 18:29 ` Marcelo Tosatti
2012-01-24 18:29 ` Marcelo Tosatti
2012-01-25 8:19 ` leonid.moiseichuk
2012-01-25 8:19 ` leonid.moiseichuk
2012-01-19 7:34 ` Pekka Enberg
2012-01-19 7:34 ` Pekka Enberg
2012-01-24 16:22 ` Arnd Bergmann
2012-01-24 16:22 ` Arnd Bergmann
2012-01-18 14:30 ` Rik van Riel
2012-01-18 14:30 ` Rik van Riel
2012-01-18 15:29 ` Pekka Enberg
2012-01-18 15:29 ` Pekka Enberg
2012-01-24 15:40 ` Marcelo Tosatti
2012-01-24 15:40 ` Marcelo Tosatti
2012-01-24 16:01 ` Pekka Enberg
2012-01-24 16:01 ` Pekka Enberg
2012-01-24 16:25 ` Arnd Bergmann
2012-01-24 16:25 ` Arnd Bergmann
2012-01-24 18:32 ` Marcelo Tosatti
2012-01-24 18:32 ` Marcelo Tosatti
2012-01-24 21:57 ` Jonathan Corbet [this message]
2012-01-24 21:57 ` Jonathan Corbet
2012-01-17 9:45 ` Pekka Enberg
2012-01-17 9:45 ` Pekka Enberg
2012-01-17 8:13 ` [RFC 2/3] vmscan hook Minchan Kim
2012-01-17 8:13 ` Minchan Kim
2012-01-17 8:39 ` KAMEZAWA Hiroyuki
2012-01-17 8:39 ` KAMEZAWA Hiroyuki
2012-01-17 9:13 ` Minchan Kim
2012-01-17 9:13 ` Minchan Kim
2012-01-17 10:05 ` KAMEZAWA Hiroyuki
2012-01-17 10:05 ` KAMEZAWA Hiroyuki
2012-01-17 23:08 ` Minchan Kim
2012-01-17 23:08 ` Minchan Kim
2012-01-18 0:18 ` KAMEZAWA Hiroyuki
2012-01-18 0:18 ` KAMEZAWA Hiroyuki
2012-01-18 14:17 ` Rik van Riel
2012-01-18 14:17 ` Rik van Riel
2012-01-19 2:25 ` KAMEZAWA Hiroyuki
2012-01-19 2:25 ` KAMEZAWA Hiroyuki
2012-01-19 14:42 ` Rik van Riel
2012-01-19 14:42 ` Rik van Riel
2012-01-20 0:24 ` KAMEZAWA Hiroyuki
2012-01-20 0:24 ` KAMEZAWA Hiroyuki
2012-01-17 8:13 ` [RFC 3/3] test program Minchan Kim
2012-01-17 8:13 ` Minchan Kim
2012-01-17 14:38 ` [RFC 0/3] low memory notify Colin Walters
2012-01-17 14:38 ` Colin Walters
2012-01-17 15:04 ` Pekka Enberg
2012-01-17 15:04 ` Pekka Enberg
2012-01-17 16:44 ` Rik van Riel
2012-01-17 16:44 ` Rik van Riel
2012-01-17 17:16 ` Olof Johansson
2012-01-17 17:16 ` Olof Johansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120124145713.20fad866@dt \
--to=corbet@lwn.net \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=leonid.moiseichuk@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=minchan@kernel.org \
--cc=mtosatti@redhat.com \
--cc=penberg@kernel.org \
--cc=rhod@redhat.com \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.