Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp230357imw; Mon, 4 Jul 2022 08:12:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhY9092Vb0NrSBwtrDA+xp8aDSpr/szZ2X2m4Z97hSa9SYQI5BBOq2Q+7m0lI8mvbrvgA3 X-Received: by 2002:a17:907:608b:b0:725:f45:39be with SMTP id ht11-20020a170907608b00b007250f4539bemr29932286ejc.669.1656947536497; Mon, 04 Jul 2022 08:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656947536; cv=none; d=google.com; s=arc-20160816; b=dbiv2v8DEUPYRljJerli+1fs0Uk9dnoj9T11C3LgyjWhHJTfM07Se/KtrGqhoQFnzc Zn5nT3Hp07gYW4igb4qGIFle/wJTZ/zWlQTELeVUoHGU6noze6IJidQPEzTji4N3H67C PI/xCJSTu3n6M/By2i8EiAXGoPtRw91fIjpp2ERcxdNMttyMMA2qWUqmjTRTv/Pnchs4 FaRW/7RBZxpjS1VE1bntNmZxKOjkpM8Hs+cteXhUEVCI2eKETL6IsVL8ouojkhlQgis4 o6kfceBp81dOFQEk8ojE/KN5CaEzvjaIvkUfD3IWLG0eWpwqs1iVfyugdl2DGInNEZ4E m4iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=1aXAa75QFld8JbpbPPEthMJig82bhovg/Ry5+b6na1M=; b=H6dAy+Gdt2jKx/XywunkB0d4k2FhagYPtM3JbLD3+Wk+iTnNEcxW7gN6z9+sbSjUc/ t815zIgI5ZmwOvxMwYxNeUDhpUaqXHEsjFv5ub1E3cLb6PhvZi1LRf+PIO8+XKro/T0y FOi5XuyONy/63UDqpmwQBs1QgpKBzh10zTjh8BrbVqZ8j1HRH1Zv23cCOAtGSSqsw2gW ntD7EEfjKp1G5qJo5NVHkr+ao133m99onUJEe34Cl9/VfuoYHUYCO3nNhtyN9wIFsC6r DWlOKQMDN3449Uxyl7q1+Qgun5RFDVUvbIeqPyIZWxR2UdSSSFAGgtuyBybHjjeiEt0z hgUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QbMgulhI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg18-20020a170907a41200b0070795e99fe3si14892905ejc.984.2022.07.04.08.11.51; Mon, 04 Jul 2022 08:12:16 -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=@google.com header.s=20210112 header.b=QbMgulhI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235019AbiGDPGm (ORCPT + 99 others); Mon, 4 Jul 2022 11:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234868AbiGDPG0 (ORCPT ); Mon, 4 Jul 2022 11:06:26 -0400 Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9EE21180E for ; Mon, 4 Jul 2022 08:06:16 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id hd35-20020a17090796a300b0072a707cfac4so2115671ejc.8 for ; Mon, 04 Jul 2022 08:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=1aXAa75QFld8JbpbPPEthMJig82bhovg/Ry5+b6na1M=; b=QbMgulhIjFHZOKr5YUDv8X5y5GYgyld0Dc3IFnyu3IQSon/TLP4ioIa3f89U8smZwo U+WA93et7dQm/OMnt016E80SrrPFeQBKr7TT8q/bG/+pIobmaX9cV85MGeJbgfwiPq1b Ava89xEesjG1OvK8d5HhEqp6Dk3T9DeQmZyzZkzFWENmRt6DEyJf1XZ/EdlOu86I7EvX atAyCVgS3XzUh3vzK3iLPDIDyYfir4UE8EUj4i/7Gr8GaAqkFojlXvkAl6EOkbu8sGt2 N+bA+TrhJ8zM0Ge7Q8+mtkxw4fiHMoiDRKfXJ/9ftoItH4d7yqJ4645bBLJu9qa0u2ti D/vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1aXAa75QFld8JbpbPPEthMJig82bhovg/Ry5+b6na1M=; b=4P37VHBpikKmMa6cRj6WdKd3ei1qQB2n6Hciq78SVs7klZTaMzEVPvXRsfqZlwwavM 9Z012uO0L0jfWg8Nrxdv2Hve6+n/uwARzas1XHTTssiiKeroK87p3qMHZjYlNDL6ejw8 eCH1nea5nRzV8fhvTALguiktc+RLzIKmd3O7DnyYJljacovU32dbrBsw2GS0jix70J/G SImvFm/YoLKtgpHpPofD3b++V9kLlMoy3MHidgbMKDSE+gBpwPpN5ODCBTfqxPdrh3wK 8iFyOW4O2o97dKxD2oli0nI4Id6qyNbc2vt0t4yvJ78vwR7dRbhWVO5d1FbpjGAl22Aj Iqpw== X-Gm-Message-State: AJIora94Mzy5JLUp1f1mIOJ0+G/HsIhDsz0qpe5SPWMwS8yLA1rnoRpa InUpQMHuSxkTCYM7Y7NQ7rTQeJPlvA== X-Received: from elver.muc.corp.google.com ([2a00:79e0:9c:201:6edf:e1bc:9a92:4ad0]) (user=elver job=sendgmr) by 2002:a17:906:74d6:b0:722:e521:7343 with SMTP id z22-20020a17090674d600b00722e5217343mr28873376ejl.432.1656947175193; Mon, 04 Jul 2022 08:06:15 -0700 (PDT) Date: Mon, 4 Jul 2022 17:05:07 +0200 In-Reply-To: <20220704150514.48816-1-elver@google.com> Message-Id: <20220704150514.48816-8-elver@google.com> Mime-Version: 1.0 References: <20220704150514.48816-1-elver@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v3 07/14] perf/hw_breakpoint: Make hw_breakpoint_weight() inlinable From: Marco Elver To: elver@google.com, Peter Zijlstra , Frederic Weisbecker , Ingo Molnar Cc: Thomas Gleixner , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Dmitry Vyukov , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-perf-users@vger.kernel.org, x86@kernel.org, linux-sh@vger.kernel.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Due to being a __weak function, hw_breakpoint_weight() will cause the compiler to always emit a call to it. This generates unnecessarily bad code (register spills etc.) for no good reason; in fact it appears in profiles of `perf bench -r 100 breakpoint thread -b 4 -p 128 -t 512`: ... 0.70% [kernel] [k] hw_breakpoint_weight ... While a small percentage, no architecture defines its own hw_breakpoint_weight() nor are there users outside hw_breakpoint.c, which makes the fact it is currently __weak a poor choice. Change hw_breakpoint_weight()'s definition to follow a similar protocol to hw_breakpoint_slots(), such that if defines hw_breakpoint_weight(), we'll use it instead. The result is that it is inlined and no longer shows up in profiles. Signed-off-by: Marco Elver Reviewed-by: Dmitry Vyukov --- include/linux/hw_breakpoint.h | 1 - kernel/events/hw_breakpoint.c | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index a3fb846705eb..f319bd26b030 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -80,7 +80,6 @@ extern int dbg_reserve_bp_slot(struct perf_event *bp); extern int dbg_release_bp_slot(struct perf_event *bp); extern int reserve_bp_slot(struct perf_event *bp); extern void release_bp_slot(struct perf_event *bp); -int hw_breakpoint_weight(struct perf_event *bp); int arch_reserve_bp_slot(struct perf_event *bp); void arch_release_bp_slot(struct perf_event *bp); void arch_unregister_hw_breakpoint(struct perf_event *bp); diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index 9fb66d358d81..9c9bf17666a5 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -124,10 +124,12 @@ static __init int init_breakpoint_slots(void) } #endif -__weak int hw_breakpoint_weight(struct perf_event *bp) +#ifndef hw_breakpoint_weight +static inline int hw_breakpoint_weight(struct perf_event *bp) { return 1; } +#endif static inline enum bp_type_idx find_slot_idx(u64 bp_type) { -- 2.37.0.rc0.161.g10f37bed90-goog