Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp345170yba; Thu, 18 Apr 2019 02:11:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPV9JHxDzHP5gLnFyd3C0PRdRkK52VUzgUdwLZXZkkI6v3B2pkKdxPLtj0B88PE0hgqGc3 X-Received: by 2002:a62:e215:: with SMTP id a21mr93553523pfi.30.1555578705156; Thu, 18 Apr 2019 02:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555578705; cv=none; d=google.com; s=arc-20160816; b=viMJaG0rixSchzVaKHdhVM7CNekMmLPhuWqdocn8gIuitb+lATGjb4Ze4ZUSsbHPhg czvcRatCij9DTwcYZLtQ7epFk6ybVb5juNQaw50UOKv/CvaTbhCarDwtQMCMGvoV4q4q U+MmoViDAYyi4i7lYXiIFLF9WQI9q0NugcE4pYdNuPzqtQbCY/G7Xr7JDkKHjsEchnVF hCQPREXnB6uP53cIRnkyNhiIJcNA/8iA+vHZNd+3/kfXsmtafF3IV+QomPhA6Hz85xZJ CThK3i6+B8oCu1FwqOC186sz9kYHru8B9V+uFNl/YSOsmCAeAyjnywsh6kF86n7o1oJs P0qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id; bh=JCj0ux7ByedEKEk5YXz2OvnjUAqieqsVDG1XIhHxw0g=; b=QuNbV4vjz0EHFOU2nWVxjzvDrmPdFeb1MKSeRYrQ9jau31LJTpzz5sLyKYqZMLsNyh BZZ97QzbeOrUqJAnYd/wN+20uott4Ss+SvuIa1PIkZqcoBwcZQqd1TK1wcP9t+LbaYZZ w0GG4+FS7wlM7KVsI4PrYeTMktqdkWJoNHeKPMy3oz3j9jHxVEeTaLEj9T0HRB4dWtEF DF0Va9Xw3GtCq2MbntKlCykyFkKkOapP5fCMkwVVmtftoExIoXWENxLsVycUdOhAvIeS VNALZa+B3ovoxcfdjdKv+FDaTjQv1FL/BpEwXgNEHfUzWAligFzFqdbuOEdHx+3JssSi Dazg== 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 d23si1542798pls.151.2019.04.18.02.11.29; Thu, 18 Apr 2019 02:11:45 -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 S2388773AbfDRJJq (ORCPT + 99 others); Thu, 18 Apr 2019 05:09:46 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:34075 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388426AbfDRJHd (ORCPT ); Thu, 18 Apr 2019 05:07:33 -0400 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hH30P-0001xS-En; Thu, 18 Apr 2019 11:06:53 +0200 Message-Id: <20190418084255.364915116@linutronix.de> User-Agent: quilt/0.65 Date: Thu, 18 Apr 2019 10:41:44 +0200 From: Thomas Gleixner To: LKML Cc: Josh Poimboeuf , x86@kernel.org, Andy Lutomirski , Steven Rostedt , Alexander Potapenko , Alexey Dobriyan , Andrew Morton , Pekka Enberg , linux-mm@kvack.org, David Rientjes , Christoph Lameter , Catalin Marinas , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Mike Rapoport , Akinobu Mita , iommu@lists.linux-foundation.org, Robin Murphy , Christoph Hellwig , Marek Szyprowski , Johannes Thumshirn , David Sterba , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Maarten Lankhorst , dri-devel@lists.freedesktop.org, David Airlie , Jani Nikula , Daniel Vetter , Rodrigo Vivi , linux-arch@vger.kernel.org Subject: [patch V2 25/29] livepatch: Simplify stack trace retrieval References: <20190418084119.056416939@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace the indirection through struct stack_trace by using the storage array based interfaces. Signed-off-by: Thomas Gleixner --- kernel/livepatch/transition.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -202,15 +202,15 @@ void klp_update_patch_state(struct task_ * Determine whether the given stack trace includes any references to a * to-be-patched or to-be-unpatched function. */ -static int klp_check_stack_func(struct klp_func *func, - struct stack_trace *trace) +static int klp_check_stack_func(struct klp_func *func, unsigned long *entries, + unsigned int nr_entries) { unsigned long func_addr, func_size, address; struct klp_ops *ops; int i; - for (i = 0; i < trace->nr_entries; i++) { - address = trace->entries[i]; + for (i = 0; i < nr_entries; i++) { + address = entries[i]; if (klp_target_state == KLP_UNPATCHED) { /* @@ -254,29 +254,25 @@ static int klp_check_stack_func(struct k static int klp_check_stack(struct task_struct *task, char *err_buf) { static unsigned long entries[MAX_STACK_ENTRIES]; - struct stack_trace trace; struct klp_object *obj; struct klp_func *func; - int ret; + int ret, nr_entries; - trace.skip = 0; - trace.nr_entries = 0; - trace.max_entries = MAX_STACK_ENTRIES; - trace.entries = entries; - ret = save_stack_trace_tsk_reliable(task, &trace); + ret = stack_trace_save_tsk_reliable(task, entries, ARRAY_SIZE(entries)); WARN_ON_ONCE(ret == -ENOSYS); - if (ret) { + if (ret < 0) { snprintf(err_buf, STACK_ERR_BUF_SIZE, "%s: %s:%d has an unreliable stack\n", __func__, task->comm, task->pid); return ret; } + nr_entries = ret; klp_for_each_object(klp_transition_patch, obj) { if (!obj->patched) continue; klp_for_each_func(obj, func) { - ret = klp_check_stack_func(func, &trace); + ret = klp_check_stack_func(func, entries, nr_entries); if (ret) { snprintf(err_buf, STACK_ERR_BUF_SIZE, "%s: %s:%d is sleeping on function %s\n",