linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* z3fold: suspicious return with spinlock held
@ 2017-03-10 21:22 Alexey Khoroshilov
  2017-03-10 21:34 ` Matthew Wilcox
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2017-03-10 21:22 UTC (permalink / raw)
  To: Vitaly Wool
  Cc: Alexey Khoroshilov, Andrew Morton, Dan Streetman, linux-mm,
	linux-kernel, ldv-project

Hello!

z3fold_reclaim_page() contains the only return that may
leave the function with pool->lock spinlock held.

669 	spin_lock(&pool->lock);
670 	if (kref_put(&zhdr->refcount, release_z3fold_page)) {
671 		atomic64_dec(&pool->pages_nr);
672 		return 0;
673 	}

May be we need spin_unlock(&pool->lock); just before return?


Found by Linux Driver Verification project (linuxtesting.org).

--
Thank you,
Alexey Khoroshilov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org

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

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

* Re: z3fold: suspicious return with spinlock held
  2017-03-10 21:22 z3fold: suspicious return with spinlock held Alexey Khoroshilov
@ 2017-03-10 21:34 ` Matthew Wilcox
  2017-03-10 21:54   ` Alexey Khoroshilov
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2017-03-10 21:34 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Vitaly Wool, Andrew Morton, Dan Streetman, linux-mm,
	linux-kernel, ldv-project

On Sat, Mar 11, 2017 at 12:22:12AM +0300, Alexey Khoroshilov wrote:
> Hello!
> 
> z3fold_reclaim_page() contains the only return that may
> leave the function with pool->lock spinlock held.
> 
> 669 	spin_lock(&pool->lock);
> 670 	if (kref_put(&zhdr->refcount, release_z3fold_page)) {
> 671 		atomic64_dec(&pool->pages_nr);
> 672 		return 0;
> 673 	}
> 
> May be we need spin_unlock(&pool->lock); just before return?

I would tend to agree.  sparse warns about this, and also about two
other locking problems ... which I'm not sure are really problems so
much as missing annotations?

mm/z3fold.c:467:35: warning: context imbalance in 'z3fold_alloc' - unexpected unlock
mm/z3fold.c:519:26: warning: context imbalance in 'z3fold_free' - different lock contexts for basic block
mm/z3fold.c:581:12: warning: context imbalance in 'z3fold_reclaim_page' - different lock contexts for basic block

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

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

* Re: z3fold: suspicious return with spinlock held
  2017-03-10 21:34 ` Matthew Wilcox
@ 2017-03-10 21:54   ` Alexey Khoroshilov
  2017-03-10 22:08     ` vitalywool
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Khoroshilov @ 2017-03-10 21:54 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Vitaly Wool, Andrew Morton, Dan Streetman, linux-mm,
	linux-kernel, ldv-project

On 11.03.2017 00:34, Matthew Wilcox wrote:
> On Sat, Mar 11, 2017 at 12:22:12AM +0300, Alexey Khoroshilov wrote:
>> Hello!
>>
>> z3fold_reclaim_page() contains the only return that may
>> leave the function with pool->lock spinlock held.
>>
>> 669 	spin_lock(&pool->lock);
>> 670 	if (kref_put(&zhdr->refcount, release_z3fold_page)) {
>> 671 		atomic64_dec(&pool->pages_nr);
>> 672 		return 0;
>> 673 	}
>>
>> May be we need spin_unlock(&pool->lock); just before return?
> 
> I would tend to agree.  sparse warns about this, and also about two
> other locking problems ... which I'm not sure are really problems so
> much as missing annotations?
> 
> mm/z3fold.c:467:35: warning: context imbalance in 'z3fold_alloc' - unexpected unlock
> mm/z3fold.c:519:26: warning: context imbalance in 'z3fold_free' - different lock contexts for basic block
> mm/z3fold.c:581:12: warning: context imbalance in 'z3fold_reclaim_page' - different lock contexts for basic block
> 

I also do not see problems in z3fold_alloc() and z3fold_free().
But I am unaware of sparse annotations that can help here.

--
Alexey

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

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

* Re: z3fold: suspicious return with spinlock held
  2017-03-10 21:54   ` Alexey Khoroshilov
@ 2017-03-10 22:08     ` vitalywool
  0 siblings, 0 replies; 4+ messages in thread
From: vitalywool @ 2017-03-10 22:08 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Matthew Wilcox, Andrew Morton, Dan Streetman, linux-mm,
	linux-kernel, ldv-project

Hi Alexey,

> 10 mars 2017 kl. 22:54 skrev Alexey Khoroshilov <khoroshilov@ispras.ru>:
> 
>> On 11.03.2017 00:34, Matthew Wilcox wrote:
>>> On Sat, Mar 11, 2017 at 12:22:12AM +0300, Alexey Khoroshilov wrote:
>>> Hello!
>>> 
>>> z3fold_reclaim_page() contains the only return that may
>>> leave the function with pool->lock spinlock held.
>>> 
>>> 669    spin_lock(&pool->lock);
>>> 670    if (kref_put(&zhdr->refcount, release_z3fold_page)) {
>>> 671        atomic64_dec(&pool->pages_nr);
>>> 672        return 0;
>>> 673    }
>>> 
>>> May be we need spin_unlock(&pool->lock); just before return?
Looks so, thanks for the pointer. I'm currently commuting but will check it thoroughly tomorrow for sure.

~vitaly 

>> 
>> I would tend to agree.  sparse warns about this, and also about two
>> other locking problems ... which I'm not sure are really problems so
>> much as missing annotations?
>> 
>> mm/z3fold.c:467:35: warning: context imbalance in 'z3fold_alloc' - unexpected unlock
>> mm/z3fold.c:519:26: warning: context imbalance in 'z3fold_free' - different lock contexts for basic block
>> mm/z3fold.c:581:12: warning: context imbalance in 'z3fold_reclaim_page' - different lock contexts for basic block
>> 
> 
> I also do not see problems in z3fold_alloc() and z3fold_free().
> But I am unaware of sparse annotations that can help here.
> 
> --
> Alexey

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

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

end of thread, other threads:[~2017-03-10 22:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 21:22 z3fold: suspicious return with spinlock held Alexey Khoroshilov
2017-03-10 21:34 ` Matthew Wilcox
2017-03-10 21:54   ` Alexey Khoroshilov
2017-03-10 22:08     ` vitalywool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox