Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1645360rdb; Wed, 20 Sep 2023 15:35:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMlRGCcrbvq0qtPhsUswXUGX6thF4ELbphhgROcVczx+bjL8wGtI/iTKBc3Sl8IiEo6J9j X-Received: by 2002:a05:6808:1820:b0:3a8:43d5:878b with SMTP id bh32-20020a056808182000b003a843d5878bmr4228340oib.2.1695249324892; Wed, 20 Sep 2023 15:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695249324; cv=none; d=google.com; s=arc-20160816; b=L9/nF3alsVpk7Ac98l4SIBjIZddhLcudGotEG/M2fKhghvoE79DvLvnVT2uLPUGfGY U5n5HhdVK4pVDBY969dnf8vhYnca3b+5lbUUpXXwKOMKEtpR+pbirI7gJ2fI4q69gBIq Rm2l5whUU3jVIfd4SxnaBLwyPkIFP1MPeXwXGE3o7GGEBn+4H1VZiITWp+ca/oaqBivm g2u7di1z8GDtqL/LHDI2h8/3EUJSOEvXGqrszk28l3OY7bCZG7jgCeBYW5+6OJMVETNN 3E9mtrIVWaQ6sfnG3My9xmidIWenwAIyNsAo91DDuO7GuDo4r1FU64tbLlpbxSQRqXmE twIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wthoGi7ZgCKB+4R1hYh+kCWMsL5jtj9JzjBOzJpqjGY=; fh=rlyyxRQZzpnnT0Mx6ymolBGcvWMPFJgMaJyPCUjQ80E=; b=gm3jFtmYspUbUrny8B72o1OU1WPCwHzyjQwg7tjOuFwlMi1NlzAsphuOlJxLNsD+1s JGAqIJcOJBYjJAdBGtCl1KGX1d0EI40S6i7mjivGaU3RRgTFWwo5RDDHhOO62/5i/vVg NHInygfjOni1QL0xhOy4pIjgbki5DLQZ7IWA6gDCyneZHETzKuexqa4BmQNQxqQGJ6ux eFK4hmccIJI83VWhcUH1kWrEQ3LxyKqwJRj3uoW3dcpH5UJQi0lUNVgGFbwTdiXu4sxc eGJirNbiqZqm1dcttdOo7iGF33VpJsKfZgj+MautpD6xVlxb1W7ws/dYuAJG5eR6Z4nr Apzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/2KPRd2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l3-20020a654c43000000b00578c64433d5si27527pgr.877.2023.09.20.15.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 15:35:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X/2KPRd2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B207F805BCB4; Wed, 20 Sep 2023 15:26:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbjITW0q (ORCPT + 99 others); Wed, 20 Sep 2023 18:26:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229592AbjITW0o (ORCPT ); Wed, 20 Sep 2023 18:26:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722E7131 for ; Wed, 20 Sep 2023 15:25:13 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B94DEC433CB; Wed, 20 Sep 2023 22:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695248707; bh=1hAloOg1XEAD5sA3NdMjJDFHNgWUZuNJi8NkzQ+xdjM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X/2KPRd2tXwhiYuAlPNMWxsUNRs/wpf1+Sac1UGySMFHFfVKeYXKyYqACvf59kvO+ tFIhvgM4ukD7ZJFFF/zxvBQyjN/KG1w0oeJ4TnWUEQIvBwaBzbtd5uXBh7gW1HbCcN SMtsSNNAHvlrCvG5ZuXNTwx82nwSIZkNVIlJWicqkXOAko1hOFR1U1t24679AB0Tml Fpj0jipmupESYNFGQJlwvke3ufTWUxr3NNttgDgL0rkKud5+gJbWq61w0Dua7SOVOP l+wjfDFk69iWDYwAp/STa/+UgMmDy2cpABeKiapA9cmU/N+e415mg82CvPXyC5m9nQ gg3iuZ74L+AFQ== Date: Wed, 20 Sep 2023 23:25:02 +0100 From: Conor Dooley To: Evan Green Cc: Atish Patra , Anup Patel , Albert Ou , Heiko Stuebner , Marc Zyngier , linux-kernel@vger.kernel.org, Palmer Dabbelt , Conor Dooley , David Laight , Palmer Dabbelt , Jisheng Zhang , Paul Walmsley , Greentime Hu , linux-riscv@lists.infradead.org, Andrew Jones Subject: Re: [PATCH v2] RISC-V: Probe misaligned access speed in parallel Message-ID: <20230920-0e2bce9821557cce8d022157@fedora> References: <20230920193801.3035093-1-evan@rivosinc.com> <20230920-98a392b40f88c69e852e2c88@fedora> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nhi9TlVMSb87TbQQ" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 20 Sep 2023 15:26:46 -0700 (PDT) --nhi9TlVMSb87TbQQ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 20, 2023 at 03:06:45PM -0700, Evan Green wrote: > On Wed, Sep 20, 2023 at 2:27=E2=80=AFPM Atish Patra wrote: > > > > On Wed, Sep 20, 2023 at 2:04=E2=80=AFPM Conor Dooley = wrote: > > > > > > Yo, > > > > > > On Wed, Sep 20, 2023 at 12:38:01PM -0700, Evan Green wrote: > > > > Probing for misaligned access speed takes about 0.06 seconds. On a > > > > system with 64 cores, doing this in smp_callin() means it's done > > > > serially, extending boot time by 3.8 seconds. That's a lot of boot = time. > > > > > > > > Instead of measuring each CPU serially, let's do the measurements on > > > > all CPUs in parallel. If we disable preemption on all CPUs, the > > > > jiffies stop ticking, so we can do this in stages of 1) everybody > > > > except core 0, then 2) core 0. > > > > > > > > The measurement call in smp_callin() stays around, but is now > > > > conditionalized to only run if a new CPU shows up after the round of > > > > in-parallel measurements has run. The goal is to have the measureme= nt > > > > call not run during boot or suspend/resume, but only on a hotplug > > > > addition. > > > > > > > > Reported-by: Jisheng Zhang > > > > Closes: https://lore.kernel.org/all/mhng-9359993d-6872-4134-83ce-c9= 7debe1cf9a@palmer-ri-x1c9/T/#mae9b8f40016f9df428829d33360144dc5026bcbf > > > > Fixes: 584ea6564bca ("RISC-V: Probe for unaligned access speed") > > > > Signed-off-by: Evan Green > > > > Reviewed-by: Andrew Jones > > > > Tested-by: Andrew Jones > > > > > > > > --- > > > > > > > > Changes in v2: > > > > - Removed new global, used system_state =3D=3D SYSTEM_RUNNING inst= ead > > > > (Jisheng) > > > > - Added tags > > > > > > > > arch/riscv/include/asm/cpufeature.h | 2 +- > > > > arch/riscv/kernel/cpufeature.c | 22 +++++++++++++++++----- > > > > arch/riscv/kernel/smpboot.c | 11 ++++++++++- > > > > 3 files changed, 28 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/inclu= de/asm/cpufeature.h > > > > index d0345bd659c9..b139796392d0 100644 > > > > --- a/arch/riscv/include/asm/cpufeature.h > > > > +++ b/arch/riscv/include/asm/cpufeature.h > > > > @@ -30,6 +30,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed); > > > > /* Per-cpu ISA extensions. */ > > > > extern struct riscv_isainfo hart_isa[NR_CPUS]; > > > > > > > > -void check_unaligned_access(int cpu); > > > > +int check_unaligned_access(void *unused); > > > > > > > > #endif > > > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpu= feature.c > > > > index 1cfbba65d11a..40bb854fcb96 100644 > > > > --- a/arch/riscv/kernel/cpufeature.c > > > > +++ b/arch/riscv/kernel/cpufeature.c > > > > @@ -556,8 +556,9 @@ unsigned long riscv_get_elf_hwcap(void) > > > > return hwcap; > > > > } > > > > > > > > -void check_unaligned_access(int cpu) > > > > +int check_unaligned_access(void *unused) > > > > { > > > > + int cpu =3D smp_processor_id(); > > > > u64 start_cycles, end_cycles; > > > > u64 word_cycles; > > > > u64 byte_cycles; > > > > @@ -571,7 +572,7 @@ void check_unaligned_access(int cpu) > > > > page =3D alloc_pages(GFP_NOWAIT, get_order(MISALIGNED_BUFFER_= SIZE)); > > > > if (!page) { > > > > pr_warn("Can't alloc pages to measure memcpy performa= nce"); > > > > - return; > > > > + return 0; > > > > > > Dumb question maybe, but I am limited setup wise at the moment due to > > > a hardware failure which makes checking stuff hard, why the signature > > > change? Requirement for on_each_cpu()? > > > > > > > Requirement for smp_call_on_cpu. >=20 > Right. >=20 > > > > > > } > > > > > > > > /* Make an unaligned destination buffer. */ > > > > @@ -643,15 +644,26 @@ void check_unaligned_access(int cpu) > > > > > > > > out: > > > > __free_pages(page, get_order(MISALIGNED_BUFFER_SIZE)); > > > > + return 0; > > > > +} > > > > + > > > > +static void check_unaligned_access_nonboot_cpu(void *param) > > > > +{ > > > > + if (smp_processor_id() !=3D 0) > > > > + check_unaligned_access(param); > > > > } > > > > > > > > -static int check_unaligned_access_boot_cpu(void) > > > > +static int check_unaligned_access_all_cpus(void) > > > > { > > > > - check_unaligned_access(0); > > > > + /* Check everybody except 0, who stays behind to tend jiffies= =2E */ > > > > + on_each_cpu(check_unaligned_access_nonboot_cpu, NULL, 1); > > > > + > > > > + /* Check core 0. */ > > > > + smp_call_on_cpu(0, check_unaligned_access, NULL, true); > > > > return 0; > > > > > > Why does this function return an int if it can only return 0? > > > >=20 > This is a requirement on the initcall_t function pointer type. Ahh great, thanks for the explanations! --nhi9TlVMSb87TbQQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZQtxOQAKCRB4tDGHoIJi 0gsAAP4oRm6nyjbOWvN0vK15n5APUUbx9gPnLXg16eOjQf84QwD+NsZutNpl565C z1nB04KBD87Lss8Ip4tkKtxkvOSdogA= =dkma -----END PGP SIGNATURE----- --nhi9TlVMSb87TbQQ--