Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5643022rwd; Mon, 12 Jun 2023 07:51:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Pcbr8Q4E5TZYNPo/cA4MrwHG1cwPyIZRIbUunlPEvDI73a/hrEu7/xrvp3CBKcTBaP8aW X-Received: by 2002:a2e:9b4d:0:b0:2b1:bc73:6fa with SMTP id o13-20020a2e9b4d000000b002b1bc7306famr3291113ljj.21.1686581515314; Mon, 12 Jun 2023 07:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686581515; cv=none; d=google.com; s=arc-20160816; b=hfkhNuE8buHXGVVsuSLrt2DYjlYHCzGt0UNf2Aut9dgcVAEyMceeEGDmeP6IeaNNxe jU1RskAGSGSy0YgHILoafAgClphytyBAhvnFzzzKOMx1gszKYCpjh0hiTqNUcwcrbBYz c05edrKcZ3wTae6/zzGgsiDV3a/Rb5UIWClJtMNTvCGgtWOhfQY6WebWejfZlKrXYXc4 hytArjiL2Mw1QG3JGcMH7Omczz4Y88C0hiKQlHBB6V2PfagLz09J6zuKw81IRBKdF4XM 6ssTul2/7hWXb+mi6hPV11HamJhGymGAqZ++Whv5mgQuyE5aTV+V6AtkHVKTayRGTysP k1lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=JQ1hmTaIDykugYgXvD2TmlqQ7XJURT9m00yN5xE0Yzw=; b=J7EkwrcmbbKdj4+SsqqrSZzqCLDtn16h8fc2B9bQXVTkZlfY+ZxVQ9nan9D6odFBOW LqeC9ExRfQRztsqUY9026C4aFc5AO8FGulU3Ct0qXSnUpa6RARIjDo/6rQPPxn7dEo4J 3gM8/nBcgbKXXQQqmwehZCrGZ/oZlwRIV6DIA9hXr9S719ZaU2CAGAzqd4LWKfW6EMLU /Fc8shGKDIlghO2AL6zRFsYBO56NF0HJmFWK/nipeUKE+CkGKs7pjOvaT28HGIdGykRy LLdA45UlMIun4tFjM9H9sCgpDNfzfivU6WZ3UKb77N43CUBucwiUp1+Rz2sSrsdSCROL Yo/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nzoBJ1bG; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay5-20020a170906d28500b00973943e93efsi5330014ejb.237.2023.06.12.07.51.29; Mon, 12 Jun 2023 07:51:55 -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=@kernel.org header.s=k20201202 header.b=nzoBJ1bG; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238795AbjFLOa1 (ORCPT + 99 others); Mon, 12 Jun 2023 10:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239203AbjFLO3t (ORCPT ); Mon, 12 Jun 2023 10:29:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7960E359C for ; Mon, 12 Jun 2023 07:28:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D4FD6629E5 for ; Mon, 12 Jun 2023 14:16:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 381C6C433D2; Mon, 12 Jun 2023 14:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686579390; bh=CUocQXDmDUDrCH8DSfjB1ZDpiJDl+Vs2OSk+s3E8iyU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nzoBJ1bGG6m/+9R2nvVL24K3bXHsfil+Lq8hdB/ynWEGUti3bug5QOmZurs5D9tEc b7k5U6L0b71ZNvLiSDxbOky3o3oWrg8gdwUNKGDtTAAeKm8tiazquNX1/6itGM8a9G Zp5ngSQt9fsJ7YAKXkRDnryn1nbtFuwPqz2f1YbGR6UYCrlatbCpuqK2KAHrq3PcBA 6hHB/Vo1gwIVZxF67fLg5+o8fauYKulorGnUCuI4lv/fYGXiVQcYxa8kITnAHcDqur vTMH89rn5EbexEwV1SntE00Tj/fKoY2vygU7pQic31BRsZdLh3qyzl9W7aVcn1LZJp lwfOS2YFvcxwg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q8iLL-004o9S-Du; Mon, 12 Jun 2023 15:16:28 +0100 Date: Mon, 12 Jun 2023 15:16:27 +0100 Message-ID: <86sfawbwas.wl-maz@kernel.org> From: Marc Zyngier To: Mark Rutland Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Reiji Watanabe , Will Deacon Subject: Re: [PATCH] perf/core: Drop __weak attribute from arch_perf_update_userpage() prototype In-Reply-To: References: <20230603082519.1088285-1-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mark.rutland@arm.com, peterz@infradead.org, linux-kernel@vger.kernel.org, reijiw@google.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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, 12 Jun 2023 14:16:28 +0100, Mark Rutland wrote: > > On Sat, Jun 03, 2023 at 09:25:19AM +0100, Marc Zyngier wrote: > > Reiji reports that the arm64 implementation of arch_perf_update_userpage() > > is now ignored and replaced by the dummy stub in core code. > > This seems to happen since the PMUv3 driver was moved to driver/perf. > > I guess we should have a Cc stable then? Potentially. I don't think anyone else is affected though, as we're the only one implementing this outside of the arch code. > > The below implies this has always been on dodgy ground, and so it's probably > inaccurate to give this a Fixes tag pointing to the move. Indeed. We just didn't notice. > > > As it turns out, dropping the __weak attribute from the *prototype* > > of the function solves the problem. You're right, this doesn't seem > > to make much sense. And yet... It appears that both symbols get > > flagged as weak, and that the first one to appear in the link order > > wins: > > > > $ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage > > 0000000000001db0 W arch_perf_update_userpage > > Ah, so having it on th *declaration* will apply to any *definition*. :/ > > That suggests this is a bad pattern generally, and we should probably remove > the other __weak instances in headers. Lukcily it seems there aren't that many: > > [mark@lakrids:~/src/linux]% git grep __weak -- **/*.h | wc -l > 50 The majority seems to be in tools (BPF FTW!), but get_c0_perfcount_int in the MIPS code count be an interesting one... > > IMO we'd should aim to remove __weak entirely; it causes a number of weird > things like this and it'd be much easier to manage with a small amount of > ifdeffery. > > Peter, thoughts? > > > Dropping the attribute from the prototype restores the expected > > behaviour, and arm64 is able to enjoy arch_perf_update_userpage() > > again. > > > > Reported-by: Reiji Watanabe > > Signed-off-by: Marc Zyngier > > Cc: Peter Zijlstra > > Cc: Mark Rutland > > Cc: Will Deacon > > Tested-by: Reiji Watanabe > > FWIW, regardless of the above: > > Acked-by: Mark Rutland Cheers for that. > > > --- > > include/linux/perf_event.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > > index d5628a7b5eaa..c8dcfdbda1f4 100644 > > --- a/include/linux/perf_event.h > > +++ b/include/linux/perf_event.h > > @@ -1845,9 +1845,9 @@ int perf_event_exit_cpu(unsigned int cpu); > > #define perf_event_exit_cpu NULL > > #endif > > > > -extern void __weak arch_perf_update_userpage(struct perf_event *event, > > - struct perf_event_mmap_page *userpg, > > - u64 now); > > +extern void arch_perf_update_userpage(struct perf_event *event, > > + struct perf_event_mmap_page *userpg, > > + u64 now); > > > > #ifdef CONFIG_MMU > > extern __weak u64 arch_perf_get_page_size(struct mm_struct *mm, unsigned long addr); > > Luckily, arch_perf_get_page_size() has no callers or definition since commit: > > 8af26be062721e52 ("perf/core: Fix arch_perf_get_page_size()") > > ... so we can just delete that prototype. Yeah, I have a patch for that too, but didn't want to distract with something that is just a basic cleanup, and I'd rather see a sweeping cleanup. M. -- Without deviation from the norm, progress is not possible.