Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp503363imi; Fri, 22 Jul 2022 03:52:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1swrWrdBPfahF4sh7UIN92Q2nVkQpsZPFJgM/SQoWQKBnqaNizerRmgev58DHHHXGd9JF2D X-Received: by 2002:a05:6a00:e0e:b0:522:990c:ab60 with SMTP id bq14-20020a056a000e0e00b00522990cab60mr2999740pfb.8.1658487127147; Fri, 22 Jul 2022 03:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658487127; cv=none; d=google.com; s=arc-20160816; b=Tu3Q/P4gh8Tx+vlIXh4zQDOYD95rQnYpujCDOiIs+LhaB8cz3tDQ98IeMUMzUs6e6y TDQTsiRjepqFkwArHdtNzF8HxlqIzDN93cZaAyOjaJSljK9VK3SXZtenoPPqDHE40xcP PxHyjCzkBscAqdKcvZ02gCtW6Lg443pYw/CWVPSB2X1iMQ5IpldeF9I9H2TuAaQ1jdTu X8tK4Qw0DJsiOwubeK8+dE+o3ES67UqPYWpVVAj2yF+H6ojyK1j/GpBehdVSdueH1xO5 /4E15V+uVMY0omypBHA8mGoZhgNucgSi0fmvyZXXyOBmuZgomixuh5MSm8CKsliGhyqu SoQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eXqhKXWkyJJg9+g/9EohedHzzZKAjuqa2sFmi97JD9Y=; b=YC7ijg9KfzPzriVmh1kSEEfG5XVSERaLnp8EOfQSF5tgzuXyP3SHJ2f/NnGRzQ+Ozw +HoOS2j3PsLmVQ4jB8h+n+mdYay1P2vtnlsNsdYoS8380P4gHY01Cmf0fG1eS9hSP6Ll eszuqUoAWUd+5WH51LoIFCkbh5gnqOh6PAzRS5/vZ272OmkRaL4dM01ms3wWDdRLCjX+ lKC+hEotK1oYKR1rUU/p8mR+KcSx1J/IJ8GhuzRpG9K2Yx4yRs8NIieMU67nGqA2mTcF Gqs0rUigj4Hwqv25resdA2KhZJ/JD3uN3UKBCe1JjY9vwgcA5RoekAuwejSEOD+7tZ85 ZLZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pnVwjwP2; 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 h4-20020a654684000000b003c15242c486si5219256pgr.787.2022.07.22.03.51.52; Fri, 22 Jul 2022 03:52:07 -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=pnVwjwP2; 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 S235432AbiGVKcG (ORCPT + 99 others); Fri, 22 Jul 2022 06:32:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbiGVKcD (ORCPT ); Fri, 22 Jul 2022 06:32:03 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF3C2B5052 for ; Fri, 22 Jul 2022 03:32:00 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id j26so4962118lji.1 for ; Fri, 22 Jul 2022 03:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eXqhKXWkyJJg9+g/9EohedHzzZKAjuqa2sFmi97JD9Y=; b=pnVwjwP2epgqugyqrMAsXv6dkAFuOokeRTDVkC6DsP+qX0N8ti0lIHBdgoQII4uwjh t4naAikyweBC0my1Llr1nYwJ/BPKlspVAbhCwPoCgTMoNwdYypjKVxB+5z3pB//FCb5f Oz3YNzSdFiOyLnc8vSoS+c49UYoX4ct9rex+XVYZL+LGaQEQvsI0oqXiljUx4g/DUwP/ XQtr7ntRWMBZtOePBlbIMVp0Nv+RhfrAUWMSyNmcqPRQRLWPqncJJ1296PNqH2EkBNyF xW3C/bLFl6hSGtA+CmQiPZPhOfPQB/4FBfUufX51z8LjtLhFudukcFcWT4Vek59IOBwC jO3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eXqhKXWkyJJg9+g/9EohedHzzZKAjuqa2sFmi97JD9Y=; b=TNoqtICutqtMZpj4l8gYZqRjtEguMJT5vDAWsBxF1DVwajSnV1pgSwGiEMxSmPlg8Y xJSjHHWxM0yplHmKZvYfJutvC/7eYdk7fEZDUhXrRGSwb/3YNLPI/KYn1USJhTjz4gRi lt7AfTtmKaMg3hbOb/6zR2WjixPZKp82Qt1l1g5sfGrSttVaQ4lnne63IspZXoRNOZpf +FcrQVkzCvky/t11BErTOj0DJjlhkRDm9FysitB2OsY31Z3giaj20EjRVtecPziWIk0y B08TYatwzHRfGtvvwDuAhFc0KhDW05TzOQBCkdW4IXPtuCbpdtm90B2NS/FEICXWFhAg fgdQ== X-Gm-Message-State: AJIora9uO3hnsWACgBEWdp0oVYfiI1PCnZL34bUcz3itcGc79ZCF+AgW S2JJhS0NgG3C67jBe3amBk3AD7Vc9fIr8ZG2m5xpsQ== X-Received: by 2002:a05:651c:1310:b0:25d:efe5:109d with SMTP id u16-20020a05651c131000b0025defe5109dmr742781lja.465.1658485917645; Fri, 22 Jul 2022 03:31:57 -0700 (PDT) MIME-Version: 1.0 References: <20220704150514.48816-1-elver@google.com> <20220704150514.48816-2-elver@google.com> <20220722091044.GC18125@willie-the-truck> <20220722101053.GA18284@willie-the-truck> In-Reply-To: <20220722101053.GA18284@willie-the-truck> From: Dmitry Vyukov Date: Fri, 22 Jul 2022 12:31:45 +0200 Message-ID: Subject: Re: [PATCH v3 01/14] perf/hw_breakpoint: Add KUnit test for constraints accounting To: Will Deacon Cc: Mark Rutland , Marco Elver , Peter Zijlstra , Frederic Weisbecker , Ingo Molnar , Thomas Gleixner , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Fri, 22 Jul 2022 at 12:11, Will Deacon wrote: > > > > [adding Will] > > > > > > > > On Mon, Jul 04, 2022 at 05:05:01PM +0200, Marco Elver wrote: > > > > > Add KUnit test for hw_breakpoint constraints accounting, with various > > > > > interesting mixes of breakpoint targets (some care was taken to catch > > > > > interesting corner cases via bug-injection). > > > > > > > > > > The test cannot be built as a module because it requires access to > > > > > hw_breakpoint_slots(), which is not inlinable or exported on all > > > > > architectures. > > > > > > > > > > Signed-off-by: Marco Elver > > > > > > > > As mentioned on IRC, I'm seeing these tests fail on arm64 when applied atop > > > > v5.19-rc7: > > > > > > > > | TAP version 14 > > > > | 1..1 > > > > | # Subtest: hw_breakpoint > > > > | 1..9 > > > > | ok 1 - test_one_cpu > > > > | ok 2 - test_many_cpus > > > > | # test_one_task_on_all_cpus: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 3 - test_one_task_on_all_cpus > > > > | # test_two_tasks_on_all_cpus: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 4 - test_two_tasks_on_all_cpus > > > > | # test_one_task_on_one_cpu: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 5 - test_one_task_on_one_cpu > > > > | # test_one_task_mixed: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 6 - test_one_task_mixed > > > > | # test_two_tasks_on_one_cpu: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 7 - test_two_tasks_on_one_cpu > > > > | # test_two_tasks_on_one_all_cpus: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 8 - test_two_tasks_on_one_all_cpus > > > > | # test_task_on_all_and_one_cpu: ASSERTION FAILED at kernel/events/hw_breakpoint_test.c:70 > > > > | Expected IS_ERR(bp) to be false, but is true > > > > | not ok 9 - test_task_on_all_and_one_cpu > > > > | # hw_breakpoint: pass:2 fail:7 skip:0 total:9 > > > > | # Totals: pass:2 fail:7 skip:0 total:9 > > > > > > > > ... which seems to be becasue arm64 currently forbids per-task > > > > breakpoints/watchpoints in hw_breakpoint_arch_parse(), where we have: > > > > > > > > /* > > > > * Disallow per-task kernel breakpoints since these would > > > > * complicate the stepping code. > > > > */ > > > > if (hw->ctrl.privilege == AARCH64_BREAKPOINT_EL1 && bp->hw.target) > > > > return -EINVAL; > > > > > > > > ... which has been the case since day one in commit: > > > > > > > > 478fcb2cdb2351dc ("arm64: Debugging support") > > > > > > > > I'm not immediately sure what would be necessary to support per-task kernel > > > > breakpoints, but given a lot of that state is currently per-cpu, I imagine it's > > > > invasive. > > > > > > I would actually like to remove HW_BREAKPOINT completely for arm64 as it > > > doesn't really work and causes problems for other interfaces such as ptrace > > > and kgdb. > > > > Will it be a localized removal of code that will be easy to revert in > > future? Or will it touch lots of code here and there? > > Let's say we come up with a very important use case for HW_BREAKPOINT > > and will need to make it work on arm64 as well in future. > > My (rough) plan is to implement a lower-level abstraction for handling the > underlying hardware resources, so we can layer consumers on top of that > instead of funneling through hw_breakpoint. So if we figure out how to make > bits of hw_breakpoint work on arm64, then it should just go on top. > > The main pain point for hw_breakpoint is kernel-side {break,watch}points > and I think there are open design questions about how they should work > on arm64, particularly when considering the interaction with user > watchpoints triggering on uaccess routines and the possibility of hitting > a kernel watchpoint in irq context. I see. Our main interest would be break/watchpoints on user addresses firing from both user-space and kernel (uaccess), so at least on irqs.