Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2540280pxb; Tue, 23 Feb 2021 09:19:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfyACK48Xnj3QEggtNs5dQuZOijIxD8z8Zatt5eQo4udikJ0hUQtWtWH7PCOXGoi5fftTu X-Received: by 2002:a17:906:943:: with SMTP id j3mr9263434ejd.501.1614100758988; Tue, 23 Feb 2021 09:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614100758; cv=none; d=google.com; s=arc-20160816; b=svnb0zEiIXoMFRrPnv5gfWdCIWn+h2vWnXTtqRDTbwXG75krVqRlrGsd1ehKXEcM8Q XqTryEb5lh44Z3FBoeRuxgf9CR4oOU53Zq+pwtPM7J415XVs5I5pVBgiSpFVMUmC6kHa hmCosK49VHOQF++dDYz1xxlGn47tyTQdt17mk/zH8OJHaWrUlbnuh5OghjIcTR0ue3/7 ptCIh3QryCVrlciGRFN93TtzZzpITc7mV5imtzf6WG4s8/f2vA0RpeK9dmcRNPElCHca upsZYJbl05I1E1p4Z298QTgg7wFAKeAnBkMX8Qy2/lrOJirK85Wb725QqnK5MNXQM4Lb zReA== 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=Y/7lyBIawgXVibPEQjRnIJxZC4/J4mTsACbEERnxYDg=; b=dEbErursSxN+2GSbjfWzhv85vQSQCfuFwfMkxDyYxUR85Ym4xjR0HCgLxwSSfxZ1/N iCoDJW2v4mHhC4tdO+fX/DctGQ1LmzZ+qOG8fGENec31Pv8TvexiA68SHhO+BPGW7ZVK RQpWaabUxtqkxY+fF/V3vM19LdxIU35yBHdciToP3JojhLxGsh4h73g49wfuGcI7j8CU JEa2S+CKVoleQpKKQgaQiHFP9bb9+9wCL1Gre0F24D1BQCoc/M7tk+LGXzuAv2MFu5wc CU1YptdazmqRJpp/9Oo+8afejYyshmQhkUn5PbgP9LVOMQo2TZZF0QJbHkqZPp+KYZZl qK5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mRjlqnBT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si14977411ede.341.2021.02.23.09.18.54; Tue, 23 Feb 2021 09:19:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mRjlqnBT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233690AbhBWRRO (ORCPT + 99 others); Tue, 23 Feb 2021 12:17:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233061AbhBWRRN (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 5A1C3C061574 for ; Tue, 23 Feb 2021 09:16:33 -0800 (PST) Received: by mail-ot1-x335.google.com with SMTP id k13so5810523otn.13 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=lX1PRPUFAEloEx+tafMkacvP1xK54oN+uYuIci/8qYE925+U0Ea/+N8oNqe0fd8Stm womlekxQCcnvMhkWnt7Aa43XoYus5LV/N0Ea6fhf/KyIMcaKHKBk1XExdT/wO4ewMM/R uF/8gAY9M0Mz82D+x+j8XvqrB1r8Qopjv9dom3h/vl8UMORFVlWa1vPx1MM1wePkjfFO S4AzRrgdfZxKR2fXI0GStBXo+2rxnRyQ9IlWIYUmONmCnzCYnP9teIfQVysE/tD/gPL5 4OBtuiILDsjKO1IShc2FUuMtYbCOICiMHg5qzVkXH17fmZRiN7S6ghGvkZ19knHCrcif p5Ow== X-Gm-Message-State: AOAM530LNXCPqu5RCtscGc/RGkwe5SKbCmVwXyG7EVZ1E3rjgfaTGUAd AZ79CMvvzU8QBZnomULa8exogYlzrBxgQbmVzYp5hw== 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-kernel@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.