All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nitin Gupta <ngupta@vflare.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH RFC 1/2] Add notifiers for various swap events
Date: Thu, 24 Sep 2009 08:40:56 +0530	[thread overview]
Message-ID: <4ABAE340.7010403@vflare.org> (raw)
In-Reply-To: <20090924104708.4f54ce4e.kamezawa.hiroyu@jp.fujitsu.com>

On 09/24/2009 07:17 AM, KAMEZAWA Hiroyuki wrote:
> On Mon, 21 Sep 2009 19:03:59 +0530
> Nitin Gupta <ngupta@vflare.org> wrote:
> 
>> Add notifiers for following swap events:
>>  - Swapon
>>  - Swapoff
>>  - When a swap slot is freed
>>
>> This is required for ramzswap module which implements RAM based block
>> devices to be used as swap disks. These devices require a notification
>> on these events to function properly (as shown in patch 2/2).
>>
>> Currently, I'm not sure if any of these event notifiers have any other
>> users. However, adding ramzswap specific hooks instead of this generic
>> approach resulted in a bad/hacky code.
>>
> Hmm ? if it's not necessary to make ramzswap as module, for-ramzswap-only
> code is much easier to read..
>

The patches posted earlier (v3 patches) inserts special hooks for swap slot
free event only. In this version, the callback is set when we get first R/W request.
Actually ramzswap needs callback for swapon/swapoff too but I just didn't do it.

Then Pekka posted test patch that allows setting this callback during swapon
itself. Looking that all these patches, I realized its already too messy even
if we just make everything ramzswap specific.
Just FYI, Pekka's test patch:
http://patchwork.kernel.org/patch/48472/

Then I added this generic notifier interface which, compared to earlier version,
looks much cleaner. The code to add these notifiers is also very small.
 
> 
> 
>> For SWAP_EVENT_SLOT_FREE, callbacks are made under swap_lock. Currently, this
>> is not a problem since ramzswap is the only user and the callback it registers
>> can be safely made under this lock. However, if this event finds more users,
>> we might have to work on reducing contention on this lock.
>>
>> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
>>
> 
> In general, notifier chain codes allowed to return NOTIFY_BAD.
> But this patch just assumes all chains should return NOTIFY_OK or
> just ignore return code.
> 
> That's not good as generic interface, I think.


What action we can take here if the notifier_call_chain() returns an error (apart
from maybe printing an error)? Perhaps we can add a warning in case of swapon/off
events but not in case of swap slot free event which is called under swap_lock.



Thanks,
Nitin

WARNING: multiple messages have this Message-ID (diff)
From: Nitin Gupta <ngupta@vflare.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH RFC 1/2] Add notifiers for various swap events
Date: Thu, 24 Sep 2009 08:40:56 +0530	[thread overview]
Message-ID: <4ABAE340.7010403@vflare.org> (raw)
In-Reply-To: <20090924104708.4f54ce4e.kamezawa.hiroyu@jp.fujitsu.com>

On 09/24/2009 07:17 AM, KAMEZAWA Hiroyuki wrote:
> On Mon, 21 Sep 2009 19:03:59 +0530
> Nitin Gupta <ngupta@vflare.org> wrote:
> 
>> Add notifiers for following swap events:
>>  - Swapon
>>  - Swapoff
>>  - When a swap slot is freed
>>
>> This is required for ramzswap module which implements RAM based block
>> devices to be used as swap disks. These devices require a notification
>> on these events to function properly (as shown in patch 2/2).
>>
>> Currently, I'm not sure if any of these event notifiers have any other
>> users. However, adding ramzswap specific hooks instead of this generic
>> approach resulted in a bad/hacky code.
>>
> Hmm ? if it's not necessary to make ramzswap as module, for-ramzswap-only
> code is much easier to read..
>

The patches posted earlier (v3 patches) inserts special hooks for swap slot
free event only. In this version, the callback is set when we get first R/W request.
Actually ramzswap needs callback for swapon/swapoff too but I just didn't do it.

Then Pekka posted test patch that allows setting this callback during swapon
itself. Looking that all these patches, I realized its already too messy even
if we just make everything ramzswap specific.
Just FYI, Pekka's test patch:
http://patchwork.kernel.org/patch/48472/

Then I added this generic notifier interface which, compared to earlier version,
looks much cleaner. The code to add these notifiers is also very small.
 
> 
> 
>> For SWAP_EVENT_SLOT_FREE, callbacks are made under swap_lock. Currently, this
>> is not a problem since ramzswap is the only user and the callback it registers
>> can be safely made under this lock. However, if this event finds more users,
>> we might have to work on reducing contention on this lock.
>>
>> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
>>
> 
> In general, notifier chain codes allowed to return NOTIFY_BAD.
> But this patch just assumes all chains should return NOTIFY_OK or
> just ignore return code.
> 
> That's not good as generic interface, I think.


What action we can take here if the notifier_call_chain() returns an error (apart
from maybe printing an error)? Perhaps we can add a warning in case of swapon/off
events but not in case of swap slot free event which is called under swap_lock.



Thanks,
Nitin

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

  reply	other threads:[~2009-09-24  3:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-21 13:33 [PATCH RFC 1/2] Add notifiers for various swap events Nitin Gupta
2009-09-21 13:33 ` Nitin Gupta
2009-09-21 13:34 ` [PATCH RFC 2/2] example usage of swap notifiers in ramzswap Nitin Gupta
2009-09-21 13:34   ` Nitin Gupta
2009-09-24  1:47 ` [PATCH RFC 1/2] Add notifiers for various swap events KAMEZAWA Hiroyuki
2009-09-24  1:47   ` KAMEZAWA Hiroyuki
2009-09-24  3:10   ` Nitin Gupta [this message]
2009-09-24  3:10     ` Nitin Gupta
2009-09-24  3:50     ` KAMEZAWA Hiroyuki
2009-09-24  3:50       ` KAMEZAWA Hiroyuki
2009-09-24  5:03       ` Nitin Gupta
2009-09-24  5:03         ` Nitin Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ABAE340.7010403@vflare.org \
    --to=ngupta@vflare.org \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.