From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EBB51C4345F for ; Wed, 24 Apr 2024 14:12:05 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IUYenDpSjPeF4cInQnIR/FMBuHkIjxn4g+DtTYt9KNQ=; b=2b8fvnfbzuSI8t IQc7VAREeghzrn7dh/JJxJwqldzM8FLwzh49QiPLjf+NmGCsb7CC/AnIzw79eBT2n8WcrfE163HwV jQ2T6/FRkxOjOrDJZCeu2NrOWcNIwHRdGF0EGnEmuBILJ69VoF+iofsFZyhJorSB55PrBgAfi1iAJ 9eNcmGQWSzdwcAbGGb14FJJKSaTrBNf0iK+24afp+Dtlq9T4LGWey7fJ5frgJIykekJHjNNzPPNn9 8s41MbEihwylu+6qo8GObbN9AgtKuut4ecdgMaIYkzkHDSjGSJtvlipjvJtIDD9qmVsvS6At9hlkY CG7mYTojG0xW4gc5c6KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzdLl-00000004QXu-1ltD; Wed, 24 Apr 2024 14:11:53 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzdLh-00000004QVh-22Yy for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2024 14:11:52 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f0b9f943cbso4794842b3a.0 for ; Wed, 24 Apr 2024 07:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713967907; x=1714572707; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=HfiemKXJi5pMLJ2Wia9A+4BjCX44VO8MUqVuxnh0Agc=; b=D8ypAGGK2pVqcefZWXNN0H/JHj0r84mb7HMCst1oyepnqIplpaoGv7zcsLULavd1lw 2uM3oGJkXwrpZ/941kLarsnWINIekeiiLTuUcBghDvZmEg1RxPehLEf+fInobnWiCRbE LaWqPBw8KTLsyw96xoAZysLF4WsjmRfYjlHnnHJgTVb7UHfMsk5HxXaMAoeqSgsBQh6N 5ppm5pIR9TFqBAxE16l7+XlBCQa9veD6x/PYaGnNndINEVdLnVcWDTG1yU1KDxjyT0SO OOdYFDaUe9TZ1tuNQnvP9h1oZbsW/2m2cr7qNzg6QX1+Wp7KYFIri0ld16XESqLZIhki TNfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713967907; x=1714572707; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HfiemKXJi5pMLJ2Wia9A+4BjCX44VO8MUqVuxnh0Agc=; b=xOv9rJEBTqEGw7LDUeHfNLxVDsdhpj4GYP1/dDtCpIRvbHy37EjBnPwW9rrZS3XZc/ jMezq9RsuqsizXdQcsHZfMI4VYCqWB4t50eZMZ2Ae5W2ZMBY9RTN3pYAgWsXgNwOBkJz KJlossqwUHsJZy/tuY4eoyGlLTMnyLX7LPXDUXuU1x8eNnxg98uY0PCy+xLuLfd3PNVV 8sM4BWRteMwoGVc8k0XoWQ7jQQkh+IBZicryYLa/FbjRgsttIeByhGZZQwmnxKRflYOz A9+zy6Kr2L+G1t8EliCaiK1LD09YumFtjV+OLH19VpSZJDPui8Mx0JYqw9bOVuSzoy6b v9Wg== X-Forwarded-Encrypted: i=1; AJvYcCX0qHqhDeTRqk7ZjUr54UBSjRCPHA/RU3+ezDa6bgrp5MzttK6zHFF+FTL0xbPDTHFQd9l0dpkLi9GQxF0bfhwVI54qJobGUdziLxRHZwkXAQmJE+0= X-Gm-Message-State: AOJu0YzRp0YrfbVxP5NOdUFOiGvlhWCLbhM164mzDsptxrvupfKFoNFS IA3cWxDQankB8cQP404oJ/0GU9uxCezQHjfdqkBdrHPiw1q1XHtL X-Google-Smtp-Source: AGHT+IHJqBTsTkgXThBpzfpF1ZxOx7yc0dvsL7kplUOYeaVjzM0pjuiOIITL51O96TsfF/Dn1ssn1g== X-Received: by 2002:a05:6a21:4988:b0:1a7:a3ba:4252 with SMTP id ax8-20020a056a21498800b001a7a3ba4252mr2452448pzc.31.1713967906724; Wed, 24 Apr 2024 07:11:46 -0700 (PDT) Received: from localhost ([36.155.101.137]) by smtp.gmail.com with ESMTPSA id fr9-20020a056a00810900b006ea8cc9250bsm11473122pfb.44.2024.04.24.07.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 07:11:46 -0700 (PDT) From: chenqiwu X-Google-Original-From: chenqiwu Date: Wed, 24 Apr 2024 22:11:35 +0800 To: Will Deacon Cc: chenqiwu , catalin.marinas@arm.com, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, kaleshsingh@google.com, ardb@kernel.org, alexander.shishkin@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Subject: Re: [RESEND v3] arm64: Add USER_STACKTRACE support Message-ID: <20240424141135.GA3664@rlk> References: <20231219022229.10230-1-qiwu.chen@transsion.com> <20240419130921.GA3148@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240419130921.GA3148@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240424_071149_614334_12CFB2D4 X-CRM114-Status: GOOD ( 25.69 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 19, 2024 at 02:09:21PM +0100, Will Deacon wrote: > On Tue, Dec 19, 2023 at 10:22:29AM +0800, chenqiwu wrote: > > Currently, userstacktrace is unsupported for ftrace and uprobe > > tracers on arm64. This patch uses the perf_callchain_user() code > > as blueprint to implement the arch_stack_walk_user() which add > > userstacktrace support on arm64. > > Meanwhile, we can use arch_stack_walk_user() to simplify the > > implementation of perf_callchain_user(). > > This patch is tested pass with ftrace, uprobe and perf tracers > > profiling userstacktrace cases. > > > > changes in v3: > > - update perf_callchain_user() to use arch_stack_walk_user() > > and delete the redundant code as Mark's suggestion in v2. > > - update the commit message. > > > > Tested-by: chenqiwu > > Signed-off-by: chenqiwu > > --- > > arch/arm64/Kconfig | 1 + > > arch/arm64/kernel/perf_callchain.c | 118 +--------------------------- > > arch/arm64/kernel/stacktrace.c | 120 +++++++++++++++++++++++++++++ > > 3 files changed, 125 insertions(+), 114 deletions(-) > > This mostly looks good to me, with one potential issue: > > > @@ -107,35 +25,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, > > return; > > } > > > > - perf_callchain_store(entry, regs->pc); > > - > > - if (!compat_user_mode(regs)) { > > - /* AARCH64 mode */ > > - struct frame_tail __user *tail; > > - > > - tail = (struct frame_tail __user *)regs->regs[29]; > > - > > - while (entry->nr < entry->max_stack && > > The old code is checking entry->nr against entry->max_stack here... > > > +void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, > > + const struct pt_regs *regs) > > +{ > > + if (!consume_entry(cookie, regs->pc)) > > + return; > > + > > + if (!compat_user_mode(regs)) { > > + /* AARCH64 mode */ > > + struct frame_tail __user *tail; > > + > > + tail = (struct frame_tail __user *)regs->regs[29]; > > + while (tail && !((unsigned long)tail & 0x7)) > > + tail = unwind_user_frame(tail, cookie, consume_entry); > > ... but it looks like you've dropped that with the rework. Why is that ok? > It's no necessary to check entry->nr in arch_stack_walk_user(), because the caller function stack_trace_save_user() registers the consume_entry callback for saving user stack traces into a storage array, checking entry->nr against entry->max_stack is put into stack_trace_consume_entry(). Qiwu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel