Re: [PATCH 3/3] ramzswap: Handler for swap slot free callback

From: Minchan Kim
Date: Mon May 17 2010 - 08:04:04 EST


On Mon, May 17, 2010 at 2:32 PM, Nitin Gupta <ngupta@xxxxxxxxxx> wrote:
> Install handler for swap_slot_free_notify callback which is called
> when a swap slot is no longer used. This handler immediately frees
> memory allocated corresponding to the given swap slot.
>
> Signed-off-by: Nitin Gupta <ngupta@xxxxxxxxxx>
> ---
> Âdrivers/staging/ramzswap/TODO Â Â Â Â Â | Â Â5 -----
> Âdrivers/staging/ramzswap/ramzswap_drv.c | Â 22 +++++++++++++---------
> Â2 files changed, 13 insertions(+), 14 deletions(-)
> Âdelete mode 100644 drivers/staging/ramzswap/TODO
>
> diff --git a/drivers/staging/ramzswap/TODO b/drivers/staging/ramzswap/TODO
> deleted file mode 100644
> index 8d64e28..0000000
> --- a/drivers/staging/ramzswap/TODO
> +++ /dev/null
> @@ -1,5 +0,0 @@
> -TODO:
> - Â Â Â - Add support for swap notifiers
> -
> -Please send patches to Greg Kroah-Hartman <greg@xxxxxxxxx> and
> -Nitin Gupta <ngupta@xxxxxxxxxx>
> diff --git a/drivers/staging/ramzswap/ramzswap_drv.c b/drivers/staging/ramzswap/ramzswap_drv.c
> index ee5eb12..ab15276 100644
> --- a/drivers/staging/ramzswap/ramzswap_drv.c
> +++ b/drivers/staging/ramzswap/ramzswap_drv.c
> @@ -795,14 +795,6 @@ static int ramzswap_write(struct ramzswap *rzs, struct bio *bio)
>
> Â Â Â Âsrc = rzs->compress_buffer;
>
> - Â Â Â /*
> - Â Â Â Â* System swaps to same sector again when the stored page
> - Â Â Â Â* is no longer referenced by any process. So, its now safe
> - Â Â Â Â* to free the memory that was allocated for this page.
> - Â Â Â Â*/
> - Â Â Â if (rzs->table[index].page || rzs_test_flag(rzs, index, RZS_ZERO))
> - Â Â Â Â Â Â Â ramzswap_free_page(rzs, index);
> -
> Â Â Â Âmutex_lock(&rzs->lock);
>
> Â Â Â Âuser_mem = kmap_atomic(page, KM_USER0);
> @@ -1295,9 +1287,21 @@ out:
> Â Â Â Âreturn ret;
> Â}
>
> +void ramzswap_slot_free_notify(struct block_device *bdev, unsigned long index)
> +{
> + Â Â Â struct ramzswap *rzs;
> +
> + Â Â Â rzs = bdev->bd_disk->private_data;
> + Â Â Â ramzswap_free_page(rzs, index);
> + Â Â Â rzs_stat64_inc(rzs, &rzs->stats.notify_free);
> +
> + Â Â Â return;
> +}

Mistake. Let's remove _return_ in void function.
Otherwise, looks good to me.

Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx>


--
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/