Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1417456ybg; Wed, 29 Jul 2020 13:45:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyO1ibh3vMsRlZEwc1VvrBk4O/hjqW8RDFTy5R8+8dcFZ8XZiE60jQBunKfWO0rAHexK0H5 X-Received: by 2002:a17:907:72c6:: with SMTP id du6mr163111ejc.362.1596055521735; Wed, 29 Jul 2020 13:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596055521; cv=none; d=google.com; s=arc-20160816; b=HdGlskM1ulr5vHI4HxNIkw0M0OOhNMvgHHomVc/zWUSI/aR46hGcyJwWUOIitt/iA5 1PWzvC/YmHnzBWUnkdjTg374S0FVmfOZFLPcBhaTdK5QpZ/Aqi+KreDkGI4dYzcH1j/q LNeNjLhFGDMLhPZhrkbYdOJpp88IHR53XPn6XtwY+vQ7ygcdZdI6gxxPKjhEWh4S/Sdt MYtGCoI6nVwUrlncKkIYRu7ADLZSM49YhcZ7D3qklREDA62ncisOgzv0v5z22UQwLRbq 3/aWpXzkf3GIHSMR2YSGCBibW8+MH+T9DWkb0In/D3CtS1oU3n62indm2rRwcBxCo9DN x7dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=TMQfL+R8ZHSE3pjcAz5mihC5M1SAcY+pChIbaXML2FE=; b=GrPBo0Mba71byDo1cp/EOCjG3D/64edWQgVV1ugw/wd2Et63yRxdzibIKxF9z78cGc JHeuYnEJfFRyZHqQrb43wnSfLy0Pzn+CCTwjg2rfzRprNMWfET2fAOU/kAjqw+G3vSYx BMM6RaAmUzp018Z84o2+W2fpx7/O1PY/1VZW1UQhahV8QnIApSndFalI/FfsfWmxlBnN ufar4Xq+dlKFknQgU5cnQgG8uiWJI/eAY66jW45zl/cA1G9DWQmjlyvN6EWlEbqBZCaV FvFvGNnw9dAc0YdC4xpbIeQPAHO05HlI1osUIIhU01EcejDjGLkH6wxiLyixMQ0//kRR amcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0g8GExDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si1750118ejf.83.2020.07.29.13.44.59; Wed, 29 Jul 2020 13:45:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0g8GExDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726933AbgG2UoM (ORCPT + 99 others); Wed, 29 Jul 2020 16:44:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:59844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgG2UoM (ORCPT ); Wed, 29 Jul 2020 16:44:12 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D67B12068F; Wed, 29 Jul 2020 20:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596055452; bh=qLclcthyaIVq9FHNhNz4KHXGIpoZhJNR9DipamyBoKA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=0g8GExDae9GS3BIIs6kvFVJgTAVyo+67M9muKbxaUqwvLHI9Tre4FMpm1NFb35TKR YMHzBO380YchTaVZtXt0Y+s2nysOI83rUzggkpTFQCHb6x8RtNXXGoMwluFsi7uJVT YDA+HE5ppQfwDSM2HjKdd3GxYTqW6ZPO1prAwg8c= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 4546340E6B; Wed, 29 Jul 2020 17:44:09 -0300 (-03) Date: Wed, 29 Jul 2020 17:44:09 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Andi Kleen , linux-kernel@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH] perf bench: Add benchmark of find_next_bit Message-ID: <20200729204409.GF433799@kernel.org> References: <20200724071959.3110510-1-irogers@google.com> <20200728115152.GB3328@kernel.org> <20200729195918.GE433799@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200729195918.GE433799@kernel.org> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Jul 29, 2020 at 04:59:18PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Tue, Jul 28, 2020 at 08:51:52AM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Fri, Jul 24, 2020 at 12:19:59AM -0700, Ian Rogers escreveu: > > > for_each_set_bit, or similar functions like for_each_cpu, may be hot > > > within the kernel. If many bits were set then one could imagine on > > > Intel a "bt" instruction with every bit may be faster than the function > > > call and word length find_next_bit logic. Add a benchmark to measure > > > this. > > > > Thanks, applied. > > > This benchmark on AMD rome and Intel skylakex shows "bt" is not a good > > > option except for very small bitmaps. > > > > +++ b/tools/perf/bench/find-bit-bench.c > > > > +#if defined(__i386__) || defined(__x86_64__) > > > +static bool asm_test_bit(long nr, const unsigned long *addr) > > > +{ > > > + bool oldbit; > > > + > > > + asm volatile("bt %2,%1" > > > + : "=@ccc" (oldbit) > > > + : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory"); > > > + > > > + return oldbit; > > Some old clang versions are not liking this: Failed with: clang version 3.8.0 (tags/RELEASE_380/final) clang version 3.8.1 (tags/RELEASE_381/final) clang version 4.0.0 (tags/RELEASE_400/final) Alpine clang version 8.0.0 (tags/RELEASE_800/final) (based on LLVM 8.0.0) Alpine clang version 5.0.0 (tags/RELEASE_500/final) (based on LLVM 5.0.0) Alpine clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1) Alpine clang version 5.0.1 (tags/RELEASE_502/final) (based on LLVM 5.0.1) Worked with: Alpine clang version 9.0.0 (https://git.alpinelinux.org/aports f7f0d2c2b8bcd6a5843401a9a702029556492689) (based on LLVM 9.0.0) Alpine clang version 10.0.0 (https://gitlab.alpinelinux.org/alpine/aports.git 7445adce501f8473efdb93b17b5eaf2f1445ed4c) Alpine clang version 10.0.0 (git://git.alpinelinux.org/aports 7445adce501f8473efdb93b17b5eaf2f1445ed4c) Also failed for; # grep FAIL dm.log/summary | grep -v alpine alt:p8: FAIL clang version 3.8.0 (tags/RELEASE_380/final) alt:p9: FAIL clang version 7.0.1 amazonlinux:1: FAIL clang version 3.6.2 (tags/RELEASE_362/final) amazonlinux:2: FAIL clang version 7.0.1 (Amazon Linux 2 7.0.1-1.amzn2.0.2) #