Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2905177pxu; Mon, 7 Dec 2020 20:42:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8Uo89f+nMtJU+UH5a1nvyX0yjzANSRNkDW1UcToe5Zav513xlboHhuhabknMHe5K/7pGQ X-Received: by 2002:a17:907:94c6:: with SMTP id dn6mr21880341ejc.13.1607402529798; Mon, 07 Dec 2020 20:42:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607402529; cv=none; d=google.com; s=arc-20160816; b=b4N/j5ecmgdgKhq5SmVfY4PEHtUmfRd0ENjPOQCerZg9VF+feDuEp3KRLnDgGz7A1h u1XaJrQPPbGv5PeLIX7NdKX1Vhv9WzE5uTJbAJVn7G8XbAzKbqRk3dDLmK6OkOgxKu69 lQB8Z8MSgNkXgb65/yLO7iK3m59dWoqPogkftBINbiLfcYwi2UDTQqIb6BfV2TPT5pW2 3T54hTsQwgoPqg3HZUabeu1oLzBC5Z6oD4AT60QdqNSlOu244x//BGhyNUDOZfsVn3N9 9+btlQjR63nwmC/M8Er8DI9xzGUHyVfRmJ++WoJYCKgwPU2rNAgcyu1xgIYiNPGO5cMa dOTA== 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=4d/TF5gux6apsclckzpVTNaKxAFLEA9dis+4frk1pq8=; b=0ebv5YGAGFSEvubT4fkH77D+6fe6s2G6zJsrs0SAFjMGopc4KFek1G9AGGUPlgHNwN o+D+w8dlufCcDzEbSkErNhaoVe3W+rPnmRc6S8Uz9UOVQXM3vl0md85NuVmWKx0rC4T+ /lHLezxs9qSyfydYKd7zOl0YHdPzKqmhAzVRrjtghVqttsGRkTQDXTySABUp/xi1yTQh 73Ya2+h3Ze+yQRuChBjl6uU3bqAMskZX+aHkc3kZf0NmAPDB8uX/EsPfE2ZLv2uNJ2xe mQweieYjh6IaLR6ITCu/BEkGZQAbwndoaWhaqBlzewayjaA2KpEHwhzWKKD4uml3JBPy RSOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lp3xZOvn; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt24si7860834ejb.248.2020.12.07.20.41.47; Mon, 07 Dec 2020 20:42:09 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Lp3xZOvn; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbgLHCAJ (ORCPT + 99 others); Mon, 7 Dec 2020 21:00:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbgLHCAJ (ORCPT ); Mon, 7 Dec 2020 21:00:09 -0500 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C6BC0613D6; Mon, 7 Dec 2020 17:59:28 -0800 (PST) Received: by mail-il1-x143.google.com with SMTP id 2so11040642ilg.9; Mon, 07 Dec 2020 17:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4d/TF5gux6apsclckzpVTNaKxAFLEA9dis+4frk1pq8=; b=Lp3xZOvnU90orEelwO5jiL8/6ZcLYxUY5HmTT0MabClYEMaThhrQT0PUIUzNC3Ntef XpSh3JHDvN9nJHkxpu0CSw6yq/E/JVpEfEyjHVIoUiuduwri5B9ERA4ItuBmHR5JPojZ tiSn9N5+lYcDrF16JgX4M7f4LTvCmA5CMefNcclMS0sUEJCOop6A2rb62mK89Zi64mDt BlQFOnuebuUa1m/U8JtQkBYG/AdE7lrtHV4PcnRdWO7USgeS+Y9q3in+8kreBoOGBINS kdoX4B17Ku6ATHnPwN0FCNw57rt6aXb8UpCMdCvTeI2CuIwC9225T01WBNGrtFtXs70W WSQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4d/TF5gux6apsclckzpVTNaKxAFLEA9dis+4frk1pq8=; b=bSWxDb36LVY28Xik8KjbtJRZ4GGtYIA+iBjEUKRYUIA6ox5M6+pWC1LEwNluQRejND luaYBf78G0H96Co4ctkfHUaW0M6K3Y1VwPbd3etLFekRP+R67aFy8oDgNqmoNxrBgdZX uk2l21ZyrE3puhVcL0o3EWCcuyEzT61KdxRiAPAAZQqOM/eyOzQcupkuxR02QKebfiwQ rmIgFkUgJzkqL3oGJSC+PQU1vCvjvE0XUzyHhd4tA8Gn7E90KddUxj1RPuApliluH+F4 RHLlw0XZTnQd7xidMQY+fTa1bzAsvOwhVNsNhvLMLJF8azjbXvF8InIhCU0kOejNeXAS Gm1w== X-Gm-Message-State: AOAM530DS1Z22Jj7fcWhghaAqyD8BnKybAc9YnrUuhXdb91J1iy24tYJ tBlnul0odflRI+Yf6QRA5tWQpQBCVf80J6m4ZGs= X-Received: by 2002:a92:9881:: with SMTP id a1mr24994868ill.238.1607392768219; Mon, 07 Dec 2020 17:59:28 -0800 (PST) MIME-Version: 1.0 References: <20201205165406.108990-1-yury.norov@gmail.com> <20201207112530.GB4379@willie-the-truck> In-Reply-To: <20201207112530.GB4379@willie-the-truck> From: Yury Norov Date: Mon, 7 Dec 2020 17:59:16 -0800 Message-ID: Subject: Re: [PATCH] arm64: enable GENERIC_FIND_FIRST_BIT To: Will Deacon Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , linux-arch@vger.kernel.org, Alexey Klimov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (CC: Alexey Klimov) On Mon, Dec 7, 2020 at 3:25 AM Will Deacon wrote: > > On Sat, Dec 05, 2020 at 08:54:06AM -0800, Yury Norov wrote: > > ARM64 doesn't implement find_first_{zero}_bit in arch code and doesn't > > enable it in config. It leads to using find_next_bit() which is less > > efficient: > > [...] > > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index 1515f6f153a0..2b90ef1f548e 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -106,6 +106,7 @@ config ARM64 > > select GENERIC_CPU_AUTOPROBE > > select GENERIC_CPU_VULNERABILITIES > > select GENERIC_EARLY_IOREMAP > > + select GENERIC_FIND_FIRST_BIT > > Does this actually make any measurable difference? The disassembly with > or without this is _very_ similar for me (clang 11). > > Will On A-53 find_first_bit() is almost twice faster than find_next_bit(), according to lib/find_bit_benchmark. (Thanks to Alexey for testing.) Yury --- Tested-by: Alexey Klimov Start testing find_bit() with random-filled bitmap [7126084.864616] find_next_bit: 9653351 ns, 164280 iterations [7126084.881146] find_next_zero_bit: 9591974 ns, 163401 iterations [7126084.893859] find_last_bit: 5778627 ns, 164280 iterations [7126084.948181] find_first_bit: 47389224 ns, 16357 iterations [7126084.958975] find_next_and_bit: 3875849 ns, 73487 iterations [7126084.965884] Start testing find_bit() with sparse bitmap [7126084.973474] find_next_bit: 109879 ns, 655 iterations [7126084.999365] find_next_zero_bit: 18968440 ns, 327026 iterations [7126085.006351] find_last_bit: 80503 ns, 655 iterations [7126085.032315] find_first_bit: 19048193 ns, 655 iterations [7126085.039303] find_next_and_bit: 82628 ns, 1 iterations with enabled GENERIC_FIND_FIRST_BIT: Start testing find_bit() with random-filled bitmap [ 84.095335] find_next_bit: 9600970 ns, 163770 iterations [ 84.111695] find_next_zero_bit: 9613137 ns, 163911 iterations [ 84.124143] find_last_bit: 5713907 ns, 163770 iterations [ 84.158068] find_first_bit: 27193319 ns, 16406 iterations [ 84.168663] find_next_and_bit: 3863814 ns, 73671 iterations [ 84.175392] Start testing find_bit() with sparse bitmap [ 84.182660] find_next_bit: 112334 ns, 656 iterations [ 84.208375] find_next_zero_bit: 18976981 ns, 327025 iterations [ 84.215184] find_last_bit: 79584 ns, 656 iterations [ 84.233005] find_first_bit: 11082437 ns, 656 iterations [ 84.239821] find_next_and_bit: 82209 ns, 1 iterations root@pine:~# cpupower -c all frequency-info | grep asserted current CPU frequency: 648 MHz (asserted by call to hardware) current CPU frequency: 648 MHz (asserted by call to hardware) current CPU frequency: 648 MHz (asserted by call to hardware) current CPU frequency: 648 MHz (asserted by call to hardware) root@pine:~# lscpu Architecture: aarch64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 Vendor ID: ARM Model: 4 Model name: Cortex-A53 Stepping: r0p4 CPU max MHz: 1152.0000 CPU min MHz: 648.0000 BogoMIPS: 48.00 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Spec store bypass: Not affected Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid