Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D735BC433EF for ; Mon, 20 Dec 2021 16:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238953AbhLTQih convert rfc822-to-8bit (ORCPT ); Mon, 20 Dec 2021 11:38:37 -0500 Received: from mail-eopbgr90080.outbound.protection.outlook.com ([40.107.9.80]:41760 "EHLO FRA01-MR2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236296AbhLTQie (ORCPT ); Mon, 20 Dec 2021 11:38:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdPOLxaL2nGuGIxK4L/+YKNO8vFjyUooS7uXA8gnjXb5rv+gNpUFEVdlrSZF35bMEsZevFbQkKgVXijhbsSPaLAX99qgktNailpY5S82Z80mzYVzVVRoP1b5Gc7aTjEFkrgtM3dIasQIu1TxKEAVq5De9UyDPCDi4wM/SRpK+XXPWd2KeO/Qu5sA/zTo+Pg8N5XjiOLJUkCkU97ieqzEJFjcdyIVa5GZuPLXmLGuW02PDHNbQADrj3ySVWa2Rr3FrIS17S4M70YLwSLD9e5AdqdeBCbNv8P5XlD+Ks5gj+rLccOw+Y6vZnRAKTw0yqtFNDExSCB/wJ/fj1Zm+sPPKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0VnYTnU4UZib71s8A1qbE2QTy4FztFa9DLNZTJoEOz4=; b=GZnHA9kfZ6FBc/3K51Bo/45hekL9kLefOjjiWh3+0/Ya1vzlUbEDLZa8oeYKtATDzROespJBxbVZ6kBdHG01OxDH40NkIB4orpmiEo5MSOPTQMBcYTaFWRCo1ZNKvy59E0KZnx+0C8eJpKWiTS6yC8XgbStQibQ2zl0tci681aFMLMfVo55KU12CHBNFljUjmGGbg5UqdTql9588iEn2hUwTnDkXrPfdB7DRSgIE2y65zeIQ4GQqx7U42tzzl09Xk8Le4uPPV/p3J+m8zTOZdTuAKUwTOaSTQOOY2HolRGMqg24ujxzqnNfw7lYzH/wrNO5huFZn/ysz62Od8yVh7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=csgroup.eu; dmarc=pass action=none header.from=csgroup.eu; dkim=pass header.d=csgroup.eu; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MRZP264MB2924.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Mon, 20 Dec 2021 16:38:31 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d%5]) with mapi id 15.20.4801.020; Mon, 20 Dec 2021 16:38:31 +0000 From: Christophe Leroy To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Steven Rostedt , Ingo Molnar , "Naveen N . Rao" CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "live-patching@vger.kernel.org" Subject: [PATCH v2 10/13] powerpc/ftrace: Refactor ftrace_{en/dis}able_ftrace_graph_caller Thread-Topic: [PATCH v2 10/13] powerpc/ftrace: Refactor ftrace_{en/dis}able_ftrace_graph_caller Thread-Index: AQHX9cAGmx9IDhU2XE6F7yRDPjZy2g== Date: Mon, 20 Dec 2021 16:38:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=csgroup.eu; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3dd04941-70d2-4b4e-5a42-08d9c3d7289a x-ms-traffictypediagnostic: MRZP264MB2924:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:215; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: R2v28u0WI+BdJN3ivesSUFhVzpNnkhhmqZcRTezxmy3L+JfpBCxx79Jn/Qk6fbl2/pw+jqhxNXDuVRfawKZHkF4mE3SG9A9ZgQ5JWTIvHDSeA/gz2F7jFy8ctHFJw/16z0xs7ESB2cdPU8knUehKuNaaWZcN1V8hEVDG5Lvs6woPMvmjoTCjd1GYqWNK0MNv0A/i9oXyQA45m/DJS5a+aGES4rPtrY6yOSXe47Lk/RZvmDqfjvp5voCEtxEvJhLvFiAR6AB9r1VD7yTgcH9Y8dQxCK6g1LaScaN+AvL2T7c964HH+KJNtJ/rMMVYJXs/qZyTvdClbOmaeNfXoXJvoOF7/xrwG/gsmv7l0MhhOHOR18raBHgJLg3C5XBcpoYQoig9zjubq2qAidct0cqMe/LUwVs5uJH20AbKmGm4ulpJyVs+NRsHQScBo4zfZYlzNH4PYsBfDwk0hZtsPifeTfftn9vsePV5b3vqSpB3uipNVloHvEKuYOUUpuqIDenhrD/Ksf263lnAWtIz3voc8KEYOZQLw2SVo/LM7o97QjYJpNij/tNHql2SeMo0cjkdspNNp82yhomELtC3CKk0SGr+9NcG49j8UW0jQ4Vt7sSJ1ePPo6MnPQO+VfegrJAV7SLjM42IRxk8XU00Posp1dxB4SwdVrdVFqlkbR7u6b7ZcgzykkxK69t9MyaaWJ8hCpMJ98jFNR7OisjG8MR7Pg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(2616005)(6512007)(7416002)(44832011)(2906002)(83380400001)(6486002)(66946007)(186003)(26005)(66556008)(64756008)(38100700002)(66476007)(8676002)(8936002)(122000001)(66446008)(76116006)(86362001)(91956017)(316002)(6506007)(508600001)(54906003)(4326008)(110136005)(71200400001)(38070700005)(36756003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?YMulNDEx/s7T3xr/Yzp9JBIZpnkFckNYfgGiSqtnbe1bOvUNRufx6GDmx8?= =?iso-8859-1?Q?a1C5g+1SY0k8HgkWlYfNHFGzWDYRQ8rXEVZqLIXFJYXgmRUyyH+2N7J/Cw?= =?iso-8859-1?Q?a2/rSvBTF0qhFWPegwxH1H7W+5YsoY2ZivAnjMBB418/RqKrfJhTvudygU?= =?iso-8859-1?Q?4SOzaWB90vFEluYqECtcHdAduqcGaEo+qJinY76o2Y6rKt3wx7dPpqMEvA?= =?iso-8859-1?Q?xCaThs/w6KHa0vpDjQm5dBXUBwkQccuWhA1+c70SzQgNACbAuXlntAi6mp?= =?iso-8859-1?Q?HBJhxq7cTMjhOrwP0fDZVTm1w9ltW0gri06U0MqWjwa0z2Y7m2e3f+lY9w?= =?iso-8859-1?Q?yHvOO0a2l3j8AhxRB2HEXF9kWoai+Q/EHqyVuVtgxfyfrth5KOgkblHcnw?= =?iso-8859-1?Q?Xk3STvUv1tbpIEGykyIcRbuIeMWJuPmrocg4Wl/7TGJrRX9wMO11bKxygZ?= =?iso-8859-1?Q?YjYJxZKr8cfMknnfcGIccr4DzKrAl0pNdQf3TkSmXrnLiZfDnELwJr5AAG?= =?iso-8859-1?Q?KOIs3IVKRPeT1EfpzGh2ZC7Cy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=?iso-8859-1?Q?f//yMEVYxA6assct7Uk7Z0sukkw7qkLAhhfeCUzimjXFI31p43iMhx81NP?= =?iso-8859-1?Q?5x94R0s5pZdtJ69ZuvfDuf/ri8Mx9mEDRUB5PJkm8aa+BMOi3lgGt1bQtD?= =?iso-8859-1?Q?rlNOA8XRVyUKeMG5weguvBna2F+O/rLjeu6zhJJtVsiSVv3qk3BxZPURNm?= =?iso-8859-1?Q?AMAwBvf/CQAKFP9AbgpdILL2GIFJTqm7ejexta+XqH1v5VTjWuv1BVvOIn?= =?iso-8859-1?Q?hSBSDQTx38BqECC6UbCL97Ab1XQ2C63sd5R2ELCfjFPEkuoW1+YaF8d2VH?= =?iso-8859-1?Q?/5MoKALSrBl7COYXZObFNP7r8=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 3dd04941-70d2-4b4e-5a42-08d9c3d7289a X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2021 16:38:31.5756 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hhhBE1R9yHi3oIEw7owcC0VeH5ui+srYpDgwnH1C+PnLn1kpBbO944LI4UR0TXh4mkXmPCem5n3gUg187TvkFJ99z3NPccxz503coePE3hc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB2924 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ftrace_enable_ftrace_graph_caller() and ftrace_disable_ftrace_graph_caller() have common code. They will have even more common code after following patch. Refactor into a single ftrace_modify_ftrace_graph_caller() function. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 80b6285769f2..ce673764cb69 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -910,30 +910,27 @@ int __init ftrace_dyn_arch_init(void) extern void ftrace_graph_call(void); extern void ftrace_graph_stub(void); -int ftrace_enable_ftrace_graph_caller(void) +static int ftrace_modify_ftrace_graph_caller(bool enable) { unsigned long ip = (unsigned long)(&ftrace_graph_call); unsigned long addr = (unsigned long)(&ftrace_graph_caller); unsigned long stub = (unsigned long)(&ftrace_graph_stub); ppc_inst_t old, new; - old = ftrace_call_replace(ip, stub, 0); - new = ftrace_call_replace(ip, addr, 0); + old = ftrace_call_replace(ip, enable ? stub : addr, 0); + new = ftrace_call_replace(ip, enable ? addr : stub, 0); return ftrace_modify_code(ip, old, new); } -int ftrace_disable_ftrace_graph_caller(void) +int ftrace_enable_ftrace_graph_caller(void) { - unsigned long ip = (unsigned long)(&ftrace_graph_call); - unsigned long addr = (unsigned long)(&ftrace_graph_caller); - unsigned long stub = (unsigned long)(&ftrace_graph_stub); - ppc_inst_t old, new; - - old = ftrace_call_replace(ip, addr, 0); - new = ftrace_call_replace(ip, stub, 0); + return ftrace_modify_ftrace_graph_caller(true); +} - return ftrace_modify_code(ip, old, new); +int ftrace_disable_ftrace_graph_caller(void) +{ + return ftrace_modify_ftrace_graph_caller(false); } /* -- 2.33.1