Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4000275ybp; Mon, 7 Oct 2019 01:18:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcNEeZHNcwvXT6TyR6NFkILwy+84sfTKkP3MHtDs4g0RFunZ/QVHu4F4jiA9PajhhSvKzO X-Received: by 2002:a50:9208:: with SMTP id i8mr27589952eda.3.1570436337324; Mon, 07 Oct 2019 01:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570436337; cv=none; d=google.com; s=arc-20160816; b=H5tYZrSdrtlwt2Kx3eILwOcr6QhRXUm1GNWsgUffbGD+Zs65F010PP73taHd2JxMe8 EUbQ4HE3sz4OzyTTfJUunuV1R9lMhgnu6j/46JzQirg0iYAAoLLTjwM3BEc7Uo5HSw/L RqCRoAAlq8bncbXb2Qs8unOF8YOR1SbMWxj0D2szSpl5N/7uWTXYeNndre5jYjwXgq3+ nKBHEs7M3VQM/T3WqEGQtiJQpYY7DITthhhWAwvL3OdPZ2Ki0DGiwr/eNDIHWkaIu5Kc ammcqxJ5jWXmIFbr7NlaY0ohUg+Ii/oxX3PfgO/LlpDDKf+TM6FxyCY3a+N1Ui+CWtyl u4og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=COFla2yaXfLkPsM1dGNhgcDG2oK+yECABFKD6vmzcbw=; b=bnDwRX65iGBkgm5iGAlnXB/L1cYruouMNLGhfNcwB10yk3l0NeqIMcPoIlm8G4bH7K VlblNIcufPvuOR8FNibOAif0goqu2p9uLqYbV8FHTL8SKUDQfjHO5Hph1igiyxuQ0OtN qFTgJ1YITvThuUiSU7afv8NratpVeEYeeUAv4fTzACyMjQEbzHbkaF4KN8M6xW3hesrP EWQVBLqy2RwVq2zgHbFBAhTw3fCyWdkAnTej60YcI7jsNxhikVxpsS9KruUch/0YCbSr R7KjPF1c0wvaVJkDk3dngjBmFQ6VPh9I52hkIHDlnclXIVJMv70poBmRGIlAJiyyhdwA eDrQ== 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 oe23si6611711ejb.199.2019.10.07.01.18.33; Mon, 07 Oct 2019 01:18:57 -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 S1727511AbfJGIRT (ORCPT + 99 others); Mon, 7 Oct 2019 04:17:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:56256 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727477AbfJGIRT (ORCPT ); Mon, 7 Oct 2019 04:17:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 69ADFAE4D; Mon, 7 Oct 2019 08:17:17 +0000 (UTC) From: Miroslav Benes To: rostedt@goodmis.org, mingo@redhat.com, jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, joe.lawrence@redhat.com Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Miroslav Benes Subject: [PATCH 1/3] ftrace: Make test_rec_ops_needs_regs() generic Date: Mon, 7 Oct 2019 10:17:12 +0200 Message-Id: <20191007081714.20259-2-mbenes@suse.cz> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007081714.20259-1-mbenes@suse.cz> References: <20191007081714.20259-1-mbenes@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function test_rec_ops_needs_regs() tests whether ftrace_ops registered on a record needs saved regs. That is, it tests for FTRACE_OPS_FL_SAVE_REGS being set. The same logic will be reused for newly introduced FTRACE_OPS_FL_PERMANENT flag, so make the function generic. Signed-off-by: Miroslav Benes --- kernel/trace/ftrace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 62a50bf399d6..a37c1127599c 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1602,24 +1602,24 @@ int ftrace_text_reserved(const void *start, const void *end) return (int)!!ret; } -/* Test if ops registered to this rec needs regs */ -static bool test_rec_ops_needs_regs(struct dyn_ftrace *rec) +/* Test if ops registered to this rec needs to have a specified flag set */ +static bool test_rec_ops_needs_flag(struct dyn_ftrace *rec, int flag) { struct ftrace_ops *ops; - bool keep_regs = false; + bool keep_flag = false; for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) { /* pass rec in as regs to have non-NULL val */ if (ftrace_ops_test(ops, rec->ip, rec)) { - if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) { - keep_regs = true; + if (ops->flags & flag) { + keep_flag = true; break; } } } - return keep_regs; + return keep_flag; } static struct ftrace_ops * @@ -1750,7 +1750,8 @@ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops, if (ftrace_rec_count(rec) > 0 && rec->flags & FTRACE_FL_REGS && ops->flags & FTRACE_OPS_FL_SAVE_REGS) { - if (!test_rec_ops_needs_regs(rec)) + if (!test_rec_ops_needs_flag(rec, + FTRACE_OPS_FL_SAVE_REGS)) rec->flags &= ~FTRACE_FL_REGS; } -- 2.23.0