From patchwork Thu Apr 11 16:05:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13626230 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62108C4345F for ; Thu, 11 Apr 2024 16:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E27DB6B00B4; Thu, 11 Apr 2024 12:06:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB1256B00BB; Thu, 11 Apr 2024 12:06:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE48A6B00BC; Thu, 11 Apr 2024 12:06:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9DA4A6B00B4 for ; Thu, 11 Apr 2024 12:06:20 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 49522A1855 for ; Thu, 11 Apr 2024 16:06:20 +0000 (UTC) X-FDA: 81997728120.14.1ED560A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id C1113180021 for ; Thu, 11 Apr 2024 16:06:18 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dBjNsDOQ; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712851578; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vm3ydTCRRAtVPv1Cqap2BhrLwXDmUejZHajDNaqcY9k=; b=YfyKOWORj77+WjONVQOo9SGKK3ZbbJK99SqA8QQYVimWx8Fj6pkle9aYZULZtF/B5404EN sTZClbAy3mYQcMmNBR6I5vcZtR392mooY5vSjnKJ5nGYRypEJzWd+5J9Sk3myk4zj46O96 OewnFF0DiFW5/0ipb+3ffSYPF2ZRMNc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712851578; a=rsa-sha256; cv=none; b=5yV824c9pUab1U5Y9FYagJVP+T7sBtjXcHjdUroR3qFk5166HwQhDEgn6wFkOlKZED4By3 u142zfpvm4Iw4Xi0M5RClqE8SixFFSF4Xaq4EbN15+eha/C//cFDD4i/od3kAEVFZuONdv tvxvRXJd5cL7FJ4bm+CM1YGsFPOc/Y8= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dBjNsDOQ; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E7120620E6; Thu, 11 Apr 2024 16:06:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00322C32786; Thu, 11 Apr 2024 16:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712851577; bh=btBuaAPySyacvFLoesSF8jmcxuZmKLyhOW9rUao98hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBjNsDOQydXb1RIv/QKPd8a/ZcM3ev4iQrlZuWSxB+eUTRlnLJblCgvMoL/gVezXk hMzdbN4z+LzsDiSRE7xfAAHe9xPq1yf5Dp8udLo1xyJoKuxv3AV7HKyl9mucU2ATHY O8GL1DfmSWHVBej34ZHjyiSumP79dUOy5Rmalka7m6BxXWq73PfMbzd7DJkjsvzYrn 3bUewkI/ccMeykN+WKxx+bwi2QvOtbdMnYufmjYMSKlLKRLBgJpYiBQsgONqWbK+Tv tyiNgxlRIcvBi+krsFKANi42N4Sy4K8EfIvPGRIPaVUAjxASMQ3Z+Ku76dg641fTiy s268X7J1EAzTg== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Andy Lutomirski , Arnd Bergmann , Catalin Marinas , Christoph Hellwig , Helge Deller , Lorenzo Stoakes , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Mathieu Desnoyers , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , Peter Zijlstra , Russell King , Song Liu , Steven Rostedt , Thomas Gleixner , Uladzislau Rezki , Will Deacon , bpf@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [RFC PATCH 4/7] ftrace: Add swap_func to ftrace_process_locs() Date: Thu, 11 Apr 2024 19:05:23 +0300 Message-ID: <20240411160526.2093408-5-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411160526.2093408-1-rppt@kernel.org> References: <20240411160526.2093408-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: fpowbxogcsaarpyqgbwjbxzrk58u4ife X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C1113180021 X-Rspam-User: X-HE-Tag: 1712851578-72992 X-HE-Meta: U2FsdGVkX1+fEFkgNVWayD8NHBxxGp81xpOOmiExilFoB3mYH9Nj7a3bVpstl2Roz5gMq7PZCLDXbzg1fv8UnsHWvqL132mbdXrBaqhQak6vGpCUSwEDieekC1Gp/CLJjB+I0GpkefKxDMRVtgcCi31h3nHPd2y+8nuqM7ruy/NhX/N57IrtEy6gW4wHHVAhiTFFc84sPjepS0z6ODFB3cgomo702C3D53hTa/dBmxKCSL0QTq7uI5Bkw0hjIkjVEw083gC5Z8MiNHkRuKxxbBKbzybLUbE0rEisNUhNQESMiQDgMCLnfzl+mG2KW8dv6TJfLejxYquAaphbk2RPxp90Fw/V3GaocpKx5x3/DfeQ81904rrD6TOi2JZrrZTVxfDozpqlYBNw35UjcZjOUE7mfCKek8B5Ej74JryuAJybgcSfv6NlLj7mViNLpmGVru7IS7yaLJIUukTqCFcZNaepgnP9SVLXjBqJfuucSnGmBgJ2eX2ampeiLUB9UCB70bBfsag4SrQoQAj5IJRwaG2PXEP4Ax3BjLLBPiifuY511cAtrJ42X4ahuwX4M6slUnJJ95h3kmcOIMJYw/gvuQK9zYC1ZPXezo0f0BybjLo4NR0aVcpCmtKePqZ+0f/5lNMlDwYHaMSCUHS3ZRQ8iGx/3l0MeNsi4rtHZv9KQfT6ALXYvug+6lC0kYkHO9SdvWf2Ksq0t+xWeR6TbBfYSAFEz7zj0dD+Ha4XEKeRqHgERXKPdnPEN1No/Hhmf7Tbi6uWNpOM8hlO2V/9X7yvlyQ1m1Nv7uPIO0VyQui3ULPqkZVrZbh1p0PS8Nb9pfdsxKbejtL0exXPgzz/IfSbDeNUTtFlXZWY5vwOdkmAqk4DKsUUrPGcGAob5fF9nOK0F9+rmeNvXWafyfyVrCTWi7LIJoFVRp0sY+wrHIbhUpp9GOKFR4K9yl/xu8zsibVaDrl0l3uV3PUQbp2iqZU puLl5Uvg 9hJaK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Song Liu ftrace_process_locs sorts module mcount, which is inside RO memory. Add a ftrace_swap_func so that archs can use RO-memory-poke function to do the sorting. Signed-off-by: Song Liu Signed-off-by: Mike Rapoport (IBM) --- include/linux/ftrace.h | 2 ++ kernel/trace/ftrace.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 54d53f345d14..54393ce57f08 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -1172,4 +1172,6 @@ unsigned long arch_syscall_addr(int nr); #endif /* CONFIG_FTRACE_SYSCALLS */ +void ftrace_swap_func(void *a, void *b, int n); + #endif /* _LINUX_FTRACE_H */ diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index da1710499698..95f11c8cdc5e 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6480,6 +6480,17 @@ static void test_is_sorted(unsigned long *start, unsigned long count) } #endif +void __weak ftrace_swap_func(void *a, void *b, int n) +{ + unsigned long t; + + WARN_ON_ONCE(n != sizeof(t)); + + t = *((unsigned long *)a); + *(unsigned long *)a = *(unsigned long *)b; + *(unsigned long *)b = t; +} + static int ftrace_process_locs(struct module *mod, unsigned long *start, unsigned long *end) @@ -6507,7 +6518,7 @@ static int ftrace_process_locs(struct module *mod, */ if (!IS_ENABLED(CONFIG_BUILDTIME_MCOUNT_SORT) || mod) { sort(start, count, sizeof(*start), - ftrace_cmp_ips, NULL); + ftrace_cmp_ips, ftrace_swap_func); } else { test_is_sorted(start, count); }