Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1392229ybg; Wed, 29 Jul 2020 13:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOMC2ehaETCBcJCPnBRblcBYAbGzy+v9YKTXFY4MaExR2FMe6qyZ0McD7RH5K89zBqBDaD X-Received: by 2002:a05:6402:1358:: with SMTP id y24mr922edw.318.1596052854269; Wed, 29 Jul 2020 13:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596052854; cv=none; d=google.com; s=arc-20160816; b=RU6b6Nj4I6kn1et/LF7IS37WRe48zx3zgWYfMmJ6ilpn3iLSbO1Q9hMvEWw0elxgOm VHvvN6DAl/uVlIinZ93je+xu3rBkh/JT3zHhRWILQh6kJ3857GB0+3mRDoQ/WCod4zUx r3OsIOxekI92acDIR2TpXk2slqoU3VobYoJyYungwT8Ha0bcfz87gQKuCN2TF5nrx0+P ds5/oSnBY48wiCg4cNSGeJeypD3A62dTF4PnG/NWnoGWyM/3BUplvc6N1y/R2+fhqZIH cza7nm/N1b1C9hIEPCg8ijpvY07u3O5qeWeeFxAjxAONIUUaKdKWCW7rqqWHrQIKHjBL M8hw== 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=3tZD9YPzJwQjLC4/gtoVt6tnxbw01JGpxf0vWnU954A=; b=c0ShNw66Z5BPLVPVcTqBjYsnxf/hp+HGjDgOmfkVQrbABIQpaRL0ANzbIb5ONIMxqv 7lbjZQX6cCa3Ak4fhmSs5xFdeF7W+zAxafd7NGT/C5DHmHVcI3jyU0+Fl+oxIhuHsuYr FV6WjrHeR9W670yDnySjoLU2ME5D+hNihhQU+zbKyKSvOfpcCQy/Alz7PMW92DVJDlp7 MmnM0yejJFR7wQRztTQmOgvuISfSIOWc53alCG2SzGyDRvTCaTz15d8uWfV73y6TS4t7 PFVrGmMQi2KFHhGuTF2nFjRMnbsxV+X/jO/Z3vJP/RYMDJFq44W6g1Fxd9Ax/auSUku3 F9xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eu5z6okq; 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 e10si1961137edy.274.2020.07.29.13.00.31; Wed, 29 Jul 2020 13:00:54 -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=eu5z6okq; 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 S1726650AbgG2T7U (ORCPT + 99 others); Wed, 29 Jul 2020 15:59:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:44092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbgG2T7U (ORCPT ); Wed, 29 Jul 2020 15:59:20 -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 DEEB520658; Wed, 29 Jul 2020 19:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596052760; bh=BNXktmbwVk5D9L+Ni47QkQesqnGuRuU7dGbygDQCcrk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eu5z6okqzB/oCiK3RUvV2s93bzvSawGJ8g3CmznI7JZO0f2ZcKBf+eVwlCrucRnqv m1V6xgpihgmJsFuWTrhcOuaM/T58aZ3RAxoXfKSogC0QwDTX6P6fQwhdNEN0OslJlM 4l7ZwqdMbLfrhlzsVpWfu3Tr45vEPRjWBN2EyhEQ= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 0E7B840E6B; Wed, 29 Jul 2020 16:59:18 -0300 (-03) Date: Wed, 29 Jul 2020 16:59:18 -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: <20200729195918.GE433799@kernel.org> References: <20200724071959.3110510-1-irogers@google.com> <20200728115152.GB3328@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200728115152.GB3328@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 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. > > - Arnaldo > > > 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: clang version 3.8.0 (tags/RELEASE_380/final) Target: x86_64-alpine-linux-musl Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/5.3.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 + make ARCH= CROSS_COMPILE= EXTRA_CFLAGS= -C /git/linux/tools/perf O=/tmp/build/perf CC=clang CC /tmp/build/perf/trace/beauty/pkey_alloc.o CC /tmp/build/perf/tests/openat-syscall-tp-fields.o bench/find-bit-bench.c:46:10: error: invalid output constraint '=@ccc' in asm : "=@ccc" (oldbit) ^ 1 error generated. mv: can't rename '/tmp/build/perf/bench/.find-bit-bench.o.tmp': No such file or directory /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/bench/find-bit-bench.o' failed make[4]: *** [/tmp/build/perf/bench/find-bit-bench.o] Error 1 /git/linux/tools/build/Makefile.build:139: recipe for target 'bench' failed make[3]: *** [bench] Error 2 make[3]: *** Waiting for unfinished jobs.... MKDIR /tmp/build/perf/arch/x86/tests/ Also: clang version 3.8.1 (tags/RELEASE_381/final) clang version 4.0.0 (tags/RELEASE_400/final) - Arnaldo