mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: "Markus Elfring" <Markus.Elfring@web.de>,
	linux-mm@kvack.org, "Andrew Morton" <akpm@linux-foundation.org>,
	"Anshuman Khandual" <anshuman.khandual@arm.com>,
	"Dave Jiang" <dave.jiang@intel.com>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Ralph Campbell" <rcampbell@nvidia.com>,
	"Souptick Joarder" <jrdr.linux@gmail.com>,
	"Yang Shi" <yang.shi@linux.alibaba.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mm/ksm: One function call less in __ksm_enter()
Date: Mon, 8 Jul 2019 09:34:14 +0300	[thread overview]
Message-ID: <64187a86-e704-140a-ec86-817c14db1812@virtuozzo.com> (raw)
In-Reply-To: <997c8ec3-9af8-3db0-24dc-cd99fe3efe14@web.de>

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

      reply	other threads:[~2019-07-08  6:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 14:16 Markus Elfring
2019-07-08  6:34 ` Kirill Tkhai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64187a86-e704-140a-ec86-817c14db1812@virtuozzo.com \
    --to=ktkhai@virtuozzo.com \
    --cc=Markus.Elfring@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=dave.jiang@intel.com \
    --cc=jglisse@redhat.com \
    --cc=jrdr.linux@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rcampbell@nvidia.com \
    --cc=yang.shi@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®