Skip to contentSkip to conversation

mm/memcontrol: Move misplaced local_unlock_irqrestore()

PATCH In review Matt Fleming 3 participants 4 messages Jan 26, 2020 – Feb 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/memcontrol: Move misplaced local_unlock_irqrestore()

There's no need to leave interrupts disabled when calling css_put_many().

---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 7b6f208c5a6b..1120b9d8dd86 100644
@@ -7062,10 +7062,10 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
 	mem_cgroup_charge_statistics(memcg, page, PageTransHuge(page),
 				     -nr_entries);
 	memcg_check_events(memcg, page);
+	local_unlock_irqrestore(event_lock, flags);
 
 	if (!mem_cgroup_is_root(memcg))
 		css_put_many(&memcg->css, nr_entries);
-	local_unlock_irqrestore(event_lock, flags);
 }
 
 /**
Signature · 1 line
2.16.4
#1 lore raw
Quoted 1 line · Matt Fleming

There's no need to leave interrupts disabled when calling css_put_many().

For RT the interrupts are never actually disabled and for !RT they are disabled with or without the change.
The comment about the disable function mentions just the counters and css_put_many()'s callback just invokes a worker so it is probably save to move the function as suggested.

May I ask how on earth you managed to open that file on a Sunday evening?

Quoted 12 lines
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +0 -0
index 7b6f208c5a6b..1120b9d8dd86 100644
@@ -7062,10 +7062,10 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
 	mem_cgroup_charge_statistics(memcg, page, PageTransHuge(page),

mm/memcontrol.c void mem_cgroup_swapout(struct page *page, swp_entry_t entry) · line 7071

Quoted 10 lines
mm/memcontrol.c +1 -1
 				     -nr_entries);
 	memcg_check_events(memcg, page);
+	local_unlock_irqrestore(event_lock, flags);
 
 	if (!mem_cgroup_is_root(memcg))
 		css_put_many(&memcg->css, nr_entries);
-	local_unlock_irqrestore(event_lock, flags);
 }
 
 /**

Sebastian

#2 lore raw
Quoted 11 lines · Sebastian Andrzej Siewior
Quoted 1 line · Matt Fleming

There's no need to leave interrupts disabled when calling css_put_many().

For RT the interrupts are never actually disabled and for !RT they are disabled with or without the change.
The comment about the disable function mentions just the counters and css_put_many()'s callback just invokes a worker so it is probably save to move the function as suggested.

May I ask how on earth you managed to open that file on a Sunday evening?

We're carrying it in some of our older SUSE RT kernels and I'd really like to get it upstream or sent to /dev/null ;)

#3 lore raw
Quoted 10 lines · Matt Fleming
Quoted 9 lines · Sebastian Andrzej Siewior
Quoted 1 line · Matt Fleming

There's no need to leave interrupts disabled when calling css_put_many().

For RT the interrupts are never actually disabled and for !RT they are disabled with or without the change.
The comment about the disable function mentions just the counters and css_put_many()'s callback just invokes a worker so it is probably save to move the function as suggested.

Quoted 5 lines
Quoted 2 lines

May I ask how on earth you managed to open that file on a Sunday evening?

We're carrying it in some of our older SUSE RT kernels and I'd really like to get it upstream or sent to /dev/null ;)

My recollection of the reason for that patchlet existing was simply because while rummaging around one day, unlock placement offended my eye a bit, so I did a dinky on the spot correction.

-Mike