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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 ACD2BC433E0 for ; Wed, 27 May 2020 16:40:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9507720721 for ; Wed, 27 May 2020 16:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729506AbgE0Qkn (ORCPT ); Wed, 27 May 2020 12:40:43 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:43368 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbgE0Qkm (ORCPT ); Wed, 27 May 2020 12:40:42 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdz6d-0006w9-OG; Wed, 27 May 2020 10:40:39 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jdz6c-0003Ki-Lj; Wed, 27 May 2020 10:40:39 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Alexey Dobriyan Cc: Kaitao Cheng , christian@brauner.io, akpm@linux-foundation.org, gladkov.alexey@gmail.com, guro@fb.com, walken@google.com, avagin@gmail.com, khlebnikov@yandex-team.ru, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <20200527141155.47554-1-pilgrimtao@gmail.com> <87k10x5tji.fsf@x220.int.ebiederm.org> <20200527152340.GA19985@localhost.localdomain> Date: Wed, 27 May 2020 11:36:48 -0500 In-Reply-To: <20200527152340.GA19985@localhost.localdomain> (Alexey Dobriyan's message of "Wed, 27 May 2020 18:23:40 +0300") Message-ID: <87k10x49nj.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jdz6c-0003Ki-Lj;;;mid=<87k10x49nj.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18BJ/5vPS/5ztRlPMmB8rb39/YlelSsKas= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink. X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexey Dobriyan writes: > On Wed, May 27, 2020 at 09:41:53AM -0500, Eric W. Biederman wrote: >> Kaitao Cheng writes: >> >> > we don't need {len = PTR_ERR(pathname)} when IS_ERR(pathname) is false, >> > it's better to move it into if(IS_ERR(pathname)){}. >> >> Please look at the generated code. >> >> I believe you will find that your change will generate worse assembly. > > I think patch is good. > > Super duper CPUs which speculate thousands instructions forward won't > care but more embedded ones do. Or in other words 1 unnecessary instruction > on common path is more important for slow CPUs than for fast CPUs. No. This adds an entire extra basic block, with an extra jump. A good compiler should not even generate an extra instruction for this case. A good compiler will just let len and pathname share the same register. So I think this will hurt your slow cpu case two as it winds up just plain being more assembly code, which stress the size of the slow cpus caches. I do admit a good compiler should be able to hoist the assignment above the branch (as we have today) it gets tricky to tell if hoisting the assignment is safe. > This style separates common path from error path more cleanly. Very arguable. [snip a completely different case] Yes larger cases can have different solutions. Eric