Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp437530pxa; Wed, 19 Aug 2020 05:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+m2bTRBMaQeaF5w1U6hOosNFm5p5wRQ+q+G/QQp+Lh7NbFqDLaaEa1Kr2sjE4koHtlJI9 X-Received: by 2002:a17:906:d282:: with SMTP id ay2mr23700669ejb.265.1597841481392; Wed, 19 Aug 2020 05:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597841481; cv=none; d=google.com; s=arc-20160816; b=d8uvds86RJQcWQ19Fl+qmgQ1simO6tIworOi3JsY00yHG80vjGOFyuqVcDmItq21Cl 1ImWVOf0v758cvrNfB4z3D7TrPgpOmKy48FzeuQWCIzlKkfD8juET+7fMSPdFLlJzMar LSTNBPsvlMcYWArOo9OnvxQ9aspPCChqgwswMKFo0BHhOOwHMdyAsaJ0lEBF5xl+XaQs 5lD6dAltxGfv+IjRzMu7ottKlqNtWQhAXTmBkMtO2vnVl22Gqc9Kqa+hJitEEVLDBy50 +NhJqtHjZRbmCG8ejjgpnolfkJUWCd70I5YYoQoEej4UnWUYA5Bgx6Sz/UnqEXHGIzML ANFw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lY/a7mtzZ/kDBh9cPH6vLSX7hTXPZl052GtqhdcIFzM=; b=KzP8nBHSo64mDYVkzLe4SAiKyqYFhXW8FPfAABmh6SIGT6lm1QTi/WAVi8sjIOTrlY lkrmPUViVHErvq991YnfIayatJq3jNUkS69aZsB3EzXa6g6qsj7CzdBTxRqmktHY5xs2 Z4IM6pxkbgE9QdqotP4IlzyXj4vD9UazkF8j89BcCF9XvwiSfetbG4fN/JK3wFHqENhp HpuXOqjPs4laeaZwrey0vwAohslF2jrU5rhBHw0rtjzgR7i5pzXl1y2R3vAiG+9snESv 0D8Kn+O+LApJkvKaCSgmvVGSveRF3ZhGeKh2zTDbxpETbbGAR2Q2wJl/UNcrVbx+osfF s6Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jCvFuqYG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de7si16760973edb.278.2020.08.19.05.50.57; Wed, 19 Aug 2020 05:51:21 -0700 (PDT) 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=@kernel.org header.s=default header.b=jCvFuqYG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728295AbgHSMuT (ORCPT + 99 others); Wed, 19 Aug 2020 08:50:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:36722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728361AbgHSMuJ (ORCPT ); Wed, 19 Aug 2020 08:50:09 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C48142072D; Wed, 19 Aug 2020 12:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597841408; bh=82c0M4r2v9vmu+J3LNGEZvNsiX4xegCRnclRjTkc4/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jCvFuqYGPhA5OkY9xU5vcakYoj7CV5UZ/02wgyzH3Y923BsCuIabyjusLnV8woih5 KdQHgWMzfE/56q/SNxxTz7WITLnqBAeao0ALlxRl5Gmys/ei8oXQJsOhQ21831/Z2C P3fQuv/Zav+3BQHatfh5/FNatgVdECK1JLUM0y7U= From: Mark Brown To: Catalin Marinas , Will Deacon , Vasily Gorbik , Heiko Carstens , Borislav Petkov , Thomas Gleixner , "H. Peter Anvin" Cc: Christian Borntraeger , Ingo Molnar , Jiri Slaby , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Miroslav Benes , Mark Brown Subject: [PATCH v2 2/3] arm64: stacktrace: Make stack walk callback consistent with generic code Date: Wed, 19 Aug 2020 13:49:12 +0100 Message-Id: <20200819124913.37261-3-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200819124913.37261-1-broonie@kernel.org> References: <20200819124913.37261-1-broonie@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As with the generic arch_stack_walk() code the arm64 stack walk code takes a callback that is called per stack frame. Currently the arm64 code always passes a struct stackframe to the callback and the generic code just passes the pc, however none of the users ever reference anything in the struct other than the pc value. The arm64 code also uses a return type of int while the generic code uses a return type of bool though in both cases the return value is a boolean value. In order to reduce code duplication when arm64 is converted to use arch_stack_walk() change the signature of the arm64 specific callback to match that of the generic code. Signed-off-by: Mark Brown --- arch/arm64/include/asm/stacktrace.h | 2 +- arch/arm64/kernel/perf_callchain.c | 6 +++--- arch/arm64/kernel/return_address.c | 8 ++++---- arch/arm64/kernel/stacktrace.c | 11 +++++------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index fc7613023c19..eb29b1fe8255 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h @@ -63,7 +63,7 @@ struct stackframe { extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame); extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame, - int (*fn)(struct stackframe *, void *), void *data); + bool (*fn)(void *, unsigned long), void *data); extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, const char *loglvl); diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c index b0e03e052dd1..bd2a91bd9e9e 100644 --- a/arch/arm64/kernel/perf_callchain.c +++ b/arch/arm64/kernel/perf_callchain.c @@ -137,11 +137,11 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, * whist unwinding the stackframe and is like a subroutine return so we use * the PC. */ -static int callchain_trace(struct stackframe *frame, void *data) +static bool callchain_trace(void *data, unsigned long pc) { struct perf_callchain_entry_ctx *entry = data; - perf_callchain_store(entry, frame->pc); - return 0; + perf_callchain_store(entry, pc); + return false; } void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, diff --git a/arch/arm64/kernel/return_address.c b/arch/arm64/kernel/return_address.c index a5e8b3b9d798..6434427a827a 100644 --- a/arch/arm64/kernel/return_address.c +++ b/arch/arm64/kernel/return_address.c @@ -18,16 +18,16 @@ struct return_address_data { void *addr; }; -static int save_return_addr(struct stackframe *frame, void *d) +static bool save_return_addr(void *d, unsigned long pc) { struct return_address_data *data = d; if (!data->level) { - data->addr = (void *)frame->pc; - return 1; + data->addr = (void *)pc; + return true; } else { --data->level; - return 0; + return false; } } NOKPROBE_SYMBOL(save_return_addr); diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 2dd8e3b8b94b..743cf11fbfca 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -118,12 +118,12 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) NOKPROBE_SYMBOL(unwind_frame); void notrace walk_stackframe(struct task_struct *tsk, struct stackframe *frame, - int (*fn)(struct stackframe *, void *), void *data) + bool (*fn)(void *, unsigned long), void *data) { while (1) { int ret; - if (fn(frame, data)) + if (fn(data, frame->pc)) break; ret = unwind_frame(tsk, frame); if (ret < 0) @@ -139,17 +139,16 @@ struct stack_trace_data { unsigned int skip; }; -static int save_trace(struct stackframe *frame, void *d) +static bool save_trace(void *d, unsigned long addr) { struct stack_trace_data *data = d; struct stack_trace *trace = data->trace; - unsigned long addr = frame->pc; if (data->no_sched_functions && in_sched_functions(addr)) - return 0; + return false; if (data->skip) { data->skip--; - return 0; + return false; } trace->entries[trace->nr_entries++] = addr; -- 2.20.1