Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4989534pxb; Thu, 14 Oct 2021 16:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3C5y4lRriEHbUrekh7k6D/CFoMyDAj7sIMd+4LaiHpCakwVrw/P6rSywisJlkbXd1m8Rm X-Received: by 2002:a50:fc17:: with SMTP id i23mr12544609edr.213.1634254337591; Thu, 14 Oct 2021 16:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634254337; cv=none; d=google.com; s=arc-20160816; b=Em/RseOeIOLGvbsl7TbuB1SrD+XGCJ2Bhg2/REdoOigykd7xybM4jqW9Q1dkQ6f9r8 WN6byTMrZ8ye6tWNamfe/U3peNgUX30t3yRMMLyL2Z2GXQpbKPPlJsjZfrwrq7ITG1uT scGf6y1ntu3yPDIuaLABqpg2km12jIl+x4juxSHpi4S6Lnn/5UDYeFVnL1P2RPhpG1sL ncrybvOMA4gxA7LIb/Gp7M9EJIjEe+khM9D0vLVkTHXFfXz90gxJgWH6rsJWhhiLT4TU uiM5D0Np2H+w4ifqo8fZrofBRbLlXhbipKJXb30I60zRP8ze/2dihOSZ5uRemvnb6+ph KScg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=390oXOAx8xu4/KUEBxfvh8/zjlryT8/NcisAwMW9dms=; b=MK2W0PVODZvOgd74IuX/efnMzoPkNUx/CJvL4qqVwLdan1rim6btuJX7PBmmeLPQgT ufD5A27Ch8+EkwAzEL3ecK14T9pXiSy84qRqYlTv/rPEuUM8lMXC4Wj3Jbj4KIasyPmP sR8xQCNWj86sRqBZovoCUFb/qkYFaxGBXCBeJLeO94PMOppe0r+4eD6I67YI86nevkMU ShnQZtu842Y8qeWE0UyZTtHQL+ULyMkHKOiLrKXXcNMbp+nbhzVHpAMYBMg0ojB79Bn2 hV69i/f/zNEjzfAq1Qw+MCODdXYxbBDkg8mPm1HUTL5bM3NyLDywnex17+dpICCLGWhs +Ytw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="WuBYlt/6"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hk18si5909160ejb.238.2021.10.14.16.31.51; Thu, 14 Oct 2021 16:32:17 -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=@redhat.com header.s=mimecast20190719 header.b="WuBYlt/6"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231536AbhJNSuj (ORCPT + 99 others); Thu, 14 Oct 2021 14:50:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30545 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbhJNSui (ORCPT ); Thu, 14 Oct 2021 14:50:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634237313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=390oXOAx8xu4/KUEBxfvh8/zjlryT8/NcisAwMW9dms=; b=WuBYlt/662IpK7uaqwDY7VQv206ZcXFQxMV3GNt0XtEBqZ6OPalY+ATf6UxAQzAC/BiD/q zwfisfviQdRqM0GUGfJxUV4v+rRpiZg2jMP6lxCC2C4MvVhU16+zb3NW1qmNdDOCNCjV9p AgL1Zf7aIWquWCSdmSEpImpz6ZiY1gY= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-XSB9vOf8MGKsA5-mv0P-vA-1; Thu, 14 Oct 2021 14:48:32 -0400 X-MC-Unique: XSB9vOf8MGKsA5-mv0P-vA-1 Received: by mail-qt1-f199.google.com with SMTP id 12-20020aed208c000000b002a78b33ad97so5096450qtb.23 for ; Thu, 14 Oct 2021 11:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=390oXOAx8xu4/KUEBxfvh8/zjlryT8/NcisAwMW9dms=; b=1F5NGQUEtIBdn7dyHDKu40AZKhn0RSKyJxmXWTvZ9qobv8HVnCiuQ/UTBakWb3g+kM pnMgS9EFVdi2rtaY0muwtjs0LZgL6c57DPp7Mzy/3CPSqVSu19jU+ejICDst/bd4stKz mmrq0JFZv+vRuoqd7rRiLdOkXONrXSJAFqxX4A4LjQgc/ytToFE/OK60aWuHobnR07We 7Oa6WRlroOtYQd3Y+K5unwcP0P8vDQsHFuRhkDpFrygZmruOmzbZ76orjPw2LKV/HgQ2 pUGaPnX6uJbD7X+mjh9lXG/IxALV7k2SwM6xdxfgRphEy5P1m1EgIRAvIN2s9qSni6pJ H3+g== X-Gm-Message-State: AOAM531bUnZtQEHdNvBeQzzvF4YIcPAtudwkinkOU7COp6n2dO9ToVEA NkqTqzEfNIgfs+8YBguXPZEPH3f2TFMdJQHAR97s1PNyKG58bqIkHEMh9wx5TUTKGcEAOhQwISm zZp+9L4qEcKyZ+rGmh+hTMZeV X-Received: by 2002:a37:c90:: with SMTP id 138mr6072543qkm.255.1634237311718; Thu, 14 Oct 2021 11:48:31 -0700 (PDT) X-Received: by 2002:a37:c90:: with SMTP id 138mr6072528qkm.255.1634237311500; Thu, 14 Oct 2021 11:48:31 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::15]) by smtp.gmail.com with ESMTPSA id g5sm1601735qkm.112.2021.10.14.11.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 11:48:31 -0700 (PDT) Date: Thu, 14 Oct 2021 11:48:25 -0700 From: Josh Poimboeuf To: Mark Rutland Cc: Peter Zijlstra , 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, 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: <20211014184825.2vre4bt3fojcfdka@treble> References: <20211008111527.438276127@infradead.org> <20211008111626.392918519@infradead.org> <20211008124052.GA976@C02TD0UTHF1T.local> <20211014180307.GB39276@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211014180307.GB39276@lakrids.cambridge.arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14, 2021 at 07:03:07PM +0100, Mark Rutland wrote: > 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? Yes, I would think so, for arches where they otherwise show up on the stacktrace. -- Josh