Re: [PATCH 3/4] zsmalloc use zs_handle instead of void *

From: Minchan Kim
Date: Sun May 13 2012 - 22:25:51 EST


On 05/12/2012 06:49 AM, Seth Jennings wrote:

> On 05/11/2012 02:29 PM, Konrad Rzeszutek Wilk wrote:
>
>>> At least, zram is also primary user and it also has such mess
>>> although it's not severe than zcache. zram->table[index].handle
>>> sometime has real (void*) handle, sometime (struct page*).
>>
>> Yikes. Yeah that needs to be fixed.
>>
>
>
> How about this (untested)? Changes to zram_bvec_write() are a little
> hard to make out in this format. There are a couple of checkpatch fixes
> (two split line strings) and an unused variable store_offset removal mixed
> in too. If this patch is good, I'll break them up for official submission
> after I test.
>
> diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
> index fbe8ac9..10dcd99 100644
> --- a/drivers/staging/zram/zram_drv.h
> +++ b/drivers/staging/zram/zram_drv.h
> @@ -81,7 +81,10 @@ enum zram_pageflags {
>
> /* Allocated for each disk page */
> struct table {
> - void *handle;
> + union {
> + void *handle; /* compressible */
> + struct page *page; /* incompressible */


You read my mind. That's exactly same idea with my patch which queued up to my tree.
But there is still problem.

zram has like this code

void *handle = zram->table[index].handle;
if (!handle) {

}

zram->table[index].handle = NULL;

It assume handle's size is greater than or equal to sizeof(struct page*)) for union working.
But we can't make sure handle's size.
If Nitin confirm this, too, the problem would be easy to fix.

--
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/