From patchwork Fri Apr 12 01:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 13626695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A96ECC001CC for ; Fri, 12 Apr 2024 01:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tKp6khP+wA61mDsmRC1dkJfO7UL/tmAQn+Hq5Dj02wA=; b=pEFEMBRIxi2Wam /Zo8D2IQoBmABrYVB0D/4N5lQjXPFsqXVIsUCWbgS77XkJMmunfuCfGXSTmATYYSswXPwspaq6QSZ ZorvWrToodcuGrkCsNycqyLrkZXxhLHZEHTIFhTnmvzoQEvEZhxvCIJfCXBkCYZnSIL9RiInZBfGo FSV2SIyw38MeJRTzq+xZsAHrhbvxhTSnhNvXUXag/hjSway+8XFCWd/6QllxwLp5K8Cryg4d0pySC O1zj9/qYf+SHxrNWaFWCicpnSxtw6dKy+1ogEvKOmUfLHsWkigoWn02dZkdWQg7BAp8nPZ6Fx258Q OhHHbguCIZJryESjAUDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rv64C-0000000EoBx-2GLy; Fri, 12 Apr 2024 01:51:00 +0000 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rv649-0000000EoA7-3evE for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 01:50:59 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-78ec0d2e1e9so18583585a.3 for ; Thu, 11 Apr 2024 18:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1712886655; x=1713491455; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XmAdJT3ZUCPeWfD1wo8jRuZywHZwwpve3RZWOW9haf0=; b=BpwSQ/6h+Jk8pG7DTRUmJ4s3eEbVKNioruhtC90BPEKn7mh0MikfftQ8enW+LyNyPe ZcVylihyycGgIqqPKeQqW6URv8WSdUad5EqxaWPOI0YE/+4KAl4dpYuqqhcg/6tHz7m+ JFYx8dYJOdtHeEPLMktmZZ9VjNmQJl5+srp2cJgqlVWxzHOTmYideCVHQd5g7mfo48Ae 8iFnD1F/LMZQf2n/78WprQj1DiavTK8UdsKN2vw2X4z9i3KbBdM3vIHSy84Up20/Cdg/ Ly+2p7Fu7IUS+vxmWwh9PvN9QcjXGkawPQZD5aoxwu2V3Ysx+xVbdw4aeqIQ8U++k34V EIIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712886655; x=1713491455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XmAdJT3ZUCPeWfD1wo8jRuZywHZwwpve3RZWOW9haf0=; b=i2cwSaj+EF4NeZ8hDZ6ar+IhzpWSXlw3P7AdFnDWsk+qbF0IsJd1pikp6qTsqXRK2u Q3hkNM3qitYSTIfXJwqDrfXeEdLndy807Eyco7rz7GVlSUau2CnhNceYtw2r950FvmU6 EilrBbM5ayhVdMkpV/clLRleKplNE4bTEqh45fNZgzyjjQTxidzTGcs0WlIeRqxW391j j8VKw5vVWZwEuR9Z3iCil8p1ZA7IwW7d/rE97eLksxvfpbIzhkmJuZor+SxIRgWPIIBo B/9W3uEribNochJJT+45sNib6z+boOs6MUuImeN6JCne0OBoRkTAi3qI1DJy95wY4cB/ v0/Q== X-Forwarded-Encrypted: i=1; AJvYcCWLwXWN+sL2tTIKrNWlUyQddUPyVoiw42cg/NHCpa4XKhP1U2YMu9a24PR2LGNACJqm1TenQu9pZNSB1hH79Ta5B4NXnjqo6GpJaepQze0c/RmX7dY= X-Gm-Message-State: AOJu0Yzogbi1eaqh9o7w5Ufy1XeO/1ek5KcIYT1XUrtq0TFAhDn114Co 4aVA5bmBtukETcJE1wGI8UcmbM58hIcrTcNJTuW0p4ZaOEQNGmLtLXbXnkksiw== X-Google-Smtp-Source: AGHT+IH1CdfzeVz3pZajhCl9CVe8VCWrOdYFKQJn9dqM+zf6JXUpBa7+69QfvqWLEhWCHiBE2XF4sw== X-Received: by 2002:a05:620a:2211:b0:78d:68d6:c1e9 with SMTP id m17-20020a05620a221100b0078d68d6c1e9mr1314228qkh.47.1712886655388; Thu, 11 Apr 2024 18:50:55 -0700 (PDT) Received: from ip-172-31-44-15.us-east-2.compute.internal (ec2-52-15-100-147.us-east-2.compute.amazonaws.com. [52.15.100.147]) by smtp.googlemail.com with ESMTPSA id f10-20020a05620a15aa00b0078d76c1178esm1756677qkk.119.2024.04.11.18.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 18:50:55 -0700 (PDT) From: Kyle Huey X-Google-Original-From: Kyle Huey To: Kyle Huey , linux-kernel@vger.kernel.org, Andrii Nakryiko , Jiri Olsa , Namhyung Kim , Marco Elver , Yonghong Song , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Robert O'Callahan , bpf@vger.kernel.org, Will Deacon , Song Liu , Andrii Nakryiko , Mark Rutland , Russell King , Catalin Marinas , Ingo Molnar , Alexander Shishkin , Ian Rogers , Adrian Hunter , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Subject: [PATCH v6 5/7] perf/bpf: Remove unneeded uses_default_overflow_handler() Date: Thu, 11 Apr 2024 18:50:17 -0700 Message-Id: <20240412015019.7060-6-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412015019.7060-1-khuey@kylehuey.com> References: <20240412015019.7060-1-khuey@kylehuey.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240411_185057_922635_41F48047 X-CRM114-Status: GOOD ( 18.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that struct perf_event's orig_overflow_handler is gone, there's no need for the functions and macros to support looking past overflow_handler to orig_overflow_handler. This patch is solely a refactoring and results in no behavior change. Signed-off-by: Kyle Huey Acked-by: Will Deacon Acked-by: Song Liu Acked-by: Jiri Olsa Acked-by: Andrii Nakryiko --- arch/arm/kernel/hw_breakpoint.c | 8 ++++---- arch/arm64/kernel/hw_breakpoint.c | 4 ++-- include/linux/perf_event.h | 17 +++-------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c index dc0fb7a81371..054e9199f30d 100644 --- a/arch/arm/kernel/hw_breakpoint.c +++ b/arch/arm/kernel/hw_breakpoint.c @@ -626,7 +626,7 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, hw->address &= ~alignment_mask; hw->ctrl.len <<= offset; - if (uses_default_overflow_handler(bp)) { + if (is_default_overflow_handler(bp)) { /* * Mismatch breakpoints are required for single-stepping * breakpoints. @@ -798,7 +798,7 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr, * Otherwise, insert a temporary mismatch breakpoint so that * we can single-step over the watchpoint trigger. */ - if (!uses_default_overflow_handler(wp)) + if (!is_default_overflow_handler(wp)) continue; step: enable_single_step(wp, instruction_pointer(regs)); @@ -811,7 +811,7 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr, info->trigger = addr; pr_debug("watchpoint fired: address = 0x%x\n", info->trigger); perf_bp_event(wp, regs); - if (uses_default_overflow_handler(wp)) + if (is_default_overflow_handler(wp)) enable_single_step(wp, instruction_pointer(regs)); } @@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs) info->trigger = addr; pr_debug("breakpoint fired: address = 0x%x\n", addr); perf_bp_event(bp, regs); - if (uses_default_overflow_handler(bp)) + if (is_default_overflow_handler(bp)) enable_single_step(bp, addr); goto unlock; } diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 2f5755192c2b..722ac45f9f7b 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -655,7 +655,7 @@ static int breakpoint_handler(unsigned long unused, unsigned long esr, perf_bp_event(bp, regs); /* Do we need to handle the stepping? */ - if (uses_default_overflow_handler(bp)) + if (is_default_overflow_handler(bp)) step = 1; unlock: rcu_read_unlock(); @@ -734,7 +734,7 @@ static u64 get_distance_from_watchpoint(unsigned long addr, u64 val, static int watchpoint_report(struct perf_event *wp, unsigned long addr, struct pt_regs *regs) { - int step = uses_default_overflow_handler(wp); + int step = is_default_overflow_handler(wp); struct arch_hw_breakpoint *info = counter_arch_bp(wp); info->trigger = addr; diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 65ad1294218f..13a2b05cc431 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1339,8 +1339,10 @@ extern int perf_event_output(struct perf_event *event, struct pt_regs *regs); static inline bool -__is_default_overflow_handler(perf_overflow_handler_t overflow_handler) +is_default_overflow_handler(struct perf_event *event) { + perf_overflow_handler_t overflow_handler = event->overflow_handler; + if (likely(overflow_handler == perf_event_output_forward)) return true; if (unlikely(overflow_handler == perf_event_output_backward)) @@ -1348,19 +1350,6 @@ __is_default_overflow_handler(perf_overflow_handler_t overflow_handler) return false; } -#define is_default_overflow_handler(event) \ - __is_default_overflow_handler((event)->overflow_handler) - -#ifdef CONFIG_BPF_SYSCALL -static inline bool uses_default_overflow_handler(struct perf_event *event) -{ - return is_default_overflow_handler(event); -} -#else -#define uses_default_overflow_handler(event) \ - is_default_overflow_handler(event) -#endif - extern void perf_event_header__init_id(struct perf_event_header *header, struct perf_sample_data *data,