Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5722892rwp; Mon, 17 Jul 2023 08:31:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlFDGTxQi1BpSOz0a/6/n2Bq8XSEpeldxaza2F/hKBkvTK0YnvjJZgFHjUErGX8BAbRJ3Dil X-Received: by 2002:a17:906:2d3:b0:997:865a:77e3 with SMTP id 19-20020a17090602d300b00997865a77e3mr5946533ejk.11.1689607872333; Mon, 17 Jul 2023 08:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689607872; cv=none; d=google.com; s=arc-20160816; b=X+cNn8o66QqcGba7FuP5yLk9GpeeyIE3c8XeKfMrr1VAG9xtpNUJSciDuquh7NuW6V tZhEv4Kok2uJ5cD75/iGZFWAbIT0XABXN3PSGgogjB1O0Sg6No6y5fKIuBCY3DYsJ3Q9 2rdyx8uU04NSRthR1CxZhzGGo1ltYkkQ7m9RywY5Us32696czJwWXOoGniMvtB1kxtB9 wTUTQqTKPT+YxCkz2w4eyvSINYTErcdJZMcKDyeUwEzJUpwgyfDphphtQIQPwY5mTtld fqx4qW29KSwDiCE236e22HoVuR/8A7SFrp7ZZsz+0t6NflTzbVOwCoxXBTHPkCCxDQpv W+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=4N+VB2O19PgaLk4/fI6QWYmgj3TbzVFJ1VSUUXkTNes=; fh=1+H30W3wK239d8P5nJGgkz/2eLsOohNSK0/IfCLdt0Y=; b=PRGx4ZlS4tnzCN/FVSpMK/jJG8loeP3+qjsRRa6YGJqP2zzTWS2fKC3nwpeowYItf6 05fs/nxc/IrUfQf0lICLKBCah4Jf02aJ41fmyHNVAhHZ5iAqmqLwCeeEiJG3k+eCNpoB sjCOkQ7WU3pYYz27CIFgwQiw43LfgcU3SV4i0dlEYZCDY2fjWjk81+3VrSM7sVaMyKGs l1lrR8k6iy8dSmaM7mkQOCU8wKeNxkfO+8UlQVN5F677Ph/H+oqUnordNejDBFyOjtci jJja4TO9rAD/wV7iO9q3pW66YVpDAO/IXzxVTGQIn5A0tFCX8bbgLvmcwhpTxNr2XeVX +udQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Izmrrjzf; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a1709064ec900b00988ce522544si13800929ejv.753.2023.07.17.08.30.46; Mon, 17 Jul 2023 08:31:12 -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=@intel.com header.s=Intel header.b=Izmrrjzf; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbjGQPDm (ORCPT + 99 others); Mon, 17 Jul 2023 11:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbjGQPDl (ORCPT ); Mon, 17 Jul 2023 11:03:41 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9715B9 for ; Mon, 17 Jul 2023 08:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689606219; x=1721142219; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=zDv2lDctT5fbcckIC6WwWPCqBgFU1iff9oIJZnsJfSc=; b=IzmrrjzfMLUEzAf/Jl7IHpVGaWMb042XuY0CpH8w5RSzsFYDJF7ZHwkY BLdyi7tZj+JQGDkSU1EwppmUD24nyHvpUXW2trhuC2gKexvW3wm95Qc3m 2SqIZ1+THA//TLitwsLWNglM0/HWcCm2qxdOCV9UbvI2zXp71ch2arDPJ bJNB14BEr9iIzLbH+Iv+mV7PSov3BvS/qYFjB/+rrtgTLUgRBMaczvSE4 fVmktyPbPK74BW8IN/NTOaO8Vo9Q41xK/RM+BS2HvrnOBU9h+0NFO7lnF xQ5rSEbvU1bKGVTm9zfFTWRjlXMTSyALkAR4K/gabuGwb5ANZoNfWm7o7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="363415142" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="363415142" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:03:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="1053927770" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="1053927770" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga005.fm.intel.com with ESMTP; 17 Jul 2023 08:03:34 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qLPl6-001zWM-29; Mon, 17 Jul 2023 18:03:32 +0300 Date: Mon, 17 Jul 2023 18:03:32 +0300 From: Andy Shevchenko To: Alexander Potapenko Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com, syednwaris@gmail.com, william.gray@linaro.org, Arnd Bergmann Subject: Re: [PATCH v3 1/5] lib/bitmap: add bitmap_{set,get}_value() Message-ID: References: <20230717113709.328671-1-glider@google.com> <20230717113709.328671-2-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 On Mon, Jul 17, 2023 at 04:53:51PM +0200, Alexander Potapenko wrote: ... > > > I remember that this construction may bring horrible code on some architectures > > > with some version(s) of the compiler (*). > > > > Wow, even the trunk Clang and GCC seem to generate better code for > > your version of this line: https://godbolt.org/z/36Kqxhe6j > > Oh wait. > First, my Godbolt reproducer is incorrect, it is using sizeof(unsigned > long) instead of 8 * sizeof(unsigned long) for BITS_PER_LONG. Still slightly better. And note, that the same GENMASK() is used at the beginning of the function. Compiler actually might cache it. > > > To fix that I found an easy refactoring: > > > > > > map[index] &= ~(GENMASK(nbits, 0) << offset)); > > > > > Second, the line above should probably be: > map[index] &= ~(GENMASK(nbits - 1, 0) << offset)); > > , right? Yes. -- With Best Regards, Andy Shevchenko