Skip to content

Commit df6879a

Browse files
RichardWeiYangakpm00
authored andcommitted
mm/ksm: cleanup mm_slot_entry() invocation
Patch series "mm_slot: following fixup for usage of mm_slot_entry()", v2. We got some late review commits during review of "mm_slot: fix the usage of mm_slot_entry()" in [1]. This patch (of 2): We got some late review commits during review of commit 08498be ("mm/ksm: get mm_slot by mm_slot_entry() when slot is !NULL"). Let's reduce the indentation level and make the code easier to follow by using gotos to a new label. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] [1] Fixes: 08498be ("mm/ksm: get mm_slot by mm_slot_entry() when slot is !NULL") Signed-off-by: Wei Yang <[email protected]> Reviewed-by: Dev Jain <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Kiryl Shutsemau <[email protected]> Acked-by: Zi Yan <[email protected]> Cc: Lance Yang <[email protected]> Cc: xu xin <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Chengming Zhou <[email protected]> Cc: Baolin Wang <[email protected]> Cc: Barry Song <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Mariano Pache <[email protected]> Cc: Raghavendra K T <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Kiryl Shutsemau <[email protected]> Cc: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a089461 commit df6879a

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

mm/ksm.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,7 +2921,7 @@ int __ksm_enter(struct mm_struct *mm)
29212921

29222922
void __ksm_exit(struct mm_struct *mm)
29232923
{
2924-
struct ksm_mm_slot *mm_slot;
2924+
struct ksm_mm_slot *mm_slot = NULL;
29252925
struct mm_slot *slot;
29262926
int easy_to_free = 0;
29272927

@@ -2936,19 +2936,20 @@ void __ksm_exit(struct mm_struct *mm)
29362936

29372937
spin_lock(&ksm_mmlist_lock);
29382938
slot = mm_slot_lookup(mm_slots_hash, mm);
2939-
if (slot) {
2940-
mm_slot = mm_slot_entry(slot, struct ksm_mm_slot, slot);
2941-
if (ksm_scan.mm_slot != mm_slot) {
2942-
if (!mm_slot->rmap_list) {
2943-
hash_del(&slot->hash);
2944-
list_del(&slot->mm_node);
2945-
easy_to_free = 1;
2946-
} else {
2947-
list_move(&slot->mm_node,
2948-
&ksm_scan.mm_slot->slot.mm_node);
2949-
}
2950-
}
2939+
if (!slot)
2940+
goto unlock;
2941+
mm_slot = mm_slot_entry(slot, struct ksm_mm_slot, slot);
2942+
if (ksm_scan.mm_slot == mm_slot)
2943+
goto unlock;
2944+
if (!mm_slot->rmap_list) {
2945+
hash_del(&slot->hash);
2946+
list_del(&slot->mm_node);
2947+
easy_to_free = 1;
2948+
} else {
2949+
list_move(&slot->mm_node,
2950+
&ksm_scan.mm_slot->slot.mm_node);
29512951
}
2952+
unlock:
29522953
spin_unlock(&ksm_mmlist_lock);
29532954

29542955
if (easy_to_free) {

0 commit comments

Comments
 (0)