Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5059266ybi; Tue, 11 Jun 2019 18:23:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMUuPz4x/Zm3tmxbrB10ImoMb9ca4Vz5lB1Y5iwViJM09FK2kN8PoWxiIkxP3AFa1IekBI X-Received: by 2002:a63:2b8a:: with SMTP id r132mr22512372pgr.196.1560302629083; Tue, 11 Jun 2019 18:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560302629; cv=none; d=google.com; s=arc-20160816; b=VuWMpYuhSN++zU9kNYXyFzkLX/fVwl0e2i56vB3Knw6+hezyx1jUKeoaOR8DvYR+SH G3laC4xSLmjeBOZxSS8m+APvzHUv76K/C/OHC4EKSqP/AUHqV9YM9bcF+bhPWYNFENro S62okm+skyuyvFebWLowu/uDFJ6i14MSKuiJF49UljaeJtBQFxupw6PFssqtsgWGVgzg uvDxasl4IuaRAyFHfhFit14WUbDCK0L6z4EPG0QOwq3kwCYautLngw6GY+cvsoks/pqd 508wV5uGtpHDtb1Qg3/jVRvRQKzzT4rDL+n9woFJPKzC9Yy9qEDyC/CT4Z5F1IB11/mA gfjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=VQmP1C8T0FocZI/pU2CHnZHCYXw2HpIZpRuQIzyKLKM=; b=KL3WCeWOnEUzUPS64vV9egqO2FJ4he/0fcLQuPtApMBCFZmFakr2p6JDBUXsTFvHCK ZbouxFv0UXuGQLRLUDCvNlrclLNfFrd0jSJPnKxK01tDTY9sOG+C2f8bYehBljfeVTGo /D9aOxwh7pyQux+D+fFhzgEu80NMwm39SC6Z/t2F0Wq52gh2ZqTG9UI7XE5GtpqaOBzg ClRVFFCrgVivfrRKKR9pf7boUZHgJH7HmKPlgmcRLpdRnkUI9aSa6locYSyo4tQ0l1gF 5KWBIMxf+OwWXGHu+f5ib+ippzQue9NBxqCDDnqFN27FlS7oyKLjnu067hJ1qxn9XIOs DCnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a28si10279938pgb.594.2019.06.11.18.23.32; Tue, 11 Jun 2019 18:23:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406844AbfFKVDf (ORCPT + 99 others); Tue, 11 Jun 2019 17:03:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48482 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406793AbfFKVDf (ORCPT ); Tue, 11 Jun 2019 17:03:35 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FAC080F81; Tue, 11 Jun 2019 21:03:35 +0000 (UTC) Received: from treble (ovpn-121-161.rdu2.redhat.com [10.10.121.161]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B93A860BF1; Tue, 11 Jun 2019 21:03:33 +0000 (UTC) Date: Tue, 11 Jun 2019 16:03:26 -0500 From: Josh Poimboeuf To: Song Liu Cc: Kairui Song , Alexei Starovoitov , Peter Zijlstra , lkml , Kernel Team , Alexei Starovoitov , Daniel Borkmann , "bpf@vger.kernel.org" Subject: Re: Getting empty callchain from perf_callchain_kernel() Message-ID: <20190611210326.uebwhnesdjegyetv@treble> References: <20190523133253.tad6ywzzexks6hrp@treble> <20190523152413.m2pbnamihu3s2c5s@treble> <20190523172714.6fkzknfsuv2t44se@treble> <20190524232312.upjixcrnidlibikd@treble> <145B7F65-2E06-4266-A816-A3445FE47638@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <145B7F65-2E06-4266-A816-A3445FE47638@fb.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 11 Jun 2019 21:03:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 06, 2019 at 04:04:48PM +0000, Song Liu wrote: > Hi Josh, > > Have you got luck fixing the ORC side? Here's the ORC fix. It's needed in addition to the bpf frame pointer fix (the previous patch). I'll clean the patches up and post them soon. diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c index 33b66b5c5aec..a2337460b1a3 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -128,6 +128,16 @@ static struct orc_entry null_orc_entry = { .type = ORC_TYPE_CALL }; +/* Fake frame pointer entry -- used as a fallback for generated code */ +static struct orc_entry orc_fp_entry = { + .type = ORC_TYPE_CALL, + .sp_reg = ORC_REG_BP, + .sp_offset = 16, + .bp_reg = ORC_REG_PREV_SP, + .bp_offset = -16, + .end = 0, +}; + static struct orc_entry *orc_find(unsigned long ip) { static struct orc_entry *orc; @@ -392,8 +402,16 @@ bool unwind_next_frame(struct unwind_state *state) * calls and calls to noreturn functions. */ orc = orc_find(state->signal ? state->ip : state->ip - 1); - if (!orc) - goto err; + if (!orc) { + /* + * As a fallback, try to assume rbp is the frame pointer. This + * is useful for generated code like BPF. Since this is a + * guess, the rest of the unwind is no longer considered + * reliable. + */ + orc = &orc_fp_entry; + state->error = true; + } /* End-of-stack check for kernel threads: */ if (orc->sp_reg == ORC_REG_UNDEFINED) {