Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4806794pxb; Thu, 14 Oct 2021 12:20:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkknltxq5qbYrqohsLwBJ63hkb51GxeSv7pI3uF2VvMnIFgi3QQgxgH6KLe0urnqz6KYfa X-Received: by 2002:a17:902:b694:b0:138:a031:610d with SMTP id c20-20020a170902b69400b00138a031610dmr6873573pls.36.1634239222516; Thu, 14 Oct 2021 12:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634239222; cv=none; d=google.com; s=arc-20160816; b=uS+JGomP64PiwvN4QPI/60E1fPkpD/g+oLjF6p3prf2kaQifRZuC24ZiXPiajKSCoy w47srh8KaNuyA5Ye6POADeYUFHGTsdp+BAQE9zHwEKuu59FE0/x6+0V5G2t6QgQWRuq6 mTzOhHAN4ZvNKF5qzle4hbqfAUyVuK8JOwEorfPEmNGU2V0Ja/uNeXDAtqFfYQWxcHJb MlUVR9P8ws+L64HZTP0/0NUyC7ntYKudf3crDlyR4Ir1M0XWcw2BgvaNTyEM1nCpTfZq UK2WKNM93D5sKr2EQnZ5BdkQlXNCzs82dwPSh3y+ZBPEfynaHcQrmTT0j6qNTPKcElLI /nvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=6tRgmoirvKUwWenWyNp7uYgpREKEEcmcFrQYFuifZpw=; b=pDH/MaNzbFje/uH+PVfQigbN13FTsLaQTwPD0bhpgDNWOT1oCjE9y87TfFQ1SEl+6h hIIReXf3r3X//P+Yg0aOQbPzHkR7EREXaK4dqNLZm/aS/Sy8mo98O0YN6aisFoPNV97r NT/A3SmEIOsZDdBc/hTUol2OHpnFA7GMJd5X60HVxh0stNTq0yBJj9rzD8DFN9SQG8I9 n5LgEy1aeBPDf8K3ODRrwQ1e9ac0+N5XC6+65koR0n303ruEq9pTcnuEyTrcTLDhP9Ie 3Aiv0+vFofiErsL+Gr8uUkrslFWyENGbsWvL+V+nCPI7/nZS76s5BQkh8GOd0QGo6lsd RRjA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oc4si16854935pjb.38.2021.10.14.12.20.10; Thu, 14 Oct 2021 12:20:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233806AbhJNSFX (ORCPT + 99 others); Thu, 14 Oct 2021 14:05:23 -0400 Received: from foss.arm.com ([217.140.110.172]:58496 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233786AbhJNSFW (ORCPT ); Thu, 14 Oct 2021 14:05:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BE4051480; Thu, 14 Oct 2021 11:03:15 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9CFD13F66F; Thu, 14 Oct 2021 11:03:09 -0700 (PDT) Date: Thu, 14 Oct 2021 19:03:07 +0100 From: Mark Rutland To: Peter Zijlstra Cc: keescook@chromium.org, jannh@google.com, linux-kernel@vger.kernel.org, vcaputo@pengaru.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, akpm@linux-foundation.org, christian.brauner@ubuntu.com, amistry@google.com, Kenta.Tada@sony.com, legion@kernel.org, michael.weiss@aisec.fraunhofer.de, mhocko@suse.com, deller@gmx.de, zhengqi.arch@bytedance.com, me@tobin.cc, tycho@tycho.pizza, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, axboe@kernel.dk, metze@samba.org, laijs@linux.alibaba.com, luto@kernel.org, dave.hansen@linux.intel.com, ebiederm@xmission.com, ohoono.kwon@samsung.com, kaleshsingh@google.com, yifeifz2@illinois.edu, jpoimboe@redhat.com, linux-hardening@vger.kernel.org, linux-arch@vger.kernel.org, vgupta@kernel.org, linux@armlinux.org.uk, will@kernel.org, guoren@kernel.org, bcain@codeaurora.org, monstr@monstr.eu, tsbogend@alpha.franken.de, nickhu@andestech.com, jonas@southpole.se, mpe@ellerman.id.au, paul.walmsley@sifive.com, hca@linux.ibm.com, ysato@users.sourceforge.jp, davem@davemloft.net, chris@zankel.net Subject: Re: [PATCH 6/7] arch: __get_wchan || STACKTRACE_SUPPORT Message-ID: <20211014180307.GB39276@lakrids.cambridge.arm.com> References: <20211008111527.438276127@infradead.org> <20211008111626.392918519@infradead.org> <20211008124052.GA976@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 08, 2021 at 03:45:59PM +0200, Peter Zijlstra wrote: > On Fri, Oct 08, 2021 at 01:40:52PM +0100, Mark Rutland wrote: > > [Adding Josh, since there might be a concern here from a livepatch pov] > > > > > > +static unsigned long __get_wchan(struct task_struct *p) > > > +{ > > > + unsigned long entry = 0; > > > + > > > + stack_trace_save_tsk(p, &entry, 1, 0); > > > > This assumes stack_trace_save_tsk() will skip sched functions, but I > > don't think that's ever been a requirement? It's certinaly not > > documented anywhere that I could find, and arm64 doesn't do so today, > > and this patch causes wchan to just log `__switch_to` for everything. > > Confused, arm64 has arch_stack_walk() and should thus use > kernel/stacktrace.c's stack_trace_consume_entry_nosched. Looking at this arm64's *current* get_wchan() unwinds once before checking in_sched_functions(), so it skips __switch_to(). As of this patch, we check in_sched_functions() first, which stops the unwind immediately as __switch_to() isn't marked as __sched. I think x86 gets away with this because switch_to() is asm, and that tail-calls __switch_to() when returning. Does switch_to() and below need to be marked __sched? Thanks, Mark.