From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 279FFC433E0 for ; Thu, 21 Jan 2021 20:45:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E283F2389F for ; Thu, 21 Jan 2021 20:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727215AbhAUUpw (ORCPT ); Thu, 21 Jan 2021 15:45:52 -0500 Received: from mga05.intel.com ([192.55.52.43]:37512 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbhAUUp2 (ORCPT ); Thu, 21 Jan 2021 15:45:28 -0500 IronPort-SDR: PQwBvX+2Yrz1KbyVxZcgFh51rJ9AAnsY23wGCPsYrm4C5zb/BCGemrBVLySJV/sgKLJYZWaKoR EZS9syFibIbA== X-IronPort-AV: E=McAfee;i="6000,8403,9871"; a="264158504" X-IronPort-AV: E=Sophos;i="5.79,365,1602572400"; d="scan'208";a="264158504" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2021 12:44:42 -0800 IronPort-SDR: iWrkowc9lTVPGtp0BdOaORGEGvpEGVXhbQ55YISgflUo4A/le6q/fC8so1C94c4aKOjD+IHlFj 60JH6Cj0qe7w== X-IronPort-AV: E=Sophos;i="5.79,365,1602572400"; d="scan'208";a="385456191" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.46.254]) ([10.209.46.254]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2021 12:44:40 -0800 Subject: Re: [PATCH v17 08/26] x86/mm: Introduce _PAGE_COW To: Dave Hansen , Borislav Petkov Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu References: <20201229213053.16395-1-yu-cheng.yu@intel.com> <20201229213053.16395-9-yu-cheng.yu@intel.com> <20210121184405.GE32060@zn.tnic> <28f56a51-b8e5-4f1f-1cda-036670c80a22@intel.com> From: "Yu, Yu-cheng" Message-ID: <6d696e26-4a08-b5bb-8ddf-6800ab98c49c@intel.com> Date: Thu, 21 Jan 2021 12:44:38 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <28f56a51-b8e5-4f1f-1cda-036670c80a22@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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