Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp856628iob; Thu, 12 May 2022 06:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa2wT/KoBRWphCIeHFGGp4G+q1P4LV0slkqTlK3bwF4DgsH+cpOVBqZJKBuSkK/l5ipVpd X-Received: by 2002:a05:6a00:150d:b0:510:3a9c:3eed with SMTP id q13-20020a056a00150d00b005103a9c3eedmr30164856pfu.86.1652361189965; Thu, 12 May 2022 06:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652361189; cv=none; d=google.com; s=arc-20160816; b=txHuEOFeB2lUvVmX3qb5EJpfBUrjqyGX9e2owRVu62h6m8saomXXJXd48hfSyX+pFj nMjrE7OjZCSgV90pfefW3DhyJpgOv21ivQbvzucUDc1lVZm9hzinyWYOAi9UdJxxyOO6 6IbaxOxkBJIo/yOA4ZPpkUSzLpnuzwu5GO34A6IomKkUDx6o4aE3piFztrCjGLb8/Htn JvQe03C9HZCpmXhtec/32Om5JgqbC5YxlolS9kQMgAevGsNV/OIdzIKV2p/bsUO3O/5U X0BU4VTqpqdifLLd7d+7RXlHRCBY0lAEAbKLQVjkI1Zl+RnMZjWdP9h6HG787lm8mlas d2pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=WLnxNXBtTu1Xj6SCyZs9UE6ChpjVOlBqg8mKHMNVhx4=; b=HoNCc/OWegiCIfw/ltBNjhDe8/5F6krcdnNARwHWWpu4t5UCA0gqLjU5aEJtX7hCSM imYGxk6pgXLj9+PX5bXjvdvnO6Eq+6OK/p0blCh6MRzsQqAJA06KrE5QBDlKBIyjlAva MS0UPptXczLXqb+zR4a0YkeJkDg9JinLUqMDh2/BCPfMwx2OuxhvvMhmiuA3LrEKk7nI wDCo2bMEhnJFh6mbNHBCo5FxJabLytugn5fblAMOhnS8nnfBgjB+ob6YlkXLxc7P3Hus q/8UbnY0plXCCk9pBe01QI/y5fyX0VZYVePzKA5Q9SY+I/u1mS2UfmpXvUhESP6jj/5B 0p0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020a635117000000b003a9eb7eab56si3171757pgb.350.2022.05.12.06.12.57; Thu, 12 May 2022 06:13:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346487AbiEKU4g (ORCPT + 99 others); Wed, 11 May 2022 16:56:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232482AbiEKU4e (ORCPT ); Wed, 11 May 2022 16:56:34 -0400 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1BA42AC5D for ; Wed, 11 May 2022 13:56:32 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id otNXnkMYfWqfTotNYnPGX7; Wed, 11 May 2022 22:56:30 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 11 May 2022 22:56:30 +0200 X-ME-IP: 86.243.180.246 Message-ID: <324f245e-15e2-a1f2-bc8a-46255a1a859f@wanadoo.fr> Date: Wed, 11 May 2022 22:56:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2 1/2] x86/asm/bitops: ffs: use __builtin_ffs to evaluate constant expressions Content-Language: en-US To: Vincent Mailhol , Nick Desaulniers , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Nathan Chancellor , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, David Howells , Jan Beulich References: <20220511160319.1045812-1-mailhol.vincent@wanadoo.fr> <20220511160319.1045812-2-mailhol.vincent@wanadoo.fr> From: Christophe JAILLET In-Reply-To: <20220511160319.1045812-2-mailhol.vincent@wanadoo.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Le 11/05/2022 à 18:03, Vincent Mailhol a écrit : > For x86_64, the current ffs() implementation does not produce > optimized code when called with a constant expression. On the > contrary, the __builtin_ffs() function of both GCC and clang is able > to simplify the expression into a single instruction. > [...] > > ** Statistics ** > > On a allyesconfig, before applying this patch...: > > | $ objdump -d vmlinux.o | grep bsf | wc -l > | 3607 > > ...and after: > > | $ objdump -d vmlinux.o | grep bsf | wc -l > | 792 > > So, roughly 26.7% of the call to ffs() were using constant expression > and were optimized out. > > nitpicking: numbers look odd. 3607 is the exact same number as in patch 2/2. (ok, could be) 26.7% is surprising with these numbers. (I guess it is (total_before - remaining) / total_before x 100 = (3607-792)/36.07 = 78.0%) (but patch looks great to me :) CJ