Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1045156rwl; Fri, 7 Apr 2023 09:06:42 -0700 (PDT) X-Google-Smtp-Source: AKy350bE8VDvPGV7NzzAumrbXrFD7uLgzeickTwH1rSHDDjVCbjBYVMXkZBL4zFB+d/Z5K7mf2xX X-Received: by 2002:a17:902:cece:b0:19f:1c69:54b5 with SMTP id d14-20020a170902cece00b0019f1c6954b5mr4402747plg.12.1680883602049; Fri, 07 Apr 2023 09:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680883602; cv=none; d=google.com; s=arc-20160816; b=wnrdUeX4JaG8qn5aHgWimrztUaZRzY9PsChiyusvQmuqjHk7Vr/MLUJ/BnQCocrv5R dZmHjWPoRH1t4IbR+Wukxz5/v81T37YhXoz7y1DlWlu5wkRqwCQPeJU/ysV1zW61keWC VzMXntWOatKsG9WSZrITuL28LFgO1PSJJ7GIvWe3yKzoZNjrfq0Q/jlCaLD7gvYmOlvE l0o4ZQyvR6r4mMe1PaxIjUg1XNUPtDsk/UmdLMc5TuNIPwPMOeaOGNDhoNQ3RB4dAxX5 lyMbp+c7Oe2/lDR3804Wtwz5CY+jL2I3v//6xy335HW6cVAJOvBYn7c0qOkw5WbkFFOr JSqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ArkFzgGmWr5GIWIb5S26dnAG6/MRvelBkLMc+Gk1DCI=; b=RKZdohUHwfDWEiP5Wu8EcCzjKS6a8wOkSB82TNo4fCCp9LiEa55xp+3F+2iZ0w/tlc g2hmj8u5UbidCH+4AJV0/IpEckdH2TECqodeQxEIPQwP8ZZOCj5/qvF0y4ALh4Rz6/tJ /DxT5Jkesb2PgTNibA9z2OL6Hi2W6ChwUwLX/nmKjWJ9/BknJjsgOkktgAsmz1ub7/9c EUygJkexxnuyJgWHUXa8/CKiVpn0cciW/jYJTqI3JkQRyJNN5F/5yJMK+/e4Y7nbfTvr HFKEFco2Ay7q3ruIb6EIl3VRHWfAp7SOSJyM1/dcJfcVEgpHAKj80EabuZOf6gdo5Bry KYvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=b1x6wuN8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a170902daca00b0019e87f429d7si4419340plx.376.2023.04.07.09.06.24; Fri, 07 Apr 2023 09:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=b1x6wuN8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240628AbjDGQBu (ORCPT + 99 others); Fri, 7 Apr 2023 12:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240638AbjDGQBp (ORCPT ); Fri, 7 Apr 2023 12:01:45 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A81FBBB92 for ; Fri, 7 Apr 2023 09:01:32 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id l1-20020a170903244100b001a0468b4afcso24488403pls.12 for ; Fri, 07 Apr 2023 09:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680883291; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ArkFzgGmWr5GIWIb5S26dnAG6/MRvelBkLMc+Gk1DCI=; b=b1x6wuN8SB2jxdh5jqkPjFSPwNKAuuWDG6iq4r0w3QQ/c5uBQxAUffbz7fBkpbziRs lMJRpn1M2y6+OlEjiNm3RbYpHz87fmdsm1jcQrsUaK7jsdHCMBrQjEVfhZbS2K8FL1xC BjOOsJBZ/EzEfpR405ay040NT0E7n++jFFtxki7qpx43vYV/QX7b+IUkqPqVe7tcsl+y celfLgTwE59cPCrG6hNTC32U/dCV/eE9guxjTQaSprpdU+4l2Qni1vJVQi9P8OgA5p5x zskClbiyAR4JdPnZE4oZ6VhsZg2eDSH7aRqCaxCbL86DuP6LI+TvES+S+ZRH9wBMef7s QYqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680883291; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ArkFzgGmWr5GIWIb5S26dnAG6/MRvelBkLMc+Gk1DCI=; b=hhCmgYdvQpurXgXQWuClqHuR/P3LRoXKpjIkO5MmqhjV4Lq5MS0JK/yhtiHINc+pWV 4EqsTuQYuApKXMVbjy8WNvmjHKAPi2R5naUslMSR/unPbfqVXq6TopX9W8ySt2DwKE6D fOsbtXSYAUjF+OLzt9p4P/XKARp2YxntsbZEbxrYrXUHQCankNkbAGCLl2trcAeuAdA9 7ciPR2cJO4YW1eA1F6dn1xVBGN7g+IbnxIBtlzTcOHfipYcbJmt+0ttxrUSRFISXZ6Ny /w3t/+tTuGBSkezRUEEZATovevNOrlAEfNINUO9xf5Pz0cNPihTQ/nsLcs0XqF25m/ZT ofVg== X-Gm-Message-State: AAQBX9cUF1PU0bPIoVamjkAb6ExSkAtsVgX1jpDTU0RnpZAe522Hy4/Y k3FIERq+hmEOAumSH7CKGk2sESsBzDE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:cf90:b0:244:a6e7:bb6c with SMTP id i16-20020a17090acf9000b00244a6e7bb6cmr760824pju.8.1680883291507; Fri, 07 Apr 2023 09:01:31 -0700 (PDT) Date: Fri, 7 Apr 2023 09:01:29 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230407093147.3646597-1-kconsul@linux.vnet.ibm.com> Message-ID: Subject: Re: [PATCH] KVM: PPC: BOOK3S: book3s_hv_nested.c: improve branch prediction for k.alloc From: Sean Christopherson To: Bagas Sanjaya Cc: Kautuk Consul , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Fabiano Rosas , Paolo Bonzini , Chao Peng , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 07, 2023, Bagas Sanjaya wrote: > On Fri, Apr 07, 2023 at 05:31:47AM -0400, Kautuk Consul wrote: > > I used the unlikely() macro on the return values of the k.alloc > > calls and found that it changes the code generation a bit. > > Optimize all return paths of k.alloc calls by improving > > branch prediction on return value of k.alloc. Nit, this is improving code generation, not branch prediction. > What about below? > > "Improve branch prediction on kmalloc() and kzalloc() call by using > unlikely() macro to optimize their return paths." Another nit, using unlikely() doesn't necessarily provide a measurable optimization. As above, it does often improve code generation for the happy path, but that doesn't always equate to improved performance, e.g. if the CPU can easily predict the branch and/or there is no impact on the cache footprint.