lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f6be644e-5ec8-edd8-a451-0e0cbd0943eb@linux.intel.com>
Date:   Mon, 20 Jul 2020 15:02:50 -0400
From:   "Liang, Kan" <kan.liang@...ux.intel.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     acme@...hat.com, mingo@...nel.org, linux-kernel@...r.kernel.org,
        jolsa@...nel.org, eranian@...gle.com,
        alexander.shishkin@...ux.intel.com, ak@...ux.intel.com
Subject: Re: [PATCH V6 06/14] perf/x86/intel: Use switch in
 intel_pmu_disable/enable_event



On 7/20/2020 12:22 PM, Peter Zijlstra wrote:
> On Fri, Jul 17, 2020 at 07:05:46AM -0700, kan.liang@...ux.intel.com wrote:
>> From: Kan Liang <kan.liang@...ux.intel.com>
>>
>> Many items are checked in the intel_pmu_disable/enable_event. More items
>> will be added later, e.g. perf metrics events.
>>
>> Use switch, which is more efficient, to replace the if-else.
> 
> Perhaps explain how; does this actually generate a jump-table?

As my understanding, some optimizing compilers may compile a switch 
statement into a jump-table. So it depends.

Another advantage of switch statement is to improve the readability of 
the code. I think I missed it in the commit message.

I will change the commit message as below in V7.

"Currently, the if-else is used in the intel_pmu_disable/enable_event to 
check the type of an event. It works well, but with more and more types 
added later, e.g., perf metrics, compared to the switch statement, the 
if-else may impair the readability of the code.

Also, some optimizing compilers may compile a switch statement into a 
jump-table which is more efficient than if-else.

Use switch to replace the if-else in the intel_pmu_disable/enable_event()."


Thanks,
Kan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ