* [PATCH 0/2] ZRAM Cleanup
@ 2012-06-21 3:32 Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 1/2] staging: zram: Remove some dead code Marcos Paulo de Souza
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2012-06-21 3:32 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, linux-mm-cc, ngupta, Marcos Paulo de Souza
These two patches cleans a little the zram driver.
I hope you enjoy :)
Marcos Paulo de Souza (2):
staging: zram: Remove dead code
staging: zram: Remove useless struct zobj_header
drivers/staging/zram/zram_drv.c | 18 +++---------------
drivers/staging/zram/zram_drv.h | 12 ------------
2 files changed, 3 insertions(+), 27 deletions(-)
--
1.7.10.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] staging: zram: Remove some dead code
2012-06-21 3:32 [PATCH 0/2] ZRAM Cleanup Marcos Paulo de Souza
@ 2012-06-21 3:32 ` Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 2/2] staging: zram: Remove useless struct zobj_header Marcos Paulo de Souza
2012-06-21 5:02 ` [PATCH 0/2] ZRAM Cleanup Minchan Kim
2 siblings, 0 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2012-06-21 3:32 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, linux-mm-cc, ngupta, Marcos Paulo de Souza
This patch removes code that is never executed by zram.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
---
drivers/staging/zram/zram_drv.c | 9 ---------
drivers/staging/zram/zram_drv.h | 3 ---
2 files changed, 12 deletions(-)
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 685d612..5216ee1 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -415,15 +415,6 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
cmem = zs_map_object(zram->mem_pool, handle);
memstore:
-#if 0
- /* Back-reference needed for memory defragmentation */
- if (!zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)) {
- zheader = (struct zobj_header *)cmem;
- zheader->table_idx = index;
- cmem += sizeof(*zheader);
- }
-#endif
-
memcpy(cmem, src, clen);
if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index fbe8ac9..fe3f8fe 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -33,9 +33,6 @@ static const unsigned max_num_devices = 32;
* object. This is required to support memory defragmentation.
*/
struct zobj_header {
-#if 0
- u32 table_idx;
-#endif
};
/*-- Configurable parameters */
--
1.7.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] staging: zram: Remove useless struct zobj_header
2012-06-21 3:32 [PATCH 0/2] ZRAM Cleanup Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 1/2] staging: zram: Remove some dead code Marcos Paulo de Souza
@ 2012-06-21 3:32 ` Marcos Paulo de Souza
2012-06-23 15:18 ` Dan Carpenter
2012-06-21 5:02 ` [PATCH 0/2] ZRAM Cleanup Minchan Kim
2 siblings, 1 reply; 5+ messages in thread
From: Marcos Paulo de Souza @ 2012-06-21 3:32 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, linux-mm-cc, ngupta, Marcos Paulo de Souza
The struct zobj_header has no members, so the sizeof(struct zobj_header *)
always returns zero. For this reason we are removing this useless struct.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
---
drivers/staging/zram/zram_drv.c | 9 +++------
drivers/staging/zram/zram_drv.h | 9 ---------
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 5216ee1..a79a20d 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -209,7 +209,6 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
int ret;
size_t clen;
struct page *page;
- struct zobj_header *zheader;
unsigned char *user_mem, *cmem, *uncmem = NULL;
page = bvec->bv_page;
@@ -249,7 +248,7 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
cmem = zs_map_object(zram->mem_pool, zram->table[index].handle);
- ret = lzo1x_decompress_safe(cmem + sizeof(*zheader),
+ ret = lzo1x_decompress_safe(cmem,
zram->table[index].size,
uncmem, &clen);
@@ -278,7 +277,6 @@ static int zram_read_before_write(struct zram *zram, char *mem, u32 index)
{
int ret;
size_t clen = PAGE_SIZE;
- struct zobj_header *zheader;
unsigned char *cmem;
if (zram_test_flag(zram, index, ZRAM_ZERO) ||
@@ -296,7 +294,7 @@ static int zram_read_before_write(struct zram *zram, char *mem, u32 index)
return 0;
}
- ret = lzo1x_decompress_safe(cmem + sizeof(*zheader),
+ ret = lzo1x_decompress_safe(cmem,
zram->table[index].size,
mem, &clen);
zs_unmap_object(zram->mem_pool, zram->table[index].handle);
@@ -318,7 +316,6 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
u32 store_offset;
size_t clen;
void *handle;
- struct zobj_header *zheader;
struct page *page, *page_store;
unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
@@ -405,7 +402,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
goto memstore;
}
- handle = zs_malloc(zram->mem_pool, clen + sizeof(*zheader));
+ handle = zs_malloc(zram->mem_pool, clen);
if (!handle) {
pr_info("Error allocating memory for compressed "
"page: %u, size=%zu\n", index, clen);
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index fe3f8fe..883f313 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -26,15 +26,6 @@
*/
static const unsigned max_num_devices = 32;
-/*
- * Stored at beginning of each compressed object.
- *
- * It stores back-reference to table entry which points to this
- * object. This is required to support memory defragmentation.
- */
-struct zobj_header {
-};
-
/*-- Configurable parameters */
/* Default zram disk size: 25% of total RAM */
--
1.7.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] ZRAM Cleanup
2012-06-21 3:32 [PATCH 0/2] ZRAM Cleanup Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 1/2] staging: zram: Remove some dead code Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 2/2] staging: zram: Remove useless struct zobj_header Marcos Paulo de Souza
@ 2012-06-21 5:02 ` Minchan Kim
2 siblings, 0 replies; 5+ messages in thread
From: Minchan Kim @ 2012-06-21 5:02 UTC (permalink / raw)
To: Marcos Paulo de Souza; +Cc: gregkh, devel, linux-mm-cc, linux-kernel, ngupta
Hi,
On 06/21/2012 12:32 PM, Marcos Paulo de Souza wrote:
> These two patches cleans a little the zram driver.
>
> I hope you enjoy :)
>
> Marcos Paulo de Souza (2):
> staging: zram: Remove dead code
> staging: zram: Remove useless struct zobj_header
>
> drivers/staging/zram/zram_drv.c | 18 +++---------------
> drivers/staging/zram/zram_drv.h | 12 ------------
> 2 files changed, 3 insertions(+), 27 deletions(-)
>
It was handled by [1] and on staging already.
[1] https://lkml.org/lkml/2012/6/8/116
Thanks.
--
Kind regards,
Minchan Kim
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] staging: zram: Remove useless struct zobj_header
2012-06-21 3:32 ` [PATCH 2/2] staging: zram: Remove useless struct zobj_header Marcos Paulo de Souza
@ 2012-06-23 15:18 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-06-23 15:18 UTC (permalink / raw)
To: Marcos Paulo de Souza; +Cc: gregkh, devel, linux-mm-cc, linux-kernel, ngupta
On Thu, Jun 21, 2012 at 12:32:45AM -0300, Marcos Paulo de Souza wrote:
> The struct zobj_header has no members, so the sizeof(struct zobj_header *)
> always returns zero. For this reason we are removing this useless struct.
>
I've been out for the past few days and I'm slowly catching up. If
you want you could update this comment as well:
drivers/staging/zram/zram_drv.h
40 /*
41 * NOTE: max_zpage_size must be less than or equal to:
42 * ZS_MAX_ALLOC_SIZE - sizeof(struct zobj_header)
43 * otherwise, xv_malloc() would always return failure.
44 */
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-23 15:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-21 3:32 [PATCH 0/2] ZRAM Cleanup Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 1/2] staging: zram: Remove some dead code Marcos Paulo de Souza
2012-06-21 3:32 ` [PATCH 2/2] staging: zram: Remove useless struct zobj_header Marcos Paulo de Souza
2012-06-23 15:18 ` Dan Carpenter
2012-06-21 5:02 ` [PATCH 0/2] ZRAM Cleanup Minchan Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox