* [PATCH] mm/ksm: One function call less in __ksm_enter()
@ 2019-07-05 14:16 Markus Elfring
2019-07-08 6:34 ` Kirill Tkhai
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2019-07-05 14:16 UTC (permalink / raw)
To: linux-mm, Andrew Morton, Anshuman Khandual, Dave Jiang,
Jérôme Glisse, Kirill Tkhai, Ralph Campbell,
Souptick Joarder, Yang Shi
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 5 Jul 2019 16:02:26 +0200
Avoid an extra function call by using a ternary operator instead of
a conditional statement.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
mm/ksm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c
index 3dc4346411e4..7934bab8ceae 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2521,10 +2521,10 @@ int __ksm_enter(struct mm_struct *mm)
* scanning cursor, otherwise KSM pages in newly forked mms will be
* missed: then we might as well insert at the end of the list.
*/
- if (ksm_run & KSM_RUN_UNMERGE)
- list_add_tail(&mm_slot->mm_list, &ksm_mm_head.mm_list);
- else
- list_add_tail(&mm_slot->mm_list, &ksm_scan.mm_slot->mm_list);
+ list_add_tail(&mm_slot->mm_list,
+ ksm_run & KSM_RUN_UNMERGE
+ ? &ksm_mm_head.mm_list
+ : &ksm_scan.mm_slot->mm_list);
spin_unlock(&ksm_mmlist_lock);
set_bit(MMF_VM_MERGEABLE, &mm->flags);
--
2.22.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/ksm: One function call less in __ksm_enter()
2019-07-05 14:16 [PATCH] mm/ksm: One function call less in __ksm_enter() Markus Elfring
@ 2019-07-08 6:34 ` Kirill Tkhai
0 siblings, 0 replies; 2+ messages in thread
From: Kirill Tkhai @ 2019-07-08 6:34 UTC (permalink / raw)
To: Markus Elfring, linux-mm, Andrew Morton, Anshuman Khandual,
Dave Jiang, Jérôme Glisse, Ralph Campbell,
Souptick Joarder, Yang Shi
Cc: LKML, kernel-janitors
On 05.07.2019 17:16, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 5 Jul 2019 16:02:26 +0200
>
> Avoid an extra function call by using a ternary operator instead of
> a conditional statement.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> mm/ksm.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/mm/ksm.c b/mm/ksm.c
> index 3dc4346411e4..7934bab8ceae 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -2521,10 +2521,10 @@ int __ksm_enter(struct mm_struct *mm)
> * scanning cursor, otherwise KSM pages in newly forked mms will be
> * missed: then we might as well insert at the end of the list.
> */
> - if (ksm_run & KSM_RUN_UNMERGE)
> - list_add_tail(&mm_slot->mm_list, &ksm_mm_head.mm_list);
> - else
> - list_add_tail(&mm_slot->mm_list, &ksm_scan.mm_slot->mm_list);
> + list_add_tail(&mm_slot->mm_list,
> + ksm_run & KSM_RUN_UNMERGE
> + ? &ksm_mm_head.mm_list
> + : &ksm_scan.mm_slot->mm_list);
Despite coccinelle warnings, I'm not sure this patch does not make the readability worse...
> spin_unlock(&ksm_mmlist_lock);
>
> set_bit(MMF_VM_MERGEABLE, &mm->flags);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-08 6:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05 14:16 [PATCH] mm/ksm: One function call less in __ksm_enter() Markus Elfring
2019-07-08 6:34 ` Kirill Tkhai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).