From patchwork Wed Feb 14 17:39:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 201076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1384052dyb; Wed, 14 Feb 2024 09:42:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVJWJMrHn52Lw/I5jSfPTBuAxtudwbI3fdE6x8rxB2EuBAJI+PZPXGn3cD5jf6Llp50OFyGQGlilGs3mE8uLzbw2l82lw== X-Google-Smtp-Source: AGHT+IECM1S4BSWzOBrnpP/ronPDn/eKrvpj0Rv1Yf98dsoC480m1H3IV5hZWKrYmtRm+hsNDGWc X-Received: by 2002:a05:6402:b30:b0:561:f78f:1049 with SMTP id bo16-20020a0564020b3000b00561f78f1049mr2543192edb.35.1707932579330; Wed, 14 Feb 2024 09:42:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707932579; cv=pass; d=google.com; s=arc-20160816; b=duU0LbdIHqqyn9FITqMA9vX86gkStEiWn3VuvGzaFUUEA6cEZr8eCS45+Zb7YkqveE 9n1TuDszyj3C6w43fKaRRmURNgsIJgxOkWPr2cGAkQ2vmy2XCR9PqVWFE3dPHT0zWLEJ xysReUGwlhsDbc9GgH4OumID3EMEPIBPkDGR+KbouY+agiOIXjzB+vFKzRiY48dXHnWm OdNRbqJO+xMIUwwkrZxLyKAUum/b85XXlOreGMTXnNsl7sijapVXYbByP00EdcDnD7rN 9FWrmhlZyqCJbXaOuEpMua7+QNVN9Wei18mEuwIKQ8/ySYvq+wTsR9curku+c8NHYbdG EaNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/ElBvlPVPDuFmuEeY/T4KuG3RaPIc1GsemQ8p6vqiM4=; fh=PpK2bNg1t5pNbrNGwf85oxieaVWW1KZqeXEpXTgibPs=; b=sp5fgtUWZjgMtOCgCIfpBBLirDUJJ4m6bBUuZ9gPJDAHlqlqbYo+uzRS5Yb7yxbkBU 2tHCX2p3g0EMRyH270zzWUhF/iEKKScm3aFQThSCsendY2Q/DMneN45quhxajJbbn1uW Z+oT6LSqRADH5kMCriC+NYRkqVbZrspfQVxJ5Q7ws3ERTDaTuazBApkZ8aSWB54sWwTG /kewcLKZ2VUJdwJH/c1iTboudUsn2DttTV3P29d6QdFA5CTLCp5ssjjLBtq6oEu7IOO/ vXZtf6BKtA8pW3fO5LIjSAU32dkd2sZpw3e7Iul/Kb9d1QLXoHmN3fEfUVA2m84uSRe7 Q9jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=IoqOV6s8; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-65698-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65698-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVnh6X8MflzvEMpekwsKwXaZX/UKMFDR727VP4Qji8XNrOhVTKAFnKiE7XvxDlAqG0Z5dSTL2k/xzQ01jny1v09HW2DKA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r21-20020a056402235500b00561e965cf12si2228806eda.112.2024.02.14.09.42.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:42:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65698-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=IoqOV6s8; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-65698-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65698-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8D8A21F2B537 for ; Wed, 14 Feb 2024 17:42:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E386286625; Wed, 14 Feb 2024 17:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kylehuey.com header.i=@kylehuey.com header.b="IoqOV6s8" Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9A2185282 for ; Wed, 14 Feb 2024 17:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707932448; cv=none; b=AHLcb0dfqdk/GMtCkzOBcW6lmE6F3MHD5sxAxrbWU/3q4X3Zko9B7d6yE6j06RMPV5dKDpv371lsnbAMv2k6sjemo7AvSCUUK3sm24sCzR+GzVioaDOU19+ByS3dapCcbrdoVIYRbTgLzavJqdsVUOSvkvUd3ktIBUoNX2d/77I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707932448; c=relaxed/simple; bh=zUABpjG2ub173w63GMgMTw18XVCHIXF84Q0edlKhxyE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H95jVdkaYIe4BY+rswM4QF7NzeCKG7kpHI5w9pO0P9eXu8g7Xg4eBL3VjjYfLnbMM3Il17gWfknCANLc2a4rNUpO2k7f3GmHmYizH89nDGbXoxPH4Jbt80WYzcRLiw6IXVcm23HL70q4B9i1tLUNhsJM7SsNhItewE7QpRmJMls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylehuey.com; spf=pass smtp.mailfrom=kylehuey.com; dkim=pass (2048-bit key) header.d=kylehuey.com header.i=@kylehuey.com header.b=IoqOV6s8; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylehuey.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylehuey.com Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-5dc20645871so9225a12.1 for ; Wed, 14 Feb 2024 09:40:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1707932445; x=1708537245; darn=vger.kernel.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=/ElBvlPVPDuFmuEeY/T4KuG3RaPIc1GsemQ8p6vqiM4=; b=IoqOV6s8Wx059NZmgJ9rmO7ZmLPt71UVBcT0WDfE7hDZ+0pKYLawhwp+c3i2Hsd+lh SKl0qaVvsppcXqJ3kvIDRFrt3a/BjswkNyWZmas+ACVehWrGNw3KA4wvGXN6omMoz/LN AH6DBp9pbZw9vbWMS0OgoEmF5Vz29UTdPwF4JIQMERu+mpTcneTZ3ffZimJMuEvjKmwb S03uoj7ovWVn0atkhg5DfTwYPG88Borp/pCsqGv49udH2dEhhl++lMLoxizRgur0PT8W FJat12JhuKe1wn++KDLETk3uKGMrz77t397fxZZcRtH73R9JXG7AYWtRQoOhLw76Adno NWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707932445; x=1708537245; 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=/ElBvlPVPDuFmuEeY/T4KuG3RaPIc1GsemQ8p6vqiM4=; b=HJRebqC7VX0E+eQqq18SLeIt9EkKE39f1/ZAYlgouPTIwiJT6rDPJBsCvGuLWnD7bD yxiVjQZQEkU/Jd0NIrQ3dUzJg1/aQycXL9svzFlqTPywVpNPqazL5GhRQxv3tz/ZlDgs XXJM2qOcS7/NvIa5LiCHOMLS9UTZHIrsHPJwdtLDZIDBNFtpDxuhd/qVk4T4DsWVxthF SXykwoeLhU6mR+GeyKPo5PKVCmoQORKj2FQnRRwWxVFbYEKgSSbi8zZdNTjdm09YNFiC dAJyzIvcmtrLEpxZdsmHaIC/ypOlC/jZDORw2t0svy2qVWhdhBobUNLnWs19b30SMhjA jySA== X-Forwarded-Encrypted: i=1; AJvYcCVisRqCC2uY6RCzvs5RQXDc7bNsGVtC7TZUZ/wSB3kqBir5LTuMwV4EQJPGk1ww+BIYnI8aZYsB6S9wQMQEkXWhdae+z2TsYTgHlhLQ X-Gm-Message-State: AOJu0Yz6NVNX+E6WOdPqNA6UZj5Ix9ir10e+b5Em1XzGVHi2LQ1dHO6r 6rnmUTxrMhp0LSLya55ig7PFytNDPeXsqHZ6rHQBzwwFM7qTVIqXPUkkAUw61Q== X-Received: by 2002:a05:6a20:d818:b0:19e:b614:685c with SMTP id iv24-20020a056a20d81800b0019eb614685cmr4223312pzb.22.1707932444999; Wed, 14 Feb 2024 09:40:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXBfzyE+xp/BPlirU8BbCNUyN9ay2yh+NMWrAWy4c76qJ1yppJZxe8xiOfc5BMTzaFpkXe3UVkwzuP7xcq8xBBkCBKiNiPp+12RTFq2CYHcu3qAvyC58hc4HuneYLJtyQnigIefY/GIMhc2iwaZk92xQSnhH94zzOGcvwSBsk8u9gIIQlOLDuURAj3u/lA8/45midZ5HMNzKnK0ywKeuuVVOJSslwMwHExU8lt7ybeAip41HXTRwZpYNugEaRiwKrZuAeCW9tdbOzDoGrkbJsgkkpUr/eHW4gyYN/FuussuWMaQFDwnAfhd3hc0TxkspyBnHxAmx0hfxuvMX8LDah+MopPTInvr6p+Z2xQQ0mGNmXEuTagrhCRvxp9QDo8FytDEsDjJUQl+fqldStC140ECBeOZSvpzlnKi9YLnTYZUfcP+5/Oh+wsQnProma40Rw7BHKV+fGL/zq3+ENEAvMKjLTwiN8xFxwztlkOTf53sOyiWszjhURi1aTa58u/6LPOpmGn91/8kLxYDfFV3YEtP346j5Gbck0lF192IeZ+zRKinjW5RQ5yOmPT0F7ohb9ckM4/rR8FJ3Q33v/dciL9JDZwZhLgSDsxHREHi/Bgj4f+EVwmLP3QOFsg5PWEfaeKBcWayXi3q8pqdtX1YML3asSjMw9Ml6ll5f+1kesxySZjAdHSZoF2w Received: from zhadum.home.kylehuey.com (c-76-126-33-191.hsd1.ca.comcast.net. [76.126.33.191]) by smtp.gmail.com with ESMTPSA id p5-20020aa78605000000b006e0874cbaefsm9567604pfn.27.2024.02.14.09.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:40:44 -0800 (PST) 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 , Will Deacon , Song Liu , Mark Rutland , Russell King , Catalin Marinas , Alexander Shishkin , Ian Rogers , Adrian Hunter , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Subject: [RESEND PATCH v5 2/4] perf/bpf: Remove unneeded uses_default_overflow_handler. Date: Wed, 14 Feb 2024 09:39:33 -0800 Message-Id: <20240214173950.18570-3-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214173950.18570-1-khuey@kylehuey.com> References: <20240214173950.18570-1-khuey@kylehuey.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790897112140744988 X-GMAIL-MSGID: 1790897112140744988 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 | 16 ++-------------- 3 files changed, 8 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 35225632d70a..db2a1861bb97 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -654,7 +654,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(); @@ -733,7 +733,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 c7f54fd74d89..c8bd5bb6610c 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1341,8 +1341,9 @@ 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)) @@ -1350,19 +1351,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,