Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6572222ybi; Wed, 29 May 2019 09:40:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqw79rgRevN7QeE4Z74/BQAxJ3SVYg4RdvqgMTaQWtvah0WNBS/pX12JPbGUg+TYpXJcpOlg X-Received: by 2002:a62:5487:: with SMTP id i129mr147386387pfb.68.1559148050777; Wed, 29 May 2019 09:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559148050; cv=none; d=google.com; s=arc-20160816; b=dQL14bPpOcSWdwmxQE0GVKzhuk6qxlu9EDB/qhwmkf8Tgr6cUsxjsQ51lk2DSFSGlg nFIrZG7ys9uBcAlTweM1ApQjxmw58PMeMLaaoQfv+4sLQVO+bgRTDiIxHvVOAebuwmOQ k3AY1Me+e4HEOBziB/83Iwv8Sajyn82c5skT6k/BcnFzYKFMfnQa3xhjz6rfc4BV5iGg 9u26DPJJ/0y1flhs363+fyALCRNu9GAwUxqyh17bJTsJ60yKs5SZ8KZAopLpyTbMl1SM Gp42PMN6i/8LZ/OaPWGaOY0MsJDR//wgPXB6Y4+4sbCzsuS1povYDqA3v6wKsxUE6StV 8M7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=WWC9yUw8O0hkE0h0448LyX5updCLX3CZb3Gcs8uzs6Q=; b=Rn92JrOqvrJO0tVcdgJaqZIHD0yXF2jN4GsQIOGtt7YrSo8/ITPAZzAlos+u89ExPT O2H4SsxpBrWPayM8uhHp2qEDS6J0aBIbTO0levBaFHppUoqQKXIY2Y22/WAeh9+tVa6u n8pUfKRzzsEaVC7bjrgnlJRO+HEDJgFua06wxicFF3eNXZHoJliddR8JNNZUEkRQlMrH GAN4Ky/SPYH/FkKFLXTBkwUDGRZ8ch0YwRtI80+2YCoz8xYBwIrfCCkrRLwTJ9g2mEQw fxI8ZUocl7Qj35sEPttwIEer0DiDa+IJzB9/TIn8KGaOeVxZeqkk7EH06gA6nQdko8QS Ui4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e23si154294pgl.293.2019.05.29.09.40.33; Wed, 29 May 2019 09:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727172AbfE2QjA (ORCPT + 99 others); Wed, 29 May 2019 12:39:00 -0400 Received: from foss.arm.com ([217.140.101.70]:49276 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfE2QjA (ORCPT ); Wed, 29 May 2019 12:39:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B84DE341; Wed, 29 May 2019 09:38:59 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E64703F5AF; Wed, 29 May 2019 09:38:56 -0700 (PDT) Date: Wed, 29 May 2019 17:38:54 +0100 From: Mark Rutland To: Peter Zijlstra Cc: Will Deacon , Young Xiao <92siuyang@gmail.com>, linux@armlinux.org.uk, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, kan.liang@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ravi.bangoria@linux.vnet.ibm.com, mpe@ellerman.id.au, acme@redhat.com, eranian@google.com, fweisbec@gmail.com, jolsa@redhat.com Subject: Re: [PATCH] perf: Fix oops when kthread execs user process Message-ID: <20190529163854.GN31777@lakrids.cambridge.arm.com> References: <20190528173228.GW2623@hirez.programming.kicks-ass.net> <20190529091733.GA4485@fuggles.cambridge.arm.com> <20190529101042.GN2623@hirez.programming.kicks-ass.net> <20190529102022.GC4485@fuggles.cambridge.arm.com> <20190529125557.GU2623@hirez.programming.kicks-ass.net> <20190529130521.GA11023@fuggles.cambridge.arm.com> <20190529132515.GW2623@hirez.programming.kicks-ass.net> <20190529143510.GA11154@fuggles.cambridge.arm.com> <20190529161955.GZ2623@hirez.programming.kicks-ass.net> <20190529162435.GM31777@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529162435.GM31777@lakrids.cambridge.arm.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 05:24:36PM +0100, Mark Rutland wrote: > On Wed, May 29, 2019 at 06:19:55PM +0200, Peter Zijlstra wrote: > > On Wed, May 29, 2019 at 03:35:10PM +0100, Will Deacon wrote: > > > On Wed, May 29, 2019 at 03:25:15PM +0200, Peter Zijlstra wrote: > > > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > > > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > > > > > > > > > if (user_mode(regs)) { > > > > > > > > > > Hmm, so it just occurred to me that Mark's observation is that the regs > > > > > can be junk in some cases. In which case, should we be checking for > > > > > kthreads first? > > > > > > > > task_pt_regs() can return garbage, but @regs is the exception (or > > > > perf_arch_fetch_caller_regs()) regs, and for those user_mode() had > > > > better be correct. > > > > > > So what should we report for the idle task? > > > > If an interrupt hits the idle task, @regs would be !user_mode(regs), > > we'll find current->flags & PF_KTHREAD (idle not having passed through > > exec()) and therefore we'll take ABI_NONE for the user regs. > > > > Or am I not getting it? > > If the contents of task_pt_regs(current) is garbage, then the result of > user_mode(task_pt_regs(current)) is also garbage, no? Ugh; I was being thick here and assuming regs was the result of task_pt_regs() when it's actually the interrupted regs. Sorry for the noise. Generally speaking though, if we ever task task_pt_regs() of an idle task we'll get junk, and user_mode() could be true. Thanks, Mark.