From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753420AbdLNV6j (ORCPT ); Thu, 14 Dec 2017 16:58:39 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:40720 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752656AbdLNV6i (ORCPT ); Thu, 14 Dec 2017 16:58:38 -0500 X-Google-Smtp-Source: ACJfBothG96zcjEgMMWJaMYYRdT0tPYiU8tVLLIwSatjX43lq2Tg7xGruMQ0+PPGZ6X8L6d+2Bbdig== Subject: Re: [PATCH 1/2] x86/stacktrace: do not fail when regs on stack for ORC To: Josh Poimboeuf , Jiri Slaby Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org References: <20171130080325.24785-1-jslaby@suse.cz> <20171130195710.cu2lsa47kwnow2hi@treble> From: Jiri Slaby Message-ID: <73526a6b-5083-78f1-8f76-d5f3ac52f958@suse.cz> Date: Thu, 14 Dec 2017 22:58:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171130195710.cu2lsa47kwnow2hi@treble> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/30/2017, 08:57 PM, Josh Poimboeuf wrote: > So with those changes in mind, how about something like this (plus > comments)? > > for (unwind_start(&state, task, NULL, NULL); !unwind_done(&state); > unwind_next_frame(&state)) { > > regs = unwind_get_entry_regs(&state); > if (regs) { > if (user_mode(regs)) > goto success; > > if (IS_ENABLED(CONFIG_FRAME_POINTER)) > return -EINVAL; > } > > addr = unwind_get_return_address(&state); > if (!addr) > return -EINVAL; > > if (save_stack_address(trace, addr, false)) > return -EINVAL; > } > > return -EINVAL; Kthreads and idle tasks hit this error as they have no user regs on the stack obviously :). So making it: if (!(task->flags & (PF_KTHREAD | PF_IDLE))) return -EINVAL; works, but is not reliable now. So I believe, we cannot live without unwind->error to differentiate between "unwind_done() == true" because: * full stack unwound and the stack type is set to UNKNOWN * unwinding failed and the stack type is set to UNKNOWN Or perhaps introduce stack type BOTTOM, NONE, or NOMORE meaning the bottom of the stacks reached? > success: > if (trace->nr_entries < trace->max_entries) > trace->entries[trace->nr_entries++] = ULONG_MAX; > > return 0; > > After these changes I believe we can enable > CONFIG_HAVE_RELIABLE_STACKTRACE for ORC. thanks, -- js suse labs