Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1017116rwe; Thu, 1 Sep 2022 11:04:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7op2mhqB9yZJJMeu9jEo8ON8EISuK9+p0wFkNH2zAxKRxq3mgJz1JLAGWiUrKENGgKdgip X-Received: by 2002:a17:906:cc15:b0:73d:d87f:f039 with SMTP id ml21-20020a170906cc1500b0073dd87ff039mr22718499ejb.253.1662055476175; Thu, 01 Sep 2022 11:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662055476; cv=none; d=google.com; s=arc-20160816; b=GHP/QnO6B6JyYfwPaq/RQJZPcuUDCAFpAX9sNDEdd+qk6pc6lNq22bl2XmYvLcONqE vLZUcs9HPwZuI+IPdk2qv0QAez6tiVikvNMmXcnUdVc2Jo0zTGOhFXVcBqDrX5s33eUY CMA3pp8WD9x0oPdtf6z2DKnNb6+S1iPqrRIjHgKDSxhzaKQM/05owF8cXOGEfOhfxgS9 JHCFFPV+H3OFXznuiYrdV0tjguZpJNloSJRQ2+LzpqBkVRZU7za+Z12RbjoI8SOWX0vQ 112FzJ7Z2be/EqsFH77AgeSE6rXWwSGxIG9Urzn3OpQw5k1dlYbMMQjxRrh3cMMCmTR/ 2EgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fA4MAzocVYnZA2PNv0a79ePFGBimCCBV9TwhybPc+1g=; b=NHWwFBDWFcjsDv1H1D+5GBB2oZbu2xV57KMvhgnWnJeUrBNpX0YUeJonltMi5j8uRE YF9pvxK/KRA5AadEa5SoajMxE9hS/0O0EsJRm9gd0tFH0cRh3QOoULtLvh2zE+LwMCuE fv4torfi42t3vwdLrNvnEocdtsGDBmOQkAbLQlKsaA2i1pggGLlfJ7siIlecCi0OZbjs qveo307atH0GLRzBEVNevgqLlRGlutz6J7+DLc+CUlhj/1QHZHbMotWMg3muBsYmcUt+ m1XGKZbYgf/vYBUQHYLw/0uhuYj55Nic4lAhMGj0MeqQI5BM07vwWOsbTSnFMtl4V5Z5 yR8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gaNyFVJI; 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 z14-20020a05640235ce00b0043be6506057si2125816edc.182.2022.09.01.11.03.47; Thu, 01 Sep 2022 11:04:36 -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=gaNyFVJI; 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 S233441AbiIARHG (ORCPT + 99 others); Thu, 1 Sep 2022 13:07:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235085AbiIARHD (ORCPT ); Thu, 1 Sep 2022 13:07:03 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86127F245 for ; Thu, 1 Sep 2022 10:07:01 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id n17so23206448wrm.4 for ; Thu, 01 Sep 2022 10:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=fA4MAzocVYnZA2PNv0a79ePFGBimCCBV9TwhybPc+1g=; b=gaNyFVJIAWi6NladXb1I0D9sKA1wYJuqwzT3vMPSeWijxpfGD7ju8E/Y3qpCZH+5z5 I5clrbyXneyIbY7yxT2NhXaPYKkI8zIbnuijIbHVkg1GygW6FAX3jkEs46hrEWyloeD6 NH+rPwNIi+1P/9amACHfAZSkG+wBIYJpRqYb9fJbKc75Jk/B0VuiZgRH08uClKGcmEDK yiN/O23Z1sZqKpASU54QXDdZx8fOkg1GrSYPxx29wANWc/x1uDFbSOc/aaxSQ4fUb53m uB/IGAAF3ZJVI0EUsjQJV71kT+kkLX9QRBd1LlSPY44Ry6Ege4IDk4UMvIQeu5Vl9wPl LiSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=fA4MAzocVYnZA2PNv0a79ePFGBimCCBV9TwhybPc+1g=; b=MrW3cNWlwxqtXdLYprfg+ZoUVfOcwMPvpIVibXIDv104kWEXpso2XLOzamgBU5jOev xmw30bynla3xO/umdF+2jpJvl+KzOLNm5mPDIq717wn8YXwl5K+41aW5/bqMMSed8Ato pwTdiFWwiHzvvsO725fXkTxKXLQ0kmpTRObzbKOagQNyI5vKJGhXUWVmD8zrz4J9GGmY bKsVUAFQM2J9p5SGMzls4t/6cix6uJoAEs2mzcSm1kJyWFFcE1+NWTDyASjOLrGOeJMm fa5On+0VFSitMt+twVPZ5Yzi5xyj5etn6wg6t6zRburJ4hvjsuUddYIzLGbvRagsjUus WuSw== X-Gm-Message-State: ACgBeo1pk0/7Khv+qH9mWQFTMhZn7ZxCyvjSld3hB7O2egVYOEGqmRyL z7aN5Dp0fqkj8pKV+XEiXQRU5MZJZBMODn/1G5/u4Q== X-Received: by 2002:a5d:47ac:0:b0:226:df12:412f with SMTP id 12-20020a5d47ac000000b00226df12412fmr10609969wrb.675.1662052020147; Thu, 01 Sep 2022 10:07:00 -0700 (PDT) MIME-Version: 1.0 References: <20220511160319.1045812-1-mailhol.vincent@wanadoo.fr> <20220831075742.295-1-mailhol.vincent@wanadoo.fr> In-Reply-To: From: Nick Desaulniers Date: Thu, 1 Sep 2022 10:06:48 -0700 Message-ID: Subject: Re: [PATCH v6 0/2] x86/asm/bitops: optimize ff{s,z} functions for constant expressions To: Yury Norov Cc: Vincent MAILHOL , Borislav Petkov , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Peter Zijlstra , Dave Hansen , "H . Peter Anvin" , Nathan Chancellor , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, David Howells , Jan Beulich , Christophe Jaillet , Joe Perches , Josh Poimboeuf Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Thu, Sep 1, 2022 at 7:19 AM Yury Norov wrote: > > On Thu, Sep 01, 2022 at 07:30:10PM +0900, Vincent MAILHOL wrote: > > On Tue. 1 sept. 2022 at 12:49, Yury Norov wrote: > > > On Wed, Aug 31, 2022 at 01:54:01AM -0700, Yury Norov wrote: > > > > On Wed, Aug 31, 2022 at 04:57:40PM +0900, Vincent Mailhol wrote: > > > > > The compilers provide some builtin expression equivalent to the ffs(), > > > > > __ffs() and ffz() functions of the kernel. The kernel uses optimized > > > > > assembly which produces better code than the builtin > > > > > functions. However, such assembly code can not be folded when used > > > > > with constant expressions. > > > > > > > > > > This series relies on __builtin_constant_p to select the optimal solution: > > > > > > > > > > * use kernel assembly for non constant expressions > > > > > > > > > > * use compiler's __builtin function for constant expressions. > > > > > > > > > > > > > > > ** Statistics ** > > > > > > > > > > Patch 1/2 optimizes 26.7% of ffs() calls and patch 2/2 optimizes 27.9% > > > > > of __ffs() and ffz() calls (details of the calculation in each patch). > > > > > > > > Hi Vincent, > > > > > > > > Can you please add a test for this? We've recently added a very similar > > > > test_bitmap_const_eval() in lib/test_bitmap.c. > > > > > > > > dc34d5036692c ("lib: test_bitmap: add compile-time optimization/evaluations > > > > assertions") > > > > > > > > Would be nice to have something like this for ffs() and ffz() in > > > > lib/test_bitops.c. > > > > > > > > Please keep me in loop in case of new versions. > > > > Hi Yury, > > > > My patch only takes care of the x86 architecture. > > OK, I just realized that you started submitting this at least back in May. > > For me, v6 is good enough and well-described. So, for the series: > Reviewed-by: Yury Norov > > How are you going to merge it? If you haven't a specific tree in mind > already, I can take it in my bitmap tree because ffs and ffz are closely > related to find_bit() functions. Unless Boris feels strong enough to nack the series, I think Yury accepting the series is the way to go. -- Thanks, ~Nick Desaulniers