LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC] shmem: Add eventfd notification on utlilization level
@ 2015-02-11 14:50 Krzysztof Kozlowski
  2015-02-11 14:50 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2015-02-11 14:50 UTC (permalink / raw)
  To: Hugh Dickins, linux-mm, linux-kernel, Alexander Viro, linux-fsdevel
  Cc: Kyungmin Park, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	Krzysztof Kozlowski

Hi,


We have a need of getting notifications from kernel to user-space
when tmpfs runs out of free space. I used here a term 'utilization'
in the meaning of percent of free space.

The idea I got is to use eventfd. Proof of concept attached:
1. Patch for kernel.
2. Sample C program (at the end of cover letter).

Usage:
$ mount -t tmpfs -o warn_used=1k,nr_blocks=2k none /path
$ ( sleep 5 && dd if=/dev/zero of=/path/file bs=1M count=4 ) &
$ ./eventfd-wait /sys/fs/tmpfs/tmpfs-6/warn_used_blocks_efd


What do you think about this? Maybe there are simpler ways
of achieving this?

Best regards,
Krzysztof


------------[ cut here ]------------
#include <sys/eventfd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>				 /* Definition of uint64_t */

#define handle_error(msg) \
	do { perror(msg); exit(EXIT_FAILURE); } while (0)

int
main(int argc, char *argv[])
{
	int efd;
	uint64_t u;
	ssize_t s;
	int fd;
	char buf[10];

	if (argc != 2) {
		printf("Usage: %s PATH\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	efd = eventfd(0, 0);
	if (efd == -1)
		 handle_error("eventfd");

	fd = open(argv[1], O_WRONLY);
	if (fd < 0)
		handle_error("sysfs open");

	snprintf(buf, sizeof(buf), "%d", efd);

	s = write(fd, buf, strlen(buf));
	if (s < 0)
		handle_error("sysfs write");

	close(fd);
	
	printf("Waiting for usage notification:\n");
	s = read(efd, &u, sizeof(uint64_t));
	if (s != sizeof(uint64_t))
		 handle_error("read");
	printf("Usage threshold reached: %llu\n",
			  (unsigned long long) u, (unsigned long long) u);
	exit(EXIT_SUCCESS);
}
------------[ cut here ]------------


Krzysztof Kozlowski (1):
  shmem: Add eventfd notification on utlilization level

 include/linux/shmem_fs.h |   4 ++
 mm/shmem.c               | 138 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 140 insertions(+), 2 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC] shmem: Add eventfd notification on utlilization level
  2015-02-11 14:50 [RFC] shmem: Add eventfd notification on utlilization level Krzysztof Kozlowski
@ 2015-02-11 14:50 ` Krzysztof Kozlowski
  2015-03-10  1:51   ` Kyungmin Park
  0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2015-02-11 14:50 UTC (permalink / raw)
  To: Hugh Dickins, linux-mm, linux-kernel, Alexander Viro, linux-fsdevel
  Cc: Kyungmin Park, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	Krzysztof Kozlowski

Allow notifying user space when used space of tmpfs exceeds specified
level.

The utilization level is passed as mount option 'warn_used'. The kernel
will notify user-space through eventfd after exceeding this number of
used blocks.

The eventfd descriptor has to be passed through sysfs file:
/sys/fs/tmpfs/tmpfs-[0-9]+/warn_used_blocks_efd

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 include/linux/shmem_fs.h |   4 ++
 mm/shmem.c               | 138 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 140 insertions(+), 2 deletions(-)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 50777b5b1e4c..c2ec9909da95 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -35,6 +35,10 @@ struct shmem_sb_info {
 	kgid_t gid;		    /* Mount gid for root directory */
 	umode_t mode;		    /* Mount mode for root directory */
 	struct mempolicy *mpol;     /* default memory policy for mappings */
+	unsigned long warn_used;    /* Warn on reaching used blocks */
+	struct kobject s_kobj;      /* kobj for sysfs attributes */
+	struct completion s_kobj_unregister; /* synchronization for put_super */
+	struct eventfd_ctx *warn_used_efd; /* user-space passed eventfd */
 };
 
 static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
diff --git a/mm/shmem.c b/mm/shmem.c
index f69d296bd0a3..b559adcef3b3 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -34,6 +34,7 @@
 #include <linux/aio.h>
 
 static struct vfsmount *shm_mnt;
+static struct kset *shmem_kset;
 
 #ifdef CONFIG_SHMEM
 /*
@@ -69,6 +70,7 @@ static struct vfsmount *shm_mnt;
 #include <linux/syscalls.h>
 #include <linux/fcntl.h>
 #include <uapi/linux/memfd.h>
+#include <linux/eventfd.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -199,6 +201,106 @@ static struct backing_dev_info shmem_backing_dev_info  __read_mostly = {
 static LIST_HEAD(shmem_swaplist);
 static DEFINE_MUTEX(shmem_swaplist_mutex);
 
+
+struct shmem_attr {
+	struct attribute attr;
+	ssize_t (*show)(struct shmem_attr *, struct shmem_sb_info *, char *);
+	ssize_t (*store)(struct shmem_attr *, struct shmem_sb_info *,
+			 const char *, size_t);
+};
+
+static int shmem_setup_warn_used_blocks_eventfd(struct shmem_sb_info *sbinfo,
+					unsigned int efd)
+{
+	int ret = 0;
+
+	if (sbinfo->warn_used_efd) {
+		eventfd_ctx_put(sbinfo->warn_used_efd);
+		sbinfo->warn_used_efd = NULL;
+	}
+
+	sbinfo->warn_used_efd = eventfd_ctx_fdget(efd);
+	if (IS_ERR(sbinfo->warn_used_efd)) {
+		ret = PTR_ERR(sbinfo->warn_used_efd);
+		sbinfo->warn_used_efd = NULL;
+	}
+
+	return ret;
+}
+
+static int parse_strtouint(const char *buf,
+		unsigned long long max, unsigned int *value)
+{
+	int ret;
+
+	ret = kstrtouint(skip_spaces(buf), 0, value);
+	if (!ret && *value > max)
+		ret = -EINVAL;
+	return ret;
+}
+
+static ssize_t warn_used_blocks_efd_store(struct shmem_attr *a,
+					struct shmem_sb_info *sbinfo,
+					const char *buf, size_t count)
+{
+	unsigned int val;
+	int ret;
+
+	if (parse_strtouint(buf, -1ULL, &val))
+		return -EINVAL;
+
+	ret = shmem_setup_warn_used_blocks_eventfd(sbinfo, val);
+
+	return ret ? ret : count;
+}
+
+static struct shmem_attr
+shmem_attr_warn_used_blocks_efd = __ATTR_WO(warn_used_blocks_efd);
+
+static struct attribute *shmem_attrs[] = {
+	&shmem_attr_warn_used_blocks_efd.attr,
+	NULL,
+};
+
+static ssize_t shmem_attr_show(struct kobject *kobj,
+			      struct attribute *attr, char *buf)
+{
+	struct shmem_sb_info *sbinfo = container_of(kobj, struct shmem_sb_info,
+						s_kobj);
+	struct shmem_attr *a = container_of(attr, struct shmem_attr, attr);
+
+	return a->show ? a->show(a, sbinfo, buf) : 0;
+}
+
+static ssize_t shmem_attr_store(struct kobject *kobj,
+			       struct attribute *attr,
+			       const char *buf, size_t len)
+{
+	struct shmem_sb_info *sbinfo = container_of(kobj, struct shmem_sb_info,
+						s_kobj);
+	struct shmem_attr *a = container_of(attr, struct shmem_attr, attr);
+
+	return a->store ? a->store(a, sbinfo, buf, len) : 0;
+}
+
+static void shmem_sb_release(struct kobject *kobj)
+{
+	struct shmem_sb_info *sbinfo = container_of(kobj, struct shmem_sb_info,
+						s_kobj);
+	complete(&sbinfo->s_kobj_unregister);
+}
+
+static const struct sysfs_ops shmem_attr_ops = {
+	.show	= shmem_attr_show,
+	.store	= shmem_attr_store,
+};
+
+static struct kobj_type shmem_ktype = {
+	.default_attrs	= shmem_attrs,
+	.sysfs_ops	= &shmem_attr_ops,
+	.release	= shmem_sb_release,
+};
+
 static int shmem_reserve_inode(struct super_block *sb)
 {
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
@@ -1170,6 +1272,13 @@ repeat:
 			}
 			percpu_counter_inc(&sbinfo->used_blocks);
 		}
+		if (sbinfo->warn_used) {
+			if (percpu_counter_compare(&sbinfo->used_blocks,
+						sbinfo->warn_used) >= 0) {
+				if (sbinfo->warn_used_efd)
+					eventfd_signal(sbinfo->warn_used_efd, 1);
+			}
+		}
 
 		page = shmem_alloc_page(gfp, info, index);
 		if (!page) {
@@ -2824,6 +2933,10 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
 			mpol = NULL;
 			if (mpol_parse_str(value, &mpol))
 				goto bad_val;
+		} else if (!strcmp(this_char,"warn_used")) {
+			sbinfo->warn_used = memparse(value, &rest);
+			if (*rest)
+				goto bad_val;
 		} else {
 			printk(KERN_ERR "tmpfs: Bad mount option %s\n",
 			       this_char);
@@ -2984,6 +3097,13 @@ static void shmem_put_super(struct super_block *sb)
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 
 	percpu_counter_destroy(&sbinfo->used_blocks);
+	if (sbinfo->warn_used_efd) {
+		eventfd_ctx_put(sbinfo->warn_used_efd);
+		sbinfo->warn_used_efd = NULL;
+	}
+	kobject_del(&sbinfo->s_kobj);
+	kobject_put(&sbinfo->s_kobj);
+	wait_for_completion(&sbinfo->s_kobj_unregister);
 	mpol_put(sbinfo->mpol);
 	kfree(sbinfo);
 	sb->s_fs_info = NULL;
@@ -2994,6 +3114,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
 	struct inode *inode;
 	struct shmem_sb_info *sbinfo;
 	int err = -ENOMEM;
+	static unsigned int no;
 
 	/* Round up to L1_CACHE_BYTES to resist false sharing */
 	sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
@@ -3045,17 +3166,25 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_TMPFS_POSIX_ACL
 	sb->s_flags |= MS_POSIXACL;
 #endif
+	sbinfo->s_kobj.kset = shmem_kset;
+	init_completion(&sbinfo->s_kobj_unregister);
+	err = kobject_init_and_add(&sbinfo->s_kobj, &shmem_ktype, NULL,
+				   "%s-%u", sb->s_id, no++);
+	if (err)
+		goto failed;
 
 	inode = shmem_get_inode(sb, NULL, S_IFDIR | sbinfo->mode, 0, VM_NORESERVE);
 	if (!inode)
-		goto failed;
+		goto failed_kobj;
 	inode->i_uid = sbinfo->uid;
 	inode->i_gid = sbinfo->gid;
 	sb->s_root = d_make_root(inode);
 	if (!sb->s_root)
-		goto failed;
+		goto failed_kobj;
 	return 0;
 
+failed_kobj:
+	kobject_del(&sbinfo->s_kobj);
 failed:
 	shmem_put_super(sb);
 	return err;
@@ -3225,6 +3354,10 @@ int __init shmem_init(void)
 	if (shmem_inode_cachep)
 		return 0;
 
+	shmem_kset = kset_create_and_add("tmpfs", NULL, fs_kobj);
+	if (!shmem_kset)
+		return -ENOMEM;
+
 	error = bdi_init(&shmem_backing_dev_info);
 	if (error)
 		goto out4;
@@ -3255,6 +3388,7 @@ out3:
 	bdi_destroy(&shmem_backing_dev_info);
 out4:
 	shm_mnt = ERR_PTR(error);
+	kset_unregister(shmem_kset);
 	return error;
 }
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC] shmem: Add eventfd notification on utlilization level
  2015-02-11 14:50 ` Krzysztof Kozlowski
@ 2015-03-10  1:51   ` Kyungmin Park
  2015-03-10 13:03     ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Kyungmin Park @ 2015-03-10  1:51 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Hugh Dickins, linux-mm, Linux Kernel Mailing List,
	Alexander Viro, Linux Filesystem Mailing List,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski

Any updates?

Thank you,
Kyungmin Park

On Wed, Feb 11, 2015 at 11:50 PM, Krzysztof Kozlowski
<k.kozlowski@samsung.com> wrote:
> Allow notifying user space when used space of tmpfs exceeds specified
> level.
>
> The utilization level is passed as mount option 'warn_used'. The kernel
> will notify user-space through eventfd after exceeding this number of
> used blocks.
>
> The eventfd descriptor has to be passed through sysfs file:
> /sys/fs/tmpfs/tmpfs-[0-9]+/warn_used_blocks_efd
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> ---
>  include/linux/shmem_fs.h |   4 ++
>  mm/shmem.c               | 138 ++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 140 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index 50777b5b1e4c..c2ec9909da95 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -35,6 +35,10 @@ struct shmem_sb_info {
>         kgid_t gid;                 /* Mount gid for root directory */
>         umode_t mode;               /* Mount mode for root directory */
>         struct mempolicy *mpol;     /* default memory policy for mappings */
> +       unsigned long warn_used;    /* Warn on reaching used blocks */
> +       struct kobject s_kobj;      /* kobj for sysfs attributes */
> +       struct completion s_kobj_unregister; /* synchronization for put_super */
> +       struct eventfd_ctx *warn_used_efd; /* user-space passed eventfd */
>  };
>
>  static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
> diff --git a/mm/shmem.c b/mm/shmem.c
> index f69d296bd0a3..b559adcef3b3 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -34,6 +34,7 @@
>  #include <linux/aio.h>
>
>  static struct vfsmount *shm_mnt;
> +static struct kset *shmem_kset;
>
>  #ifdef CONFIG_SHMEM
>  /*
> @@ -69,6 +70,7 @@ static struct vfsmount *shm_mnt;
>  #include <linux/syscalls.h>
>  #include <linux/fcntl.h>
>  #include <uapi/linux/memfd.h>
> +#include <linux/eventfd.h>
>
>  #include <asm/uaccess.h>
>  #include <asm/pgtable.h>
> @@ -199,6 +201,106 @@ static struct backing_dev_info shmem_backing_dev_info  __read_mostly = {
>  static LIST_HEAD(shmem_swaplist);
>  static DEFINE_MUTEX(shmem_swaplist_mutex);
>
> +
> +struct shmem_attr {
> +       struct attribute attr;
> +       ssize_t (*show)(struct shmem_attr *, struct shmem_sb_info *, char *);
> +       ssize_t (*store)(struct shmem_attr *, struct shmem_sb_info *,
> +                        const char *, size_t);
> +};
> +
> +static int shmem_setup_warn_used_blocks_eventfd(struct shmem_sb_info *sbinfo,
> +                                       unsigned int efd)
> +{
> +       int ret = 0;
> +
> +       if (sbinfo->warn_used_efd) {
> +               eventfd_ctx_put(sbinfo->warn_used_efd);
> +               sbinfo->warn_used_efd = NULL;
> +       }
> +
> +       sbinfo->warn_used_efd = eventfd_ctx_fdget(efd);
> +       if (IS_ERR(sbinfo->warn_used_efd)) {
> +               ret = PTR_ERR(sbinfo->warn_used_efd);
> +               sbinfo->warn_used_efd = NULL;
> +       }
> +
> +       return ret;
> +}
> +
> +static int parse_strtouint(const char *buf,
> +               unsigned long long max, unsigned int *value)
> +{
> +       int ret;
> +
> +       ret = kstrtouint(skip_spaces(buf), 0, value);
> +       if (!ret && *value > max)
> +               ret = -EINVAL;
> +       return ret;
> +}
> +
> +static ssize_t warn_used_blocks_efd_store(struct shmem_attr *a,
> +                                       struct shmem_sb_info *sbinfo,
> +                                       const char *buf, size_t count)
> +{
> +       unsigned int val;
> +       int ret;
> +
> +       if (parse_strtouint(buf, -1ULL, &val))
> +               return -EINVAL;
> +
> +       ret = shmem_setup_warn_used_blocks_eventfd(sbinfo, val);
> +
> +       return ret ? ret : count;
> +}
> +
> +static struct shmem_attr
> +shmem_attr_warn_used_blocks_efd = __ATTR_WO(warn_used_blocks_efd);
> +
> +static struct attribute *shmem_attrs[] = {
> +       &shmem_attr_warn_used_blocks_efd.attr,
> +       NULL,
> +};
> +
> +static ssize_t shmem_attr_show(struct kobject *kobj,
> +                             struct attribute *attr, char *buf)
> +{
> +       struct shmem_sb_info *sbinfo = container_of(kobj, struct shmem_sb_info,
> +                                               s_kobj);
> +       struct shmem_attr *a = container_of(attr, struct shmem_attr, attr);
> +
> +       return a->show ? a->show(a, sbinfo, buf) : 0;
> +}
> +
> +static ssize_t shmem_attr_store(struct kobject *kobj,
> +                              struct attribute *attr,
> +                              const char *buf, size_t len)
> +{
> +       struct shmem_sb_info *sbinfo = container_of(kobj, struct shmem_sb_info,
> +                                               s_kobj);
> +       struct shmem_attr *a = container_of(attr, struct shmem_attr, attr);
> +
> +       return a->store ? a->store(a, sbinfo, buf, len) : 0;
> +}
> +
> +static void shmem_sb_release(struct kobject *kobj)
> +{
> +       struct shmem_sb_info *sbinfo = container_of(kobj, struct shmem_sb_info,
> +                                               s_kobj);
> +       complete(&sbinfo->s_kobj_unregister);
> +}
> +
> +static const struct sysfs_ops shmem_attr_ops = {
> +       .show   = shmem_attr_show,
> +       .store  = shmem_attr_store,
> +};
> +
> +static struct kobj_type shmem_ktype = {
> +       .default_attrs  = shmem_attrs,
> +       .sysfs_ops      = &shmem_attr_ops,
> +       .release        = shmem_sb_release,
> +};
> +
>  static int shmem_reserve_inode(struct super_block *sb)
>  {
>         struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
> @@ -1170,6 +1272,13 @@ repeat:
>                         }
>                         percpu_counter_inc(&sbinfo->used_blocks);
>                 }
> +               if (sbinfo->warn_used) {
> +                       if (percpu_counter_compare(&sbinfo->used_blocks,
> +                                               sbinfo->warn_used) >= 0) {
> +                               if (sbinfo->warn_used_efd)
> +                                       eventfd_signal(sbinfo->warn_used_efd, 1);
> +                       }
> +               }
>
>                 page = shmem_alloc_page(gfp, info, index);
>                 if (!page) {
> @@ -2824,6 +2933,10 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
>                         mpol = NULL;
>                         if (mpol_parse_str(value, &mpol))
>                                 goto bad_val;
> +               } else if (!strcmp(this_char,"warn_used")) {
> +                       sbinfo->warn_used = memparse(value, &rest);
> +                       if (*rest)
> +                               goto bad_val;
>                 } else {
>                         printk(KERN_ERR "tmpfs: Bad mount option %s\n",
>                                this_char);
> @@ -2984,6 +3097,13 @@ static void shmem_put_super(struct super_block *sb)
>         struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
>
>         percpu_counter_destroy(&sbinfo->used_blocks);
> +       if (sbinfo->warn_used_efd) {
> +               eventfd_ctx_put(sbinfo->warn_used_efd);
> +               sbinfo->warn_used_efd = NULL;
> +       }
> +       kobject_del(&sbinfo->s_kobj);
> +       kobject_put(&sbinfo->s_kobj);
> +       wait_for_completion(&sbinfo->s_kobj_unregister);
>         mpol_put(sbinfo->mpol);
>         kfree(sbinfo);
>         sb->s_fs_info = NULL;
> @@ -2994,6 +3114,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
>         struct inode *inode;
>         struct shmem_sb_info *sbinfo;
>         int err = -ENOMEM;
> +       static unsigned int no;
>
>         /* Round up to L1_CACHE_BYTES to resist false sharing */
>         sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
> @@ -3045,17 +3166,25 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
>  #ifdef CONFIG_TMPFS_POSIX_ACL
>         sb->s_flags |= MS_POSIXACL;
>  #endif
> +       sbinfo->s_kobj.kset = shmem_kset;
> +       init_completion(&sbinfo->s_kobj_unregister);
> +       err = kobject_init_and_add(&sbinfo->s_kobj, &shmem_ktype, NULL,
> +                                  "%s-%u", sb->s_id, no++);
> +       if (err)
> +               goto failed;
>
>         inode = shmem_get_inode(sb, NULL, S_IFDIR | sbinfo->mode, 0, VM_NORESERVE);
>         if (!inode)
> -               goto failed;
> +               goto failed_kobj;
>         inode->i_uid = sbinfo->uid;
>         inode->i_gid = sbinfo->gid;
>         sb->s_root = d_make_root(inode);
>         if (!sb->s_root)
> -               goto failed;
> +               goto failed_kobj;
>         return 0;
>
> +failed_kobj:
> +       kobject_del(&sbinfo->s_kobj);
>  failed:
>         shmem_put_super(sb);
>         return err;
> @@ -3225,6 +3354,10 @@ int __init shmem_init(void)
>         if (shmem_inode_cachep)
>                 return 0;
>
> +       shmem_kset = kset_create_and_add("tmpfs", NULL, fs_kobj);
> +       if (!shmem_kset)
> +               return -ENOMEM;
> +
>         error = bdi_init(&shmem_backing_dev_info);
>         if (error)
>                 goto out4;
> @@ -3255,6 +3388,7 @@ out3:
>         bdi_destroy(&shmem_backing_dev_info);
>  out4:
>         shm_mnt = ERR_PTR(error);
> +       kset_unregister(shmem_kset);
>         return error;
>  }
>
> --
> 1.9.1
>
> --
> 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/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC] shmem: Add eventfd notification on utlilization level
  2015-03-10  1:51   ` Kyungmin Park
@ 2015-03-10 13:03     ` Christoph Hellwig
  2015-03-10 14:22       ` Jan Kara
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2015-03-10 13:03 UTC (permalink / raw)
  To: Kyungmin Park
  Cc: Krzysztof Kozlowski, Hugh Dickins, linux-mm,
	Linux Kernel Mailing List, Alexander Viro,
	Linux Filesystem Mailing List, Bartlomiej Zolnierkiewicz,
	Marek Szyprowski, Jan Kara

On Tue, Mar 10, 2015 at 10:51:41AM +0900, Kyungmin Park wrote:
> Any updates?

Please just add disk quota support to tmpfs so thast the standard quota
netlink notifications can be used.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC] shmem: Add eventfd notification on utlilization level
  2015-03-10 13:03     ` Christoph Hellwig
@ 2015-03-10 14:22       ` Jan Kara
  2015-03-10 15:25         ` Beata Michalska
  2015-03-11  4:35         ` Kyungmin Park
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Kara @ 2015-03-10 14:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Kyungmin Park, Krzysztof Kozlowski, Hugh Dickins, linux-mm,
	Linux Kernel Mailing List, Alexander Viro,
	Linux Filesystem Mailing List, Bartlomiej Zolnierkiewicz,
	Marek Szyprowski, Jan Kara

On Tue 10-03-15 06:03:23, Christoph Hellwig wrote:
> On Tue, Mar 10, 2015 at 10:51:41AM +0900, Kyungmin Park wrote:
> > Any updates?
> 
> Please just add disk quota support to tmpfs so thast the standard quota
> netlink notifications can be used.
  If I understand the problem at hand, they are really interested in
notification when running out of free space. Using quota for that doesn't
seem ideal since that tracks used space per user, not free space on fs as a
whole.

But if I remember right there were discussions about ENOSPC notification
from filesystem for thin provisioning usecases. It would be good to make
this consistent with those but I'm not sure if it went anywhere.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC] shmem: Add eventfd notification on utlilization level
  2015-03-10 14:22       ` Jan Kara
@ 2015-03-10 15:25         ` Beata Michalska
  2015-03-10 16:13           ` Lukáš Czerner
  2015-03-11  4:35         ` Kyungmin Park
  1 sibling, 1 reply; 8+ messages in thread
From: Beata Michalska @ 2015-03-10 15:25 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christoph Hellwig, Kyungmin Park, Krzysztof Kozlowski,
	Hugh Dickins, linux-mm, Linux Kernel Mailing List,
	Alexander Viro, Linux Filesystem Mailing List,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski

On 03/10/2015 03:22 PM, Jan Kara wrote:
> On Tue 10-03-15 06:03:23, Christoph Hellwig wrote:
>> On Tue, Mar 10, 2015 at 10:51:41AM +0900, Kyungmin Park wrote:
>>> Any updates?
>> Please just add disk quota support to tmpfs so thast the standard quota
>> netlink notifications can be used.
>   If I understand the problem at hand, they are really interested in
> notification when running out of free space. Using quota for that doesn't
> seem ideal since that tracks used space per user, not free space on fs as a
> whole.
>
> But if I remember right there were discussions about ENOSPC notification
> from filesystem for thin provisioning usecases. It would be good to make
> this consistent with those but I'm not sure if it went anywhere.
>
> 								Honza

The ideal case here, would be to get the notification, despite the type
of the actual filesystem, whenever the amount of free space drops below
a certain level. Quota doesn't seem to be the right approach here.

BR
Beata Michalska


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC] shmem: Add eventfd notification on utlilization level
  2015-03-10 15:25         ` Beata Michalska
@ 2015-03-10 16:13           ` Lukáš Czerner
  0 siblings, 0 replies; 8+ messages in thread
From: Lukáš Czerner @ 2015-03-10 16:13 UTC (permalink / raw)
  To: Beata Michalska
  Cc: Jan Kara, Christoph Hellwig, Kyungmin Park, Krzysztof Kozlowski,
	Hugh Dickins, linux-mm, Linux Kernel Mailing List,
	Alexander Viro, Linux Filesystem Mailing List,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski

On Tue, 10 Mar 2015, Beata Michalska wrote:

> Date: Tue, 10 Mar 2015 16:25:12 +0100
> From: Beata Michalska <b.k.m.devel@gmail.com>
> To: Jan Kara <jack@suse.cz>
> Cc: Christoph Hellwig <hch@infradead.org>,
>     Kyungmin Park <kmpark@infradead.org>,
>     Krzysztof Kozlowski <k.kozlowski@samsung.com>,
>     Hugh Dickins <hughd@google.com>, linux-mm <linux-mm@kvack.org>,
>     Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
>     Alexander Viro <viro@zeniv.linux.org.uk>,
>     Linux Filesystem Mailing List <linux-fsdevel@vger.kernel.org>,
>     Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
>     Marek Szyprowski <m.szyprowski@samsung.com>
> Subject: Re: [RFC] shmem: Add eventfd notification on utlilization level
> 
> On 03/10/2015 03:22 PM, Jan Kara wrote:
> > On Tue 10-03-15 06:03:23, Christoph Hellwig wrote:
> >> On Tue, Mar 10, 2015 at 10:51:41AM +0900, Kyungmin Park wrote:
> >>> Any updates?
> >> Please just add disk quota support to tmpfs so thast the standard quota
> >> netlink notifications can be used.
> >   If I understand the problem at hand, they are really interested in
> > notification when running out of free space. Using quota for that doesn't
> > seem ideal since that tracks used space per user, not free space on fs as a
> > whole.
> >
> > But if I remember right there were discussions about ENOSPC notification
> > from filesystem for thin provisioning usecases. It would be good to make
> > this consistent with those but I'm not sure if it went anywhere.
> >
> > 								Honza
> 
> The ideal case here, would be to get the notification, despite the type
> of the actual filesystem, whenever the amount of free space drops below
> a certain level. Quota doesn't seem to be the right approach here.
> 
> BR
> Beata Michalska

A while back I was prototyping a netlink notification interface for
file systems, but it went nowhere.

https://lkml.org/lkml/2011/8/18/170

So maybe it's time get back to the drawing board and finish the
idea, since it seems to be some interest in this now.

-Lukas

> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC] shmem: Add eventfd notification on utlilization level
  2015-03-10 14:22       ` Jan Kara
  2015-03-10 15:25         ` Beata Michalska
@ 2015-03-11  4:35         ` Kyungmin Park
  1 sibling, 0 replies; 8+ messages in thread
From: Kyungmin Park @ 2015-03-11  4:35 UTC (permalink / raw)
  To: Jan Kara
  Cc: Christoph Hellwig, Krzysztof Kozlowski, Hugh Dickins, linux-mm,
	Linux Kernel Mailing List, Alexander Viro,
	Linux Filesystem Mailing List, Bartlomiej Zolnierkiewicz,
	Marek Szyprowski

On Tue, Mar 10, 2015 at 11:22 PM, Jan Kara <jack@suse.cz> wrote:
> On Tue 10-03-15 06:03:23, Christoph Hellwig wrote:
>> On Tue, Mar 10, 2015 at 10:51:41AM +0900, Kyungmin Park wrote:
>> > Any updates?
>>
>> Please just add disk quota support to tmpfs so thast the standard quota
>> netlink notifications can be used.
>   If I understand the problem at hand, they are really interested in
> notification when running out of free space. Using quota for that doesn't
> seem ideal since that tracks used space per user, not free space on fs as a
> whole.
>
> But if I remember right there were discussions about ENOSPC notification
> from filesystem for thin provisioning usecases. It would be good to make
> this consistent with those but I'm not sure if it went anywhere.

In mobile case, it provides two warning messages when it remains 5%
and 0.1% respectively.
to achieve it, some daemon call statfs periodically. right it's inefficient.

that's reason we need some notification method from filesystem.

tmpfs is different story. some malicious app fills tmpfs then system
goes slow. so it has to check it periodically.
to avoid it, this patch is developed and want to get feedback.

we considered quota but it's not desired one. other can't write tmpfs
even though it has 20% remaining.

Thank you,
Kyungmin Park

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-11  4:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-11 14:50 [RFC] shmem: Add eventfd notification on utlilization level Krzysztof Kozlowski
2015-02-11 14:50 ` Krzysztof Kozlowski
2015-03-10  1:51   ` Kyungmin Park
2015-03-10 13:03     ` Christoph Hellwig
2015-03-10 14:22       ` Jan Kara
2015-03-10 15:25         ` Beata Michalska
2015-03-10 16:13           ` Lukáš Czerner
2015-03-11  4:35         ` Kyungmin Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).