Re: [PATCH v17 08/26] x86/mm: Introduce _PAGE_COW

From: Yu, Yu-cheng
Date: Thu Jan 21 2021 - 15:46:09 EST


On 1/21/2021 12:26 PM, Dave Hansen wrote:
Usually, the compiler is better at making code efficient than humans. I
find that coding it in the most human-readable way is best unless I
*know* the compiler is unable to generate god code.

"good code", even.

I really want a "god code" compiler, though. :)

With my version of GCC, the shifting implementation creates five instructions, all operate on registers only. The other implementation also creates five instructions, but introduces one jump and one memory access. But, you are right, being readable is also important. Maybe we can tweak it a little or create something similar to those in bitops.

--
Yu-cheng