Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1708804imm; Wed, 16 May 2018 01:42:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqAdtc03RsjsPlxBKnKb1WDD8ioI9amfvnFqYoDGh8k2PpvsyA5Ca1BR6If/wv9T1Br/IfR X-Received: by 2002:a17:902:6113:: with SMTP id t19-v6mr17864332plj.372.1526460174437; Wed, 16 May 2018 01:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526460174; cv=none; d=google.com; s=arc-20160816; b=wZmzpLv/wDcYq1mhaO086WgFB0om2oJwgS1+6wOMp92FGMGAh7tVmASEaxgJG2Doew F7z65xKTRg2uYJQ0MIlqodAY5HW39B3gPvjiGRQUzO0fuC/c8Ff0hKUG9pOQ9r7SiRDi BDsqvkhTNU1MLyS1H4OihkSJA9xDTYA/2KMgOLe6UFvW53hTTgRrF0SRlGSlRxGOLvP2 O213m7HvxiH893v4xgbBINWS8Sz3ymPH0Za/YzXc87L1WfIP8FRg1SJA0FWa+RTsO/g8 5ILgzdVWvZSITk9j33bseWKRUQcWu+0duJrvm9FwcEdlbka41KURsMxyeOwZyHlUb4K+ 9uEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=wyzIBJdZ0ZreXGMZxvvDRgivRwZqnCY4qxHNmuMheGM=; b=wi7iGcjk+KpjQL/SWPKlNS10CQHqnGjGhUyNTYSqwY3nGnlAvo9VKZkhC1a1uU/jHM 24c0RJw8wYso2T8AMKVNlTbJUkAKIJu6oROcd8rNKOcykKi52xF1G3OnZfu39thkfN4X YiZH3+77O6H4E0f+2kOMAZmP/B3/B7O3zsbmZdsjP1mYe/V0j9hf0y44Fj9psUunP7yp ctNJWBV409ZDW9ljd3qbp0V5a3Q7FAa3CLK4b6zNEGjxYZxHEAnf+QKEQQoEy86Lm2u2 YfzF4tBO9utuvOny+1pvYuxftstIJXxbcrNnEPA3OcCH8lmb576O5+UJcjrUXGqAZ9wf tMAQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14-v6si2165323pfa.296.2018.05.16.01.42.39; Wed, 16 May 2018 01:42:54 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752443AbeEPIm3 (ORCPT + 99 others); Wed, 16 May 2018 04:42:29 -0400 Received: from mga06.intel.com ([134.134.136.31]:57139 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbeEPIm0 (ORCPT ); Wed, 16 May 2018 04:42:26 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2018 01:42:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,404,1520924400"; d="scan'208";a="56333330" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 16 May 2018 01:42:26 -0700 Received: from [10.125.252.219] (abudanko-mobl.ccr.corp.intel.com [10.125.252.219]) by linux.intel.com (Postfix) with ESMTP id 9CD27580396; Wed, 16 May 2018 01:42:23 -0700 (PDT) Subject: Re: [PATCH v2]: perf/x86: store user space frame-pointer value on a sample To: Andy Lutomirski Cc: Peter Zijlstra , Andy Lutomirski , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , linux-kernel , linux-perf-users@vger.kernel.org References: <31205dc8-b756-e12b-0249-2ed06c2db9c9@linux.intel.com> <20180509145436.GV12217@hirez.programming.kicks-ass.net> From: Alexey Budankov Message-ID: <15a49a1c-01de-b904-a98b-ecced01b8ddb@linux.intel.com> Date: Wed, 16 May 2018 11:42:18 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 15.05.2018 19:30, Andy Lutomirski wrote: > >> On May 15, 2018, at 1:08 AM, Alexey Budankov wrote: >> >> >> Hi Andy, >> >>> On 09.05.2018 17:54, Peter Zijlstra wrote: >>>> On Tue, May 08, 2018 at 06:21:36PM +0300, Alexey Budankov wrote: >>>> >>>> Store user space frame-pointer value (BP register) into Perf trace >>>> on a sample for a process so the value becomes available when >>>> unwinding call stacks for functions gaining event samples. >>>> >>>> Signed-off-by: Alexey Budankov >>>> --- >>>> arch/x86/kernel/perf_regs.c | 8 +++++++- >>>> 1 file changed, 7 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c >>>> index e47b2dbbdef3..8d68658eff7f 100644 >>>> --- a/arch/x86/kernel/perf_regs.c >>>> +++ b/arch/x86/kernel/perf_regs.c >>>> @@ -156,7 +156,13 @@ void perf_get_regs_user(struct perf_regs *regs_user, >>> >>> >>>> * Most system calls don't save these registers, don't report them. >>> >>> ^^^ that worries me and is the reason for the '-1's below. However I >>> think with all the PTI rework this might no longer be true. >>> >>> The Changelog needs to state that user_regs->bp is in fact valid and >>> ideally point to the commits that makes it so. Also this patch should >>> update that comment. >>> >>> Cc Andy who keeps better track of all that than me. >> >> Are there any thoughts so far? Feedback on the matter above is highly appreciated. > > Sorry, I missed this. Can you forward the original patch? I don’t have it. Store user space frame-pointer value (BP register) into Perf trace on a sample for a process so the value becomes available when unwinding call stacks for functions gaining event samples. Signed-off-by: Alexey Budankov --- arch/x86/kernel/perf_regs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c index e47b2dbbdef3..8d68658eff7f 100644 --- a/arch/x86/kernel/perf_regs.c +++ b/arch/x86/kernel/perf_regs.c @@ -156,7 +156,13 @@ void perf_get_regs_user(struct perf_regs *regs_user, * Most system calls don't save these registers, don't report them. */ regs_user_copy->bx = -1; - regs_user_copy->bp = -1; + /* + * Store user space frame-pointer value on sample + * to facilitate stack unwinding for cases when + * user space executable code has such support + * enabled at compile time; + */ + regs_user_copy->bp = user_regs->bp; regs_user_copy->r12 = -1; regs_user_copy->r13 = -1; regs_user_copy->r14 = -1; > These days, system calls should save all registers, but I’m not entirely sure I want to promise that they’ll continue to do so forever. >