From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E68C433DB for ; Tue, 23 Feb 2021 17:17:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21A6F64E85 for ; Tue, 23 Feb 2021 17:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233116AbhBWRRO (ORCPT ); Tue, 23 Feb 2021 12:17:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233640AbhBWRRN (ORCPT ); Tue, 23 Feb 2021 12:17:13 -0500 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E48C061786 for ; Tue, 23 Feb 2021 09:16:33 -0800 (PST) Received: by mail-ot1-x335.google.com with SMTP id s107so16313441otb.8 for ; Tue, 23 Feb 2021 09:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Y/7lyBIawgXVibPEQjRnIJxZC4/J4mTsACbEERnxYDg=; b=mRjlqnBTeAG3y2s8FAauHnaH1SamsOPskLA8yoP4qMATNnDLnjombF0ueoOHemI4v+ ON6jLAZhOorVDCKlKeVaclVW9ax1Wykz+j252M1N70rI88dT8+/ddGZqMupFk8ePUsvK lR4xLAbwYMFT1IC4bvpofpMVF0Gyw4e25Mcw1bCWYrZ7TrIvqotBPjioRqMac5HIgLYa XYfi7UxAvEjWctj8pwgTeUIb+FgkAKDx3VBwjigk5C2ZNvZd5+QhbZQoHnNks7gY3H+l VwJXfx7Fo2e8npir946O3k87wAW02SzO5wtDlyBr5gc6B5JV4UqSIR3Y9/ZCsk3rsY7Q MPSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Y/7lyBIawgXVibPEQjRnIJxZC4/J4mTsACbEERnxYDg=; b=JtcNAEKzb1d5pmL3iNjtEPHtSKZ/eQPrveOOQmYIn80PLLFk2wGNvk/j3QSgTaOC0u TXPyD6jYbyKgjLc85KIuin89louQYjDF1Ui0XnS0RkPC1V4t42fubgJQbQvTlRSewC0b SlfSgmcvYyo3ER6p1QStqN3JOlexCmFfo4rfjS/E7UF7zaYDUC7dHjvdIV7aUB+Inxot lVD1H6MMoummyal5kkCHi0C3WAyQSTGTYkWTPq0gR7YGqV507AnnMEFApwliE6OEBjtU 9BJ2i2QU2ZYPlYQi+y3gw4+GKRopGdxt5nsXyT9jYsplMnYzRq2Ybtri+8NGhVQvB02I Hpyg== X-Gm-Message-State: AOAM533fkC1wIIW1eQhIGkCQdL06BAgT/gFKZg+nZYuCehXrdiF5AXYR glgXpxIxgqEQFZJQbwZr2JKU6ev3AVey8kBbzmridA== X-Google-Smtp-Source: ABdhPJw2zJQHH6G+SOVfrrWuVDvoFs3AyTMegDYPDbhen+c9h8Rqfm/XJ8UoE2cbXebtHnL9Z/5RERNNXFBoFBXyXaU= X-Received: by 2002:a05:6830:1552:: with SMTP id l18mr21502367otp.233.1614100592568; Tue, 23 Feb 2021 09:16:32 -0800 (PST) MIME-Version: 1.0 References: <20210223143426.2412737-1-elver@google.com> <20210223143426.2412737-5-elver@google.com> In-Reply-To: From: Marco Elver Date: Tue, 23 Feb 2021 18:16:20 +0100 Message-ID: Subject: Re: [PATCH RFC 4/4] perf/core: Add breakpoint information to siginfo on SIGTRAP To: Dmitry Vyukov Cc: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Ingo Molnar , Jiri Olsa , Mark Rutland , Namhyung Kim , Thomas Gleixner , Alexander Potapenko , Al Viro , Arnd Bergmann , Christian Brauner , Jann Horn , Jens Axboe , Matt Morehouse , Peter Collingbourne , Ian Rogers , kasan-dev , linux-arch , linux-fsdevel , LKML , linux-m68k@lists.linux-m68k.org, "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, 23 Feb 2021 at 16:16, Dmitry Vyukov wrote: > > On Tue, Feb 23, 2021 at 4:10 PM 'Marco Elver' via kasan-dev > wrote: > > > > Encode information from breakpoint attributes into siginfo_t, which > > > > helps disambiguate which breakpoint fired. > > > > > > > > Note, providing the event fd may be unreliable, since the event may have > > > > been modified (via PERF_EVENT_IOC_MODIFY_ATTRIBUTES) between the event > > > > triggering and the signal being delivered to user space. > > > > > > > > Signed-off-by: Marco Elver > > > > --- > > > > kernel/events/core.c | 11 +++++++++++ > > > > 1 file changed, 11 insertions(+) > > > > > > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > > > index 8718763045fd..d7908322d796 100644 > > > > --- a/kernel/events/core.c > > > > +++ b/kernel/events/core.c > > > > @@ -6296,6 +6296,17 @@ static void perf_sigtrap(struct perf_event *event) > > > > info.si_signo = SIGTRAP; > > > > info.si_code = TRAP_PERF; > > > > info.si_errno = event->attr.type; > > > > + > > > > + switch (event->attr.type) { > > > > + case PERF_TYPE_BREAKPOINT: > > > > + info.si_addr = (void *)(unsigned long)event->attr.bp_addr; > > > > + info.si_perf = (event->attr.bp_len << 16) | (u64)event->attr.bp_type; > > > > + break; > > > > + default: > > > > + /* No additional info set. */ > > > > > > Should we prohibit using attr.sigtrap for !PERF_TYPE_BREAKPOINT if we > > > don't know what info to pass yet? > > > > I don't think it's necessary. This way, by default we get support for > > other perf events. If user space observes si_perf==0, then there's no > > information available. That would require that any event type that > > sets si_perf in future, must ensure that it sets si_perf!=0. > > > > I can add a comment to document the requirement here (and user space > > facing documentation should get a copy of how the info is encoded, > > too). > > > > Alternatively, we could set si_errno to 0 if no info is available, at > > the cost of losing the type information for events not explicitly > > listed here. Note that PERF_TYPE_HARDWARE == 0, so setting si_errno to 0 does not work. Which leaves us with: 1. Ensure si_perf==0 (or some other magic value) if no info is available and !=0 otherwise. 2. Return error for events where we do not officially support requesting sigtrap. I'm currently leaning towards (1). > > What do you prefer? > > Ah, I see. > Let's wait for the opinions of other people. There are a number of > options for how to approach this.