mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Jihong <yangjihong1@huawei.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: <tom.zanussi@linux.intel.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [QUESTION] Performance deterioration caused by commit 85f726a35e504418
Date: Tue, 19 Oct 2021 10:39:47 +0800	[thread overview]
Message-ID: <19e4222c-c9ac-5c1a-0c3a-b8bfd3524ab7@huawei.com> (raw)
In-Reply-To: <20211018093731.2dd5917f@gandalf.local.home>

Hi Steve,

On 2021/10/18 21:37, Steven Rostedt wrote:
> On Mon, 18 Oct 2021 11:23:14 +0800
> Yang Jihong <yangjihong1@huawei.com> wrote:
> 
>> Hi Tom and Steven,
>>
>> commit 85f726a35e504418 use strncpy instead of memcpy when copying comm,
>> on ARM64 machine, this commit causes performance degradation.
>>
>> I test the number of instructions executed by invoking the
>> trace_sched_switch function once on an arm64 machine:
>> 1. Use memcpy, the number of instructions executed is 850.
>> 2. Use strncpy, the number of instructions executed 1100.
>> That is, use strncpy is almost 250 more instructions than memcpy.
>>
>> Has the impact on performance been considered in this commit? :)
>> What is the impact of revert the patch?
>>
> 
> It's a security issue. And like everything security, there's always going
> to be a performance impact. Look at the performance impact due to spectre
> and meltdown!
> 
> That said, although memcpy() may not be used, we don't need strncpy.
> strncpy() will pad the rest of the string with nul bytes. But since the
> memory the string is being recorded into is already initialized (or can be
> if it isn't), we could use the faster strlcpy().
> 
> Have you tried testing it by switching strncpy() with strlcpy()?
> 
I have tried testing it by switching strncpy() with strlcpy(), there is 
no performance improvement, probably because the strlen function is 
called in strlpy and the string is traversed each time.

Kind regards,
Jihong
> -- Steve
> .
> 

  reply	other threads:[~2021-10-19  2:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18  3:23 Yang Jihong
2021-10-18 13:37 ` Steven Rostedt
2021-10-19  2:39   ` Yang Jihong [this message]
2021-10-19  2:51     ` Steven Rostedt
2021-10-19 17:30       ` Zanussi, Tom
2021-10-19 18:10         ` Steven Rostedt
2021-10-19 18:38           ` Zanussi, Tom
2021-10-20  2:00             ` Yang Jihong

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=19e4222c-c9ac-5c1a-0c3a-b8bfd3524ab7@huawei.com \
    --to=yangjihong1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tom.zanussi@linux.intel.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®