Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5033660rdb; Tue, 12 Dec 2023 17:39:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPZ6vBoyLp5WZ/Q0rAqUVa3ChlTg/uPUWKvBqJiMNECUPuwAW/h1rKPJOmXz1LiYXU4nlR X-Received: by 2002:a05:6870:2c91:b0:1fa:f56e:e9c with SMTP id oh17-20020a0568702c9100b001faf56e0e9cmr9571374oab.3.1702431544957; Tue, 12 Dec 2023 17:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702431544; cv=none; d=google.com; s=arc-20160816; b=sJtmX8RCCu6HQ/z7kRM+Lbt21CkM1TGwZKAXogtsU+KwdJHTq1SjatTBtkB15+gQlC NyPIu34gqWXpx0SoAJrId7wYydIZ5/VmJSLNAuPd/uGfuWh969Ln9FV2LRCsomM+x5bb 52QsH/TOed6qcHdZrZ8Em8G83BVWcxWZnP1UcZUimXx1qxF0JSQWJkqR7Jj/uoiEI5vN zan9jtuvQofdPub8zll3pWGj1r3I7OmIJ85s3s9Js3kdFKluBytB/A5nDlmAGxQlpYY2 MNMLX6PyfDB76CVSzw3SfuzlKlL/QtJI6U6kPncg2jvSY3lOKjFYpZIVAvCJyZRZjAL7 1WiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=Y+YcGIvQtbTA774oULiQjytsGLeVIgnAxn6F4EW+kJI=; fh=gtyJfpHq342tGBYxiKfII3TmUg+0TWsFG8aYGrL+Vsg=; b=ERfOCY546nt3lxD5SJRJwl0mkShcwVInKL+t5htleJGpJi0xoO8D8w3urULR1n1lND Ldt8/axGjND4qF16dysV4sNZRVyBJgzDD/nTDi2yr1mkwXORILcMe7PNUrKyE94Vyl+C RkEFBpqhhugDBUFZUGg3yVvKkbV69wxnc8bFVbLsegHU74j2SbUqFCWghVGEGBaIPwH9 yBzgumq1o/jUgZHDrZ6dzIiQZua+gP0KDESRTMWTBdhUfIAriMwIUJVif99ZR264nJEg 09q1NCvr2ZMzNuNKXPJa6MF9HZwOCJRiMgOf/ghPIYo4jRbPgf+wZjH1FOw16hR0yMSd HAsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o13-20020a634e4d000000b005bdd76219edsi8464747pgl.675.2023.12.12.17.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:39:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B5529801B4A3; Tue, 12 Dec 2023 17:39:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378211AbjLMBil convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Dec 2023 20:38:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378218AbjLMBik (ORCPT ); Tue, 12 Dec 2023 20:38:40 -0500 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFB3DDC; Tue, 12 Dec 2023 17:38:45 -0800 (PST) Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6d855efb920so5079384a34.1; Tue, 12 Dec 2023 17:38:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702431525; x=1703036325; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YIWyx+xVFC2u/BA+JksVQths0h28NvpxYOOQa54kPF4=; b=EFGQfdiiwRYwCoFGDdwWFDPhVvXuqtpK/4c+YrkBGlUdNMn3AzZTac1zEleEFCf6aY CG0oT5mypW+NZCNRiTDgj6HxB4R8pOQw1hgeH9HyqafgLcGWns1egL8BK5lfgmPEQX6H RC5700fwaRQ7ScFJGBwvHhaT+zlKj3dMhcsCeSIkqN2nYHlMvCAw92sVTxlM6yxcr2xJ T/Z9rwLWyrtB0hTgtyz8fifxhVMn8BuNUTb9Wh9ArooLfUPUeFntFZgAOj1xGoCoIDIM 0fK+nPK9NpyIc14UiPZiAYBBi3y24Djz/CBGgqHE5AIlBJ9czMdUsU4ttAOgWDIXb4H8 baTw== X-Gm-Message-State: AOJu0YxurFebBOG1eT4G+UHREMKsUX8TA+QX6wMASPXzG5fkmHdj8478 03W4k6xIyLeZYj7bN0E/O+xQV2OGo5UbBbme6OY= X-Received: by 2002:a9d:6349:0:b0:6d9:d567:7c36 with SMTP id y9-20020a9d6349000000b006d9d5677c36mr7620957otk.71.1702431525092; Tue, 12 Dec 2023 17:38:45 -0800 (PST) MIME-Version: 1.0 References: <20231211045543.31741-1-khuey@kylehuey.com> In-Reply-To: <20231211045543.31741-1-khuey@kylehuey.com> From: Namhyung Kim Date: Tue, 12 Dec 2023 17:38:34 -0800 Message-ID: Subject: Re: [PATCH v3 0/4] Combine perf and bpf for fast eval of hw breakpoint conditions To: Kyle Huey Cc: Kyle Huey , linux-kernel@vger.kernel.org, Andrii Nakryiko , Jiri Olsa , Marco Elver , Yonghong Song , "Robert O'Callahan" , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 17:39:01 -0800 (PST) Hello, On Sun, Dec 10, 2023 at 8:55 PM Kyle Huey wrote: > > rr, a userspace record and replay debugger[0], replays asynchronous events > such as signals and context switches by essentially[1] setting a breakpoint > at the address where the asynchronous event was delivered during recording > with a condition that the program state matches the state when the event > was delivered. > > Currently, rr uses software breakpoints that trap (via ptrace) to the > supervisor, and evaluates the condition from the supervisor. If the > asynchronous event is delivered in a tight loop (thus requiring the > breakpoint condition to be repeatedly evaluated) the overhead can be > immense. A patch to rr that uses hardware breakpoints via perf events with > an attached BPF program to reject breakpoint hits where the condition is > not satisfied reduces rr's replay overhead by 94% on a pathological (but a > real customer-provided, not contrived) rr trace. > > The only obstacle to this approach is that while the kernel allows a BPF > program to suppress sample output when a perf event overflows it does not > suppress signalling the perf event fd or sending the perf event's SIGTRAP. > This patch set redesigns __perf_overflow_handler() and > bpf_overflow_handler() so that the former invokes the latter directly when > appropriate rather than through the generic overflow handler machinery, > passes the return code of the BPF program back to __perf_overflow_handler() > to allow it to decide whether to execute the regular overflow handler, > reorders bpf_overflow_handler() and the side effects of perf event > overflow, changes __perf_overflow_handler() to suppress those side effects > if the BPF program returns zero, and adds a selftest. > > The previous version of this patchset can be found at > https://lore.kernel.org/linux-kernel/20231207163458.5554-1-khuey@kylehuey.com/ > > Changes since v2: > > Patches 1 and 2 were added from a suggestion by Namhyung Kim to refactor > this code to implement this feature in a cleaner way. Patch 2 is separated > for the benefit of the ARM arch maintainers. > > Patch 3 conceptually supercedes v2's patches 1 and 2, now with a cleaner > implementation thanks to the earlier refactoring. > > Patch 4 is v2's patch 3, and addresses review comments about C++ style > comments, getting a TRAP_PERF definition into the test, and unnecessary > NULL checks. Acked-by: Namhyung Kim Thanks, Namhyung > > [0] https://rr-project.org/ > [1] Various optimizations exist to skip as much as execution as possible > before setting a breakpoint, and to determine a set of program state that > is practical to check and verify. > >