All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-snap: optimize track_chunk
@ 2012-10-16 23:04 Mikulas Patocka
  2012-10-17  0:01 ` Mike Snitzer
  0 siblings, 1 reply; 3+ messages in thread
From: Mikulas Patocka @ 2012-10-16 23:04 UTC (permalink / raw)
  To: Alasdair G. Kergon; +Cc: dm-devel

dm-snap: optimize track_chunk

track_chunk is always called with interrupts enabled. Consequently, we
do not need to save and restore interrupt state in "flags" variable.
This patch changes spin_lock_irqsave to spin_lock_irq and
spin_unlock_irqrestore to spin_unlock_irq.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-snap.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: linux-3.6.2-fast/drivers/md/dm-snap.c
===================================================================
--- linux-3.6.2-fast.orig/drivers/md/dm-snap.c	2012-10-17 00:43:01.000000000 +0200
+++ linux-3.6.2-fast/drivers/md/dm-snap.c	2012-10-17 00:43:22.000000000 +0200
@@ -201,14 +201,13 @@ static struct dm_snap_tracked_chunk *tra
 {
 	struct dm_snap_tracked_chunk *c = mempool_alloc(s->tracked_chunk_pool,
 							GFP_NOIO);
-	unsigned long flags;
 
 	c->chunk = chunk;
 
-	spin_lock_irqsave(&s->tracked_chunk_lock, flags);
+	spin_lock_irq(&s->tracked_chunk_lock);
 	hlist_add_head(&c->node,
 		       &s->tracked_chunk_hash[DM_TRACKED_CHUNK_HASH(chunk)]);
-	spin_unlock_irqrestore(&s->tracked_chunk_lock, flags);
+	spin_unlock_irq(&s->tracked_chunk_lock);
 
 	return c;
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dm-snap: optimize track_chunk
  2012-10-16 23:04 [PATCH] dm-snap: optimize track_chunk Mikulas Patocka
@ 2012-10-17  0:01 ` Mike Snitzer
  2012-10-17  0:44   ` Mikulas Patocka
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Snitzer @ 2012-10-17  0:01 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: dm-devel, Alasdair G. Kergon

On Tue, Oct 16 2012 at  7:04pm -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:

> dm-snap: optimize track_chunk
> 
> track_chunk is always called with interrupts enabled. Consequently, we
> do not need to save and restore interrupt state in "flags" variable.
> This patch changes spin_lock_irqsave to spin_lock_irq and
> spin_unlock_irqrestore to spin_unlock_irq.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> ---
>  drivers/md/dm-snap.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> Index: linux-3.6.2-fast/drivers/md/dm-snap.c
> ===================================================================
> --- linux-3.6.2-fast.orig/drivers/md/dm-snap.c	2012-10-17 00:43:01.000000000 +0200
> +++ linux-3.6.2-fast/drivers/md/dm-snap.c	2012-10-17 00:43:22.000000000 +0200
> @@ -201,14 +201,13 @@ static struct dm_snap_tracked_chunk *tra
>  {
>  	struct dm_snap_tracked_chunk *c = mempool_alloc(s->tracked_chunk_pool,
>  							GFP_NOIO);
> -	unsigned long flags;
>  
>  	c->chunk = chunk;
>  
> -	spin_lock_irqsave(&s->tracked_chunk_lock, flags);
> +	spin_lock_irq(&s->tracked_chunk_lock);

Does is make any sense to add "BUG_ON(irqs_disabled());" before the spin_lock_irq?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dm-snap: optimize track_chunk
  2012-10-17  0:01 ` Mike Snitzer
@ 2012-10-17  0:44   ` Mikulas Patocka
  0 siblings, 0 replies; 3+ messages in thread
From: Mikulas Patocka @ 2012-10-17  0:44 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: dm-devel, Alasdair G. Kergon



On Tue, 16 Oct 2012, Mike Snitzer wrote:

> On Tue, Oct 16 2012 at  7:04pm -0400,
> Mikulas Patocka <mpatocka@redhat.com> wrote:
> 
> > dm-snap: optimize track_chunk
> > 
> > track_chunk is always called with interrupts enabled. Consequently, we
> > do not need to save and restore interrupt state in "flags" variable.
> > This patch changes spin_lock_irqsave to spin_lock_irq and
> > spin_unlock_irqrestore to spin_unlock_irq.
> > 
> > Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> > 
> > ---
> >  drivers/md/dm-snap.c |    5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > Index: linux-3.6.2-fast/drivers/md/dm-snap.c
> > ===================================================================
> > --- linux-3.6.2-fast.orig/drivers/md/dm-snap.c	2012-10-17 00:43:01.000000000 +0200
> > +++ linux-3.6.2-fast/drivers/md/dm-snap.c	2012-10-17 00:43:22.000000000 +0200
> > @@ -201,14 +201,13 @@ static struct dm_snap_tracked_chunk *tra
> >  {
> >  	struct dm_snap_tracked_chunk *c = mempool_alloc(s->tracked_chunk_pool,
> >  							GFP_NOIO);
> > -	unsigned long flags;
> >  
> >  	c->chunk = chunk;
> >  
> > -	spin_lock_irqsave(&s->tracked_chunk_lock, flags);
> > +	spin_lock_irq(&s->tracked_chunk_lock);
> 
> Does is make any sense to add "BUG_ON(irqs_disabled());" before the 
> spin_lock_irq?

You can add it, but I think there is not high risk that someone calls it 
from interrupt context in the future.

Mikulas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-17  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 23:04 [PATCH] dm-snap: optimize track_chunk Mikulas Patocka
2012-10-17  0:01 ` Mike Snitzer
2012-10-17  0:44   ` Mikulas Patocka

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.