On Wed, 7 Nov 2012 03:01:28 -0800 Anton Vorontsov anton.vorontsov@linaro.org wrote:
This patch introduces vmpressure_fd() system call. The system call creates a new file descriptor that can be used to monitor Linux' virtual memory management pressure.
I noticed a couple of quick things as I was looking this over...
+static ssize_t vmpressure_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)+{
- struct vmpressure_watch *watch = file->private_data;
 - struct vmpressure_event event;
 - int ret;
 - if (count < sizeof(event))
 return -EINVAL;- ret = wait_event_interruptible(watch->waitq,
 atomic_read(&watch->pending));
Would it make sense to support non-blocking reads? Perhaps a process would like to simply know that current pressure level?
+SYSCALL_DEFINE1(vmpressure_fd, struct vmpressure_config __user *, config) +{
- struct vmpressure_watch *watch;
 - struct file *file;
 - int ret;
 - int fd;
 - watch = kzalloc(sizeof(*watch), GFP_KERNEL);
 - if (!watch)
 return -ENOMEM;- ret = copy_from_user(&watch->config, config, sizeof(*config));
 - if (ret)
 goto err_free;
This is wrong - you'll return the number of uncopied bytes to user space. You'll need a "ret = -EFAULT;" in there somewhere.
jon