Skip to contentSkip to conversation

Drivers: hv: hv_balloon: keep locks balanced on add_memory() failure

PATCH In review Vitaly Kuznetsov 3 participants 4 messages Feb 20, 2015 – Mar 7, 2015 Hyper-V/Azure core and drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Drivers: hv: hv_balloon: keep locks balanced on add_memory() failure

When add_memory() fails the following BUG is observed:

[  743.646107] hv_balloon: hot_add memory failed error is -17
[  743.679973]
[  743.680930] =====================================
[  743.680930] [ BUG: bad unlock balance detected! ]
[  743.680930] 3.19.0-rc5_bug1131426+ #552 Not tainted
[  743.680930] -------------------------------------
[  743.680930] kworker/0:2/255 is trying to release lock (&dm_device.ha_region_mutex) at:
[  743.680930] [<ffffffff81aae5fe>] mutex_unlock+0xe/0x10
[  743.680930] but there are no more locks to release!

This happens as we don't acquire ha_region_mutex and hot_add_req() expects us to as it does unconditional mutex_unlock(). Acquire the lock on the error path.

---
This patch is dependent on the previously posted 'Drivers: hv: hv_balloon:
eliminate the trylock path in acquire/release_region_mutex'.

---
 drivers/hv/hv_balloon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hv/hv_balloon.c +1 -0
index 1283035..771bf84 100644
@@ -654,6 +654,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
 			}
 			has->ha_end_pfn -= HA_CHUNK;
 			has->covered_end_pfn -=  processed_pfn;
+			mutex_lock(&dm_device.ha_region_mutex);
 			break;
 		}
 
Signature · 1 line
1.9.3
#1 lore raw
Quoted 11 lines · Vitaly Kuznetsov

When add_memory() fails the following BUG is observed:

[  743.646107] hv_balloon: hot_add memory failed error is -17
[  743.679973]
[  743.680930] =====================================
[  743.680930] [ BUG: bad unlock balance detected! ]
[  743.680930] 3.19.0-rc5_bug1131426+ #552 Not tainted
[  743.680930] -------------------------------------
[  743.680930] kworker/0:2/255 is trying to release lock (&dm_device.ha_region_mutex) at:
[  743.680930] [<ffffffff81aae5fe>] mutex_unlock+0xe/0x10
[  743.680930] but there are no more locks to release!
Quoted 7 lines

This happens as we don't acquire ha_region_mutex and hot_add_req() expects us to as it does unconditional mutex_unlock(). Acquire the lock on the error path.

---
This patch is dependent on the previously posted 'Drivers: hv: hv_balloon:
eliminate the trylock path in acquire/release_region_mutex'.

Hi K.Y.,

I don't see this patch in your '[PATCH 0/7] Drivers: hv: Collection fixes and enhancements' sent to Greg. Please let me know if you see any issues with it as it looks like a pretty important bugfix to me.

Thanks,

Quoted 15 lines
---
 drivers/hv/hv_balloon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hv/hv_balloon.c +1 -0
index 1283035..771bf84 100644
@@ -654,6 +654,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
 			}
 			has->ha_end_pfn -= HA_CHUNK;
 			has->covered_end_pfn -=  processed_pfn;
+			mutex_lock(&dm_device.ha_region_mutex);
 			break;
 		}
Signature · 1 line
  Vitaly
#2 lore raw
Quoted 33 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Monday, March 2, 2015 2:34 AM
To: KY Srinivasan
Cc: [email protected]; Haiyang Zhang; linux- [email protected]; Dexuan Cui
Subject: Re: [PATCH] Drivers: hv: hv_balloon: keep locks balanced on add_memory() failure

Quoted 7 lines · Vitaly Kuznetsov

When add_memory() fails the following BUG is observed:

[  743.646107] hv_balloon: hot_add memory failed error is -17 [
743.679973] [  743.680930] =====================================
[  743.680930] [ BUG: bad unlock balance detected! ] [  743.680930]
3.19.0-rc5_bug1131426+ #552 Not tainted [  743.680930]
-------------------------------------
[  743.680930] kworker/0:2/255 is trying to release lock

(&dm_device.ha_region_mutex) at:

Quoted 5 lines
[  743.680930] [<ffffffff81aae5fe>] mutex_unlock+0xe/0x10 [

743.680930] but there are no more locks to release!

This happens as we don't acquire ha_region_mutex and hot_add_req() expects us to as it does unconditional mutex_unlock(). Acquire the lock on

the error path.

Quoted 5 lines

---
This patch is dependent on the previously posted 'Drivers: hv: hv_balloon:
eliminate the trylock path in acquire/release_region_mutex'.

Quoted 5 lines

Hi K.Y.,

I don't see this patch in your '[PATCH 0/7] Drivers: hv: Collection fixes and enhancements' sent to Greg. Please let me know if you see any issues with it as it looks like a pretty important bugfix to me.

Yes, I am sending this patch out soon.

K. Y

Quoted 20 lines

Thanks,

Quoted 9 lines
---
 drivers/hv/hv_balloon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hv/hv_balloon.c index renamed from drivers/hv/hv_balloon.c +0 -0

1283035..771bf84 100644

drivers/hv/hv_balloon.c static void hv_mem_hot_add(unsigned long start, · line 658

Quoted 5 lines
drivers/hv/hv_balloon.c +1 -0
@@ -654,6 +654,7 @@ static void hv_mem_hot_add(unsigned long start,
 unsigned long size,  }  has->ha_end_pfn -= HA_CHUNK;
 has->covered_end_pfn -=  processed_pfn;
+mutex_lock(&dm_device.ha_region_mutex);
 break;
 }

--
Vitaly

Acked-by on v1 1/1
#3 lore raw
In reply to Vitaly Kuznetsov

----- Original Message -----

Quoted 12 lines

When add_memory() fails the following BUG is observed:

[  743.646107] hv_balloon: hot_add memory failed error is -17
[  743.679973]
[  743.680930] =====================================
[  743.680930] [ BUG: bad unlock balance detected! ]
[  743.680930] 3.19.0-rc5_bug1131426+ #552 Not tainted
[  743.680930] -------------------------------------
[  743.680930] kworker/0:2/255 is trying to release lock
(&dm_device.ha_region_mutex) at:
[  743.680930] [<ffffffff81aae5fe>] mutex_unlock+0xe/0x10
[  743.680930] but there are no more locks to release!
Quoted 5 lines

This happens as we don't acquire ha_region_mutex and hot_add_req() expects us to as it does unconditional mutex_unlock(). Acquire the lock on the error path.

Quoted 29 lines

---
This patch is dependent on the previously posted 'Drivers: hv: hv_balloon:
eliminate the trylock path in acquire/release_region_mutex'.

---
 drivers/hv/hv_balloon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hv/hv_balloon.c +1 -1
index 1283035..771bf84 100644
@@ -654,6 +654,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned
 long size,
 			}
 			has->ha_end_pfn -= HA_CHUNK;
 			has->covered_end_pfn -=  processed_pfn;
+			mutex_lock(&dm_device.ha_region_mutex);
 			break;
 		}
 
--

1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/