public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zram: enable compaction support in zram
@ 2015-04-17  1:07 Sergey Senozhatsky
  2015-04-17  1:31 ` Minchan Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2015-04-17  1:07 UTC (permalink / raw)
  To: Andrew Morton, Minchan Kim; +Cc: Nitin Gupta, linux-kernel, Sergey Senozhatsky

Commit c72c6160d967 ("zram: move compact_store() to sysfs functions area")
was intended to be a cosmetic change that moved function around w/o any
functional change:
http://lkml.iu.edu/hypermail/linux/kernel/1503.1/01818.html

Unfortunately, on its way from mmotm to Linus's tree it was altered and turned
into "remove compaction support from zram" commit. I've managed to create a
mess of commits and Andrew had to pick some of the commits and hand edit them.

Fix it and learn my lessons.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 Documentation/blockdev/zram.txt |  2 +-
 drivers/block/zram/zram_drv.c   | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index 48a183e..bef4998 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -126,7 +126,7 @@ mem_used_max      RW    the maximum amount memory zram have consumed to
 mem_limit         RW    the maximum amount of memory ZRAM can use to store
                         the compressed data
 num_migrated      RO    the number of objects migrated migrated by compaction
-
+compact           WO    trigger memory compaction
 
 WARNING
 =======
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index c94386a..f474cbe 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -261,6 +261,27 @@ static ssize_t comp_algorithm_store(struct device *dev,
 	return len;
 }
 
+static ssize_t compact_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t len)
+{
+	unsigned long nr_migrated;
+	struct zram *zram = dev_to_zram(dev);
+	struct zram_meta *meta;
+
+	down_read(&zram->init_lock);
+	if (!init_done(zram)) {
+		up_read(&zram->init_lock);
+		return -EINVAL;
+	}
+
+	meta = zram->meta;
+	nr_migrated = zs_compact(meta->mem_pool);
+	atomic64_add(nr_migrated, &zram->stats.num_migrated);
+	up_read(&zram->init_lock);
+
+	return len;
+}
+
 /* flag operations needs meta->tb_lock */
 static int zram_test_flag(struct zram_meta *meta, u32 index,
 			enum zram_pageflags flag)
@@ -1038,6 +1059,7 @@ static const struct block_device_operations zram_devops = {
 	.owner = THIS_MODULE
 };
 
+static DEVICE_ATTR_WO(compact);
 static DEVICE_ATTR_RW(disksize);
 static DEVICE_ATTR_RO(initstate);
 static DEVICE_ATTR_WO(reset);
@@ -1114,6 +1136,7 @@ static struct attribute *zram_disk_attrs[] = {
 	&dev_attr_num_writes.attr,
 	&dev_attr_failed_reads.attr,
 	&dev_attr_failed_writes.attr,
+	&dev_attr_compact.attr,
 	&dev_attr_invalid_io.attr,
 	&dev_attr_notify_free.attr,
 	&dev_attr_zero_pages.attr,
-- 
2.4.0.rc1.29.gecc46a1


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

* Re: [PATCH] zram: enable compaction support in zram
  2015-04-17  1:07 [PATCH] zram: enable compaction support in zram Sergey Senozhatsky
@ 2015-04-17  1:31 ` Minchan Kim
       [not found]   ` <CAHqPoq+s7eH21NQsQAyJMqfE9GjnsnxC92pbKwcR-JW9mXCJdQ@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Minchan Kim @ 2015-04-17  1:31 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Andrew Morton, Nitin Gupta, linux-kernel, Sergey Senozhatsky

On Fri, Apr 17, 2015 at 10:07:40AM +0900, Sergey Senozhatsky wrote:
> Commit c72c6160d967 ("zram: move compact_store() to sysfs functions area")
> was intended to be a cosmetic change that moved function around w/o any
> functional change:
> http://lkml.iu.edu/hypermail/linux/kernel/1503.1/01818.html
> 
> Unfortunately, on its way from mmotm to Linus's tree it was altered and turned
> into "remove compaction support from zram" commit. I've managed to create a
> mess of commits and Andrew had to pick some of the commits and hand edit them.
> 
> Fix it and learn my lessons.
> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>


-- 
Kind regards,
Minchan Kim

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

* Re: [PATCH] zram: enable compaction support in zram
       [not found]   ` <CAHqPoq+s7eH21NQsQAyJMqfE9GjnsnxC92pbKwcR-JW9mXCJdQ@mail.gmail.com>
@ 2015-04-17  1:41     ` Minchan Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Minchan Kim @ 2015-04-17  1:41 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Sergey Senozhatsky, Andrew Morton, Nitin Gupta,
	linux-kernel@vger.kernel.org

On Fri, Apr 17, 2015 at 10:34:57AM +0900, Sergey Senozhatsky wrote:
> >> Commit c72c6160d967 ("zram: move compact_store() to sysfs functions
> area")
> >> was intended to be a cosmetic change that moved function around w/o any
> >> functional change:
> >> http://lkml.iu.edu/hypermail/linux/kernel/1503.1/01818.html
> >>
> >> Unfortunately, on its way from mmotm to Linus's tree it was altered and
> turned
> >> into "remove compaction support from zram" commit. I've managed to
> create a
> >> mess of commits and Andrew had to pick some of the commits and hand edit
> them.
> >>
> >> Fix it and learn my lessons.
> >>
> >> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > Acked-by: Minchan Kim <minchan@kernel.org>
> 
> 
> let's just revert c72c6160d967ed26a0b136dbab337f821d233509 instead.
> this commit doesn't make a lot of sense.

Agree.

-- 
Kind regards,
Minchan Kim

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

end of thread, other threads:[~2015-04-17  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-17  1:07 [PATCH] zram: enable compaction support in zram Sergey Senozhatsky
2015-04-17  1:31 ` Minchan Kim
     [not found]   ` <CAHqPoq+s7eH21NQsQAyJMqfE9GjnsnxC92pbKwcR-JW9mXCJdQ@mail.gmail.com>
2015-04-17  1:41     ` Minchan Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox