From patchwork Fri Oct 15 02:58:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhavan T. Venkataraman" X-Patchwork-Id: 12559777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D433C433F5 for ; Fri, 15 Oct 2021 03:01:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C1B460F70 for ; Fri, 15 Oct 2021 03:01:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3C1B460F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=srCU7wspJ+yzFSWzkDJqtj29cveq25mGU2t283zUrWk=; b=QjamYQzqE3uoJz 68YtmTApATvCINUwurBN2zUUTUGLBHhviZ0/spVX0WIgLqrDjoVGy55FpTbOSVSuNoihfjvc/r5lR Ptn5EtI79F7dwYQdC0kjRyxWElXZObdDzLywWP7ImdRlsNPMEVYrSVsIs+uaAK0H2nn/XfvXS3XUv JY3Zp+XpETzubsH+CyOM/7KWgnWPpkwJ4+2ISiuc2J++CSvKjayrMGce+bobkivf0sG8xyos6kApB PrQLeq3zy9hJlIFQjka0vXBUcPzT2YHLnO1OZmgoBHw1GQdFDqDF6tbzxjYQ+SP35rw0JfoUCfYl6 DyIS8/Jmox7U1wLNH8NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbDRk-005Ccf-DX; Fri, 15 Oct 2021 02:59:48 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbDR4-005COr-LL for linux-arm-kernel@lists.infradead.org; Fri, 15 Oct 2021 02:59:08 +0000 Received: from x64host.home (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id 90ED620B9D1E; Thu, 14 Oct 2021 19:59:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 90ED620B9D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1634266746; bh=g5fdmzSduoUMkjQHmQa/fhtE8jC0SUmUZcxIW9qvvbk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lBvZQzvd1+eA5IQSDbS3fFDDPe+shGmQRIdrhpVc3ctrdoWHLDAQ6RHSe9A8Vc0yD R3rD66EQXo5BCyzisFaAz4KISEwSkC25Zj44GNND4JRihiKm2zDFwPem1hngXIzwB/ rVn3Bnq5tTi/W85c/yiOLDYczo7JQQPoZ7W0SW0A= From: madvenka@linux.microsoft.com To: mark.rutland@arm.com, broonie@kernel.org, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com Subject: [PATCH v10 03/11] arm64: Make get_wchan() use arch_stack_walk() Date: Thu, 14 Oct 2021 21:58:39 -0500 Message-Id: <20211015025847.17694-4-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015025847.17694-1-madvenka@linux.microsoft.com> References: <20211015025847.17694-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211014_195906_729745_1C2644C5 X-CRM114-Status: UNSURE ( 9.92 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Madhavan T. Venkataraman" Currently, get_wchan() in ARM64 code walks the stack using start_backtrace() and unwind_frame(). Make it use arch_stack_walk() instead. This makes maintenance easier. Signed-off-by: Madhavan T. Venkataraman --- arch/arm64/kernel/process.c | 38 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index c8989b999250..48ed89acce0d 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -544,11 +544,27 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, return last; } +struct wchan_info { + unsigned long pc; + int count; +}; + +static bool get_wchan_cb(void *arg, unsigned long pc) +{ + struct wchan_info *wchan_info = arg; + + if (!in_sched_functions(pc)) { + wchan_info->pc = pc; + return false; + } + return wchan_info->count++ < 16; +} + unsigned long get_wchan(struct task_struct *p) { - struct stackframe frame; - unsigned long stack_page, ret = 0; - int count = 0; + unsigned long stack_page; + struct wchan_info wchan_info; + if (!p || p == current || task_is_running(p)) return 0; @@ -556,20 +572,12 @@ unsigned long get_wchan(struct task_struct *p) if (!stack_page) return 0; - start_backtrace(&frame, thread_saved_fp(p), thread_saved_pc(p)); + wchan_info.pc = 0; + wchan_info.count = 0; + arch_stack_walk(get_wchan_cb, &wchan_info, p, NULL); - do { - if (unwind_frame(p, &frame)) - goto out; - if (!in_sched_functions(frame.pc)) { - ret = frame.pc; - goto out; - } - } while (count++ < 16); - -out: put_task_stack(p); - return ret; + return wchan_info.pc; } unsigned long arch_align_stack(unsigned long sp)