Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5547806rwd; Mon, 12 Jun 2023 06:41:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62cXL51BSiN38wnxbWXKAgacx9yk8WISuh9WaqoKz18/1trcfeuJCVVuPU4OoNUqtChDNc X-Received: by 2002:a05:6a00:138f:b0:663:716e:e752 with SMTP id t15-20020a056a00138f00b00663716ee752mr11930189pfg.26.1686577284809; Mon, 12 Jun 2023 06:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686577284; cv=none; d=google.com; s=arc-20160816; b=miaTN5cBnllEmxSorB7ed3tjD6l+Kys2INcBpQY8p/bQ9hP27RlEMv8sX2yX76gaYt Iy7BrSynSIBRG8pmhq1E0Wgsd0J56Evhx0zfP6c5eOFJ2m8Klbj89azvWGzb/TaQzpxA FLijXy0ZK9Ljpp7jdIHtfuacRj31YCF6F2HJxfjULg0rlBlS12xpsRBygBstVRlL2s2H +u5+qdR3GUwSUOWzjH3BRnNI+1q96qXr2SDfqAj3hz+rMnlj1sqSiz6nP4hIiisphamc azdW9uMPFpTzf7z8XGbgh8ygmEYq4ev6IKm5QS/s3xGlyfVzhZoXlBEPYBc6rcDjN53R +v3A== 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; bh=dN8bOu7ALVTeqAPpOOTv1TNz6VYUlkSTmTnfG79Bq+0=; b=damRWAgfysL5qhXNjZ4j3vMOIk6RQf+9p4FxJ7JLnXGcA8pyPIdMAtNtUA0ECqQLkl Uj36cK/mcJCWeSn2dXZrIyEfXzB3ZOnL1gRR5A2VkJJpIQd5Q61SFUfqY1e8KFIvsWaj IQHLtLu2k/thRmaDqrd+56xP1GuM1H6NlDhIkygiwiGPcopUI/HqTmC1fnIbL0nBtGck 99HvtFm0vmdNqHL3nd2eXsD3tHKorF6DmtWHQbcq3IHB9yu+gD67DuubnYCctM9nh8FK mkbCv7k//7Mc9CRYXeKArUu5vQIdE9uX3n1BI++sBrctCkpMQ9KxIuKd/2Fg/gpcNANy j79Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a626305000000b0064d5b6864d0si5632870pfb.76.2023.06.12.06.41.11; Mon, 12 Jun 2023 06:41:24 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232790AbjFLNRB (ORCPT + 99 others); Mon, 12 Jun 2023 09:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbjFLNQ6 (ORCPT ); Mon, 12 Jun 2023 09:16:58 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 07854D3 for ; Mon, 12 Jun 2023 06:16:56 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B7061FB; Mon, 12 Jun 2023 06:17:41 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.27.163]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F23A3F587; Mon, 12 Jun 2023 06:16:55 -0700 (PDT) Date: Mon, 12 Jun 2023 14:16:28 +0100 From: Mark Rutland To: Marc Zyngier , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Reiji Watanabe , Will Deacon Subject: Re: [PATCH] perf/core: Drop __weak attribute from arch_perf_update_userpage() prototype Message-ID: References: <20230603082519.1088285-1-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230603082519.1088285-1-maz@kernel.org> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 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? 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. > 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 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 > --- > 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. Mark