Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp701510rwb; Fri, 7 Oct 2022 03:04:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zmC4pA5xhMoskjoP3Ahj0/ynOd099EuUlPF3Bq/9QR8sWjuZ2LD+JRs4geHvn0JQDfsVu X-Received: by 2002:a17:90a:4ec6:b0:20a:96cd:2a46 with SMTP id v6-20020a17090a4ec600b0020a96cd2a46mr4607388pjl.171.1665137082862; Fri, 07 Oct 2022 03:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665137082; cv=none; d=google.com; s=arc-20160816; b=HHPCrPyY3ZMiGQ76FJw5hl49yC9zRAr54/FeLsVj+myKbQlcmBmOcECUb7tpJHNB7U wIFAvGswDCS8tOOluba5CZAstKqr6Kpp1tCRR3VYih9Ld3ysi4rlLwxknZ4dFDZKFdgZ vuvGH5DHfFViUY61uziRGCFVqeoK6jT2LycqBUgfMxXxH6tr9KCTfmc6oC8zoxXNcZDt qrhvUZN5kBrtY5qGN9+vBUPvUSx3fY5+tZu6Hr15BD/i5a13iAc5r1LzG424eXBvLpfH +NyBKoTq2HHw1v3rxnyAl5e5EEIqGGN+wr1t9e7nQAOD2FOVBvTupcgyqOjBUUD1bDeM sHJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=EQkrLmzT3Pvs6KFi5WAH9SS4PAeF6bOPV5uy+VMuFaU=; b=mXKUIl76a68F1G+mh4PYEjie4eM1rMslktQ+bPuDsVy6zO9fGBk7n/D8pyrbYjEY2t alACRQjMIAiS9MgxwE3m6bXtuLMzRWTB8NNFNIByMgrHljurvJqJ81xM8Lwh105B6Yom rbcxbzU2YYVF7t1OqeQdU70BRd8r86LEvZAZ0HWD3CuI+3M6QAMdd63VZb0QOMyGV6MJ 2doIMOcLCc+wu9ghFt1NxjWr0/2PBXlU7sFN/yVjOhOOI1DEm6f/VYkKJsiZybLwbdpJ pQU/+ZVEhzGF9TsNxSsbm5gcXCE07EWwbwgWI4224X9hmFJAzwpN4hDYUeDb/lNoJlZ6 M90A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=URWhMdnZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a170902e84d00b00174fd2df917si2119258plg.101.2022.10.07.03.03.59; Fri, 07 Oct 2022 03:04:42 -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=@gmail.com header.s=20210112 header.b=URWhMdnZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbiJGJpp (ORCPT + 99 others); Fri, 7 Oct 2022 05:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbiJGJpm (ORCPT ); Fri, 7 Oct 2022 05:45:42 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A3A148C9D; Fri, 7 Oct 2022 02:45:40 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id j7so6455666wrr.3; Fri, 07 Oct 2022 02:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=EQkrLmzT3Pvs6KFi5WAH9SS4PAeF6bOPV5uy+VMuFaU=; b=URWhMdnZurrj0JGkaHhZWS1Hb/wxi0oCu8/3WD0OIL65EtHWMnklxQ5XqxkIjTL/B5 N7xpNnpQ+M8rKHRQFHYb+paRvh0EyNlN4EEUzu9CCRmTeHiVRNU/OwCXr2YchUlcof3e fevesm1nDkiNOXckaZO9/J4RT0wSUXaEGoKREPrlJBPo0O8082l8MKf8Zb49/PjF2TCS m2snA09tMpIoKXLCQu7c9iuXj9PTan9gdlQ79UdkKAuaUxrqaxr1wDmC1s7cx7mgfsCY 9E5AIUFXpoRWDapYlzKFqxkuhPMThRplkkW2XHoJO+wUa9ssFtuP1EPwk82oxDc6HA2T jbBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EQkrLmzT3Pvs6KFi5WAH9SS4PAeF6bOPV5uy+VMuFaU=; b=UAzdWD32NFubJe0yYDj2QicvoB2ZVXHvTH0wudZZ2jj9avxgvad0yvgBbcrTLer4lC AAuiQMdEzxJnZdfR4iY95M7M9BBkYJfiY24FbyhcPt/0Kr8TKlBoor46s+ypuAHsr6nY KlH0bsDKBVeQCGJ1p4ULwM+YfxWVFE5XEasXvSjlqVKZu1gB8pmvzHO6o2/ku/KnrBww oDkr2KjSKPS7AaVGu7BzCB8gHCjtoEBr0XUt6MBw/sLGL22MrB/4w26yXi2a8vFp6YtP GHl69IrRDLkhPlsTZIyMPCiZUWqWsBh4rIwKR1yRAVahG9i9J/nMzc8eS902bILCp2lG vM6A== X-Gm-Message-State: ACrzQf1R9vDNsxdanz+m0how/d+oAnY69wL0UTdepOpqAkGUkspkufvl w2WDFiZlVXozPcwoUCWkoaY= X-Received: by 2002:adf:f90d:0:b0:20c:de32:4d35 with SMTP id b13-20020adff90d000000b0020cde324d35mr2603406wrr.583.1665135939037; Fri, 07 Oct 2022 02:45:39 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id j39-20020a05600c48a700b003a5537bb2besm1686541wmp.25.2022.10.07.02.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 02:45:38 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Fri, 7 Oct 2022 11:45:36 +0200 To: Sumanth Korikkar , peterz@infradead.org Cc: olsajiri@gmail.com, bpf@vger.kernel.org, gor@linux.ibm.com, hca@linux.ibm.com, iii@linux.ibm.com, linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org, namhyung@kernel.org, svens@linux.ibm.com, tip-bot2@linutronix.de, tmricht@linux.ibm.com, x86@kernel.org Subject: Re: [PATCH] bpf: fix sample_flags for bpf_perf_event_output Message-ID: References: <20221007081327.1047552-1-sumanthk@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221007081327.1047552-1-sumanthk@linux.ibm.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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, Oct 07, 2022 at 10:13:27AM +0200, Sumanth Korikkar wrote: > * Raw data is also filled by bpf_perf_event_output. > * Add sample_flags to indicate raw data. > * This eliminates the segfaults as shown below: > Run ./samples/bpf/trace_output > BUG pid 9 cookie 1001000000004 sized 4 > BUG pid 9 cookie 1001000000004 sized 4 > BUG pid 9 cookie 1001000000004 sized 4 > Segmentation fault (core dumped) > > Fixes: 838d9bb62d13 ("perf: Use sample_flags for raw_data") > Acked-by: Namhyung Kim > Signed-off-by: Sumanth Korikkar Acked-by: Jiri Olsa Peter, I think this should go through your tree again? bpf-next/master does not have sample_flags merged yet thanks, jirka > --- > kernel/trace/bpf_trace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index 49fb9ec8366d..1ed08967fb97 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -687,6 +687,7 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map, > > perf_sample_data_init(sd, 0, 0); > sd->raw = &raw; > + sd->sample_flags |= PERF_SAMPLE_RAW; > > err = __bpf_perf_event_output(regs, map, flags, sd); > > @@ -745,6 +746,7 @@ u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size, > perf_fetch_caller_regs(regs); > perf_sample_data_init(sd, 0, 0); > sd->raw = &raw; > + sd->sample_flags |= PERF_SAMPLE_RAW; > > ret = __bpf_perf_event_output(regs, map, flags, sd); > out: > -- > 2.36.1 >