From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751774AbeFEPFV (ORCPT ); Tue, 5 Jun 2018 11:05:21 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:44589 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbeFEPFS (ORCPT ); Tue, 5 Jun 2018 11:05:18 -0400 X-Google-Smtp-Source: ADUXVKJ62ayiBkQqtwBIS2HKD6VBEKRKhDDpR45LDHcK41aP3AHElO2C4TbbvtfzpGnW/U5YGTjoWA== Date: Tue, 5 Jun 2018 17:05:14 +0200 From: Ingo Molnar To: Linus Torvalds , Alexey Dobriyan Cc: Alexey Dobriyan , Linux Kernel Mailing List , Thomas Gleixner , Peter Zijlstra , Andrew Morton , Andy Lutomirski , Borislav Petkov , Josh Poimboeuf , "H. Peter Anvin" , Denys Vlasenko Subject: Re: x86/asm: __clear_user() micro-optimization (was: "Re: [GIT PULL] x86/asm changes for v4.18") Message-ID: <20180605150514.GA31065@gmail.com> References: <20180604122132.GA3337@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Linus Torvalds wrote: > On Mon, Jun 4, 2018 at 5:21 AM Ingo Molnar wrote: > > > > - __clear_user() micro-optimization (Alexey Dobriyan) > > Was this actually tested? I'm not sure - Alexey? > I think one reason people avoided the constant was that on some > microarchitecture it ended up being a separate uop just for the > constant generation, because it wouldn't fit in a single uop. > > I'm pretty sure that used to be the case for P4, for example. > > Afaik there have also been issues with decoding instructions that have > both an immediate and a memory offset. > > I suspect none of this is an issue on modern cores, but there really > at least historically were cases where > > mov %reg,mem > > was better than > > mov $imm,mem > > if %reg already had the right value, so it's not at all 100% obvious > that the micro-optimization really _optimizes_ anything. > > Any time people do this, they should add numbers. Ok, fair point and agreed - if Alexey sends some measurements to back the change I'll keep this, otherwise queue up a revert. Thanks, Ingo