[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <19e4222c-c9ac-5c1a-0c3a-b8bfd3524ab7@huawei.com>
Date: Tue, 19 Oct 2021 10:39:47 +0800
From: Yang Jihong <yangjihong1@...wei.com>
To: Steven Rostedt <rostedt@...dmis.org>
CC: <tom.zanussi@...ux.intel.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [QUESTION] Performance deterioration caused by commit
85f726a35e504418
Hi Steve,
On 2021/10/18 21:37, Steven Rostedt wrote:
> On Mon, 18 Oct 2021 11:23:14 +0800
> Yang Jihong <yangjihong1@...wei.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
> .
>
Powered by blists - more mailing lists