Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp281327ybv; Wed, 19 Feb 2020 21:30:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzIWbsU5WN4EqtZQF5eM6EryCRkaS59FXHTQ4K+ElPt+/i0JQoVe5e0xSBXUaxHNtwtCnkq X-Received: by 2002:a9d:7305:: with SMTP id e5mr21237514otk.64.1582176610928; Wed, 19 Feb 2020 21:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582176610; cv=none; d=google.com; s=arc-20160816; b=O50cuyxJsQWw+vryFqNzX8mFJ9oJpstPL/fYUjpN9EN8I9G+R37HZ341dzNlahzB8E CJfWg2HLcAXH7FIprfB0L+11Zotu9TUfvwhSXAlIgNYsBDJAn37lUsiJhP/9oukF+Kjg KIL5HSepQiEl4Zi/IcLW3O2ozlmZP4CdHkwj/C+AHR08imF72OCBZzrwIjMyj3ZNmcfC SobgEHuOtNUqX/bn5xXagwKvk5mRXqQPzqWtybRKLukG1DxWuZXe7je9HsJvTFSksGCl G2UfJwfF9iVeLg4FmLsNq41GfKCeMZr2nKd/OiudW3ELQqlHabJP/+r2DcJsDNtI4yO6 HNuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=3qk48O5iP5UI83BGLtFK/DPXjcS2SRQP8TVMgp2fJpo=; b=FR96ROaC9Aci1JEQ0lT7W2fjLONLOwhMgz4SZ00ug5EarGzDu4TtLVZT6uIdo9PeY3 SD8m6lUgexb3dX9AvEDAgU+p2Y2OT38mDSdhFCrQ+JKUzTOT5GRuV5l3WfNOnPPU3O/1 nmMXGRRJD8cUADE+tmP4zc3PsND3gBbsNy8CxWLcTvOy26lsS53j+dfN5nZWcoA+Ioma IsHx1vS9VwbK42+6rvshoTuMecfoz3ox2DR7HaM7mo1YeMrkaQxFgjPrYpYkFMo27HZ2 uVTMWt9XpNl5eWezUQYMHoUYzkk9yLpBEWauAa/sNuc0Ph9voinYOW9byc8NBkBsRkx1 X5sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bRhVmrGG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si1598805oix.12.2020.02.19.21.29.59; Wed, 19 Feb 2020 21:30:10 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=bRhVmrGG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbgBTF3J (ORCPT + 99 others); Thu, 20 Feb 2020 00:29:09 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39517 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgBTF3I (ORCPT ); Thu, 20 Feb 2020 00:29:08 -0500 Received: by mail-pl1-f196.google.com with SMTP id g6so1080514plp.6 for ; Wed, 19 Feb 2020 21:29:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3qk48O5iP5UI83BGLtFK/DPXjcS2SRQP8TVMgp2fJpo=; b=bRhVmrGGpBmtuhmW7mF9VhV7BpnN10S3RU3sTcIlAIM6YOGdKjZ3Muy0pfFZe2HjrE +ivyFn3B0QqL0Ol5NTaEMo8clTBpXV+uTp8jhp82ceKiaBLhs86pcSsLjIXMlQiYMOQn U7/pghcJB7bzkbFeytV2N+2VSre7MAF5HzQr4a9xJo8EdiiZV9e4SCRrsqsLuzX3baYS Sjr0EPpXA0sO0qCXUn903Cva3jEeYbKONPZfRXl24FlLLEG2TWe1L+i/JUlqlfkDfgcr AI/yVONdmuXUT8egRIDZyGN4l3PIV0VubOxrHCzNjswERFv82GKMpG494kJbaaCd4IbE 2WdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3qk48O5iP5UI83BGLtFK/DPXjcS2SRQP8TVMgp2fJpo=; b=P+Jhhp+TrvLRC27Q6VPpijkYGhS/777v/ugIHjcSzhqD42zvI+ls5RXKYQJQzwFYX6 yGR4q4T5pyr1vOLF61eCzvERfXLpBxAxJc2aPxlF7+ZHMcwSgFH6FdaA/Hmz8KUXOXHb 2HbixwIkjThLTjOdpGSr9wQCOg74Vc4dnlfiC+JsVLx40dSdfEJc2hPmrIZ53nVUTMa4 jj37NlI3CsZizbc9O/lNE3fpiYzOUeGp1saWbuoxlTHqMDBQDckU2I08ew2+QHcdg2Ap C95FZXiNZtioaTFaEF43UhxquUUkoKUalPMUfgwxbuvtohLUUbjrK0VcIMMNr1r4zMK7 7LdQ== X-Gm-Message-State: APjAAAWeP6T/2ieoSBU2y+PSWcGEu9kCU1f/YHnGHS/YwyBK0gBRqD0k 6xkF5/pHmla4O+UdMivDa46XVA== X-Received: by 2002:a17:902:b617:: with SMTP id b23mr30197151pls.285.1582176547616; Wed, 19 Feb 2020 21:29:07 -0800 (PST) Received: from localhost.localdomain (li1441-214.members.linode.com. [45.118.134.214]) by smtp.gmail.com with ESMTPSA id l69sm1535663pgd.1.2020.02.19.21.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 21:29:07 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mark Rutland , Mike Leach , Robert Walker , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML Cc: Leo Yan Subject: [PATCH v5 8/9] perf thread: Add helper to get top return address Date: Thu, 20 Feb 2020 13:27:00 +0800 Message-Id: <20200220052701.7754-9-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200220052701.7754-1-leo.yan@linaro.org> References: <20200220052701.7754-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the instruction emulation or single step in kernel, when return to the user space, the return address is not possible to be the same with the ret_addr in thread stack. This patch adds a helper to read out the top return address from thread stack, this can be used for specific calibration in up case. Signed-off-by: Leo Yan --- tools/perf/util/thread-stack.c | 10 ++++++++++ tools/perf/util/thread-stack.h | 1 + 2 files changed, 11 insertions(+) diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index 0885967d5bc3..60cd6fdca8de 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c @@ -497,6 +497,16 @@ void thread_stack__sample(struct thread *thread, int cpu, chain->nr = i; } +u64 thread_stack__get_top_ret_addr(struct thread *thread, int cpu) +{ + struct thread_stack *ts = thread__stack(thread, cpu); + + if (!ts || !ts->cnt) + return UINT64_MAX; + + return ts->stack[ts->cnt--].ret_addr; +} + struct call_return_processor * call_return_processor__new(int (*process)(struct call_return *cr, u64 *parent_db_id, void *data), void *data) diff --git a/tools/perf/util/thread-stack.h b/tools/perf/util/thread-stack.h index e1ec5a58f1b2..b9d07a3be6c2 100644 --- a/tools/perf/util/thread-stack.h +++ b/tools/perf/util/thread-stack.h @@ -88,6 +88,7 @@ void thread_stack__sample(struct thread *thread, int cpu, struct ip_callchain *c int thread_stack__flush(struct thread *thread); void thread_stack__free(struct thread *thread); size_t thread_stack__depth(struct thread *thread, int cpu); +u64 thread_stack__get_top_ret_addr(struct thread *thread, int cpu); struct call_return_processor * call_return_processor__new(int (*process)(struct call_return *cr, u64 *parent_db_id, void *data), -- 2.17.1