* [PATCH] [mmotm] comment on swap notify locking constraints
@ 2010-01-14 14:32 Nitin Gupta
2010-01-14 15:10 ` Hugh Dickins
0 siblings, 1 reply; 3+ messages in thread
From: Nitin Gupta @ 2010-01-14 14:32 UTC (permalink / raw)
To: Hugh Dickins, Pekka Enberg
Cc: Andrew Morton, Al Viro, Christoph Hellwig, Jens Axboe,
Andi Kleen, linux-kernel
A block device makes swap_slot_free_notify() callback
when the last reference to a swap slot is dropped.
This callback is made under swap_lock and often with
lock for corresponding swapcache page also held. This
is a note of warning for registered callback function
which must meet these constraints.
Signed-off-by: Nitin Gupta <ngupta@vflare.org>
---
include/linux/blkdev.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 14b95a3..e3dcff6 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1295,6 +1295,7 @@ struct block_device_operations {
unsigned long long);
int (*revalidate_disk) (struct gendisk *);
int (*getgeo)(struct block_device *, struct hd_geometry *);
+ /* this callback is with swap_lock and often page lock also held */
void (*swap_slot_free_notify) (struct block_device *, unsigned long);
struct module *owner;
};
--
1.6.2.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [mmotm] comment on swap notify locking constraints
2010-01-14 14:32 [PATCH] [mmotm] comment on swap notify locking constraints Nitin Gupta
@ 2010-01-14 15:10 ` Hugh Dickins
2010-01-14 17:59 ` Nitin Gupta
0 siblings, 1 reply; 3+ messages in thread
From: Hugh Dickins @ 2010-01-14 15:10 UTC (permalink / raw)
To: Nitin Gupta
Cc: Pekka Enberg, Andrew Morton, Al Viro, Christoph Hellwig,
Jens Axboe, Andi Kleen, linux-kernel
On Thu, 14 Jan 2010, Nitin Gupta wrote:
> A block device makes swap_slot_free_notify() callback
> when the last reference to a swap slot is dropped.
>
> This callback is made under swap_lock and often with
> lock for corresponding swapcache page also held. This
> is a note of warning for registered callback function
> which must meet these constraints.
You're right that the page lock of the corresponding swapcache page
may be held there, but that isn't what worried me enough to ask for
a comment: it's the page table lock (sometimes we call it pte lock),
a spinlock like the swap_lock, being held there that particularly
deserves comment. We don't want someone going to lots of effort
to avoid holding swap_lock there, only to find that effort wasted
because page table lock is also held.
Hugh
>
> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
> ---
> include/linux/blkdev.h | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 14b95a3..e3dcff6 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1295,6 +1295,7 @@ struct block_device_operations {
> unsigned long long);
> int (*revalidate_disk) (struct gendisk *);
> int (*getgeo)(struct block_device *, struct hd_geometry *);
> + /* this callback is with swap_lock and often page lock also held */
and page table lock
> void (*swap_slot_free_notify) (struct block_device *, unsigned long);
> struct module *owner;
> };
> --
> 1.6.2.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [mmotm] comment on swap notify locking constraints
2010-01-14 15:10 ` Hugh Dickins
@ 2010-01-14 17:59 ` Nitin Gupta
0 siblings, 0 replies; 3+ messages in thread
From: Nitin Gupta @ 2010-01-14 17:59 UTC (permalink / raw)
To: Hugh Dickins
Cc: Pekka Enberg, Andrew Morton, Al Viro, Christoph Hellwig,
Jens Axboe, Andi Kleen, linux-kernel
On 01/14/2010 08:40 PM, Hugh Dickins wrote:
> On Thu, 14 Jan 2010, Nitin Gupta wrote:
>
>> A block device makes swap_slot_free_notify() callback
>> when the last reference to a swap slot is dropped.
>>
>> This callback is made under swap_lock and often with
>> lock for corresponding swapcache page also held. This
>> is a note of warning for registered callback function
>> which must meet these constraints.
>
> You're right that the page lock of the corresponding swapcache page
> may be held there, but that isn't what worried me enough to ask for
> a comment: it's the page table lock (sometimes we call it pte lock),
> a spinlock like the swap_lock, being held there that particularly
> deserves comment. We don't want someone going to lots of effort
> to avoid holding swap_lock there, only to find that effort wasted
> because page table lock is also held.
Thanks for the review.
I was missing this important point regarding pte lock. I will edit
the comment and resend the patch.
Nitin
>>
>> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
>> ---
>> include/linux/blkdev.h | 1 +
>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index 14b95a3..e3dcff6 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -1295,6 +1295,7 @@ struct block_device_operations {
>> unsigned long long);
>> int (*revalidate_disk) (struct gendisk *);
>> int (*getgeo)(struct block_device *, struct hd_geometry *);
>> + /* this callback is with swap_lock and often page lock also held */
>
> and page table lock
>
>> void (*swap_slot_free_notify) (struct block_device *, unsigned long);
>> struct module *owner;
>> };
>> --
>> 1.6.2.5
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-14 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-14 14:32 [PATCH] [mmotm] comment on swap notify locking constraints Nitin Gupta
2010-01-14 15:10 ` Hugh Dickins
2010-01-14 17:59 ` Nitin Gupta
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.