From patchwork Mon Aug 26 06:55:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13777231 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 5764AC5321D for ; Mon, 26 Aug 2024 07:02:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF2AC8D0041; Mon, 26 Aug 2024 03:02:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C79698D0029; Mon, 26 Aug 2024 03:02:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7DDD8D0041; Mon, 26 Aug 2024 03:02:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7CA788D0040 for ; Mon, 26 Aug 2024 03:02:23 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2F212A90B9 for ; Mon, 26 Aug 2024 07:02:23 +0000 (UTC) X-FDA: 82493502966.22.F8401D7 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 93A152000F for ; Mon, 26 Aug 2024 07:02:21 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YhbSmxe0; spf=pass (imf13.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724655699; 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=t1oKofdsKxK0ldQ2tCa0yio0SYsDFNlLCnwbaE19ST0=; b=ofc0cUgkiCef5pmLK22YZ3gFGl8Dk3dqJt8HLrmgkcE53gRKGoD2TjvUjm+Pqj+8gGwgoh alQBwwFbGfw3SQxNxq/Br6RFEE2lamWap9tu0EvBV6EkwehWBOjHuaOyn1AXVOg+Bbth/R 7Ss2EZv/uEmxCkZ/ESzPNTcGT00I56I= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YhbSmxe0; spf=pass (imf13.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724655699; a=rsa-sha256; cv=none; b=vb1HYMyKtzhs5dqRKCIxO7cAujdtyXmY33MzUYveVmtKRsTQrov4GMPDf2TweOqdyrSFuF EB6IY2GcLAVWyz7tOzf6pcUFNQ1vrucVRFLB5sqlvnlcUGODhiRKhwEWXpUPvL1qoKwAqr 70zW7XVkyolVzjRufOxj8LkKlSxQnCg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 70A5AA41C59; Mon, 26 Aug 2024 07:02:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17547C52771; Mon, 26 Aug 2024 06:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724655431; bh=V5vgSKLMNC5xDauNsA8Q9sUWVFSHgPBigpP0dkRNui8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhbSmxe07BA1yJFRiZKO2RvsIZALsjMSoPns6+ARiwj5IzU0ASkQGmtoKb+hh90hS J6BDgg1zhpqDu4VFALJrA8keVSlzcNnojJmSrtAHrdm0i3g+EHsP35vTP7f7gfe6fj upMbgJciteuQOoh50BNTPMeykyZKVoF4YMAanalap68kfwGpncXqPEpJY0yKHsNGxg PaPCzCzmedEwNLxcmR1GbsCwpZ8unLntdigA+zr4dFZmGtAOJ6Ulh6Ng84JE0Ver08 ckebHWlrVw/K6qXHl1fJsZxADBkuR+8dAiAZNb74jQsl55r8nweVnEVhDBSb5n0BnB aYOVxtMhEaH6A== From: Mike Rapoport To: Andrew Morton Cc: Andreas Larsson , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Christoph Hellwig , Christophe Leroy , Dave Hansen , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Kent Overstreet , "Liam R. Howlett" , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Mike Rapoport , Oleg Nesterov , Palmer Dabbelt , Peter Zijlstra , Richard Weinberger , Russell King , Song Liu , Stafford Horne , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Uladzislau Rezki , Vineet Gupta , Will Deacon , bpf@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 5/8] ftrace: Add swap_func to ftrace_process_locs() Date: Mon, 26 Aug 2024 09:55:29 +0300 Message-ID: <20240826065532.2618273-6-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240826065532.2618273-1-rppt@kernel.org> References: <20240826065532.2618273-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 93A152000F X-Stat-Signature: 9pzrjk1psdbhr4exmgtiqcn9cw9ezzo9 X-HE-Tag: 1724655741-472439 X-HE-Meta: U2FsdGVkX1+ZJlj/yspVQYYcBhu2CoSktsEExQ2FTgPI7VGwRG8wyHfs0mEe76bJJw/2EC2Rs/g40qUeRFE81yJ+cCQTi46zXUG3RcIRmx17HoHnP8LOrBxevGsSvatcF+n7MoEB331e9dh1C5Vc+ih2weYyFcAbn3M65wNU1C8qwPVgxtrjjAQBKn5y74jbjNSeHP4X1TsfD0nOV04lIhwUpU34vcx0ck0z60bAgLcEQuv5nFwEFvbXKD4MKgwRbupmE5+EuFNadD6274u7QQrBV4sS0j1NJICDd9tswzaPvBWMoVQO+S8AKvJw7YJP+tjjuUVCz5Rrx9vS4j2kzB0JkIVW+NPN1NR5+9t07ojZKslspS0I62hVlXqCiS2WqPKF+aQOK7be5z7mhd6a7BGHU0v1wFQfWDfTHI7EQGhF9Crh1u2srwWj9NS7fQNVakcnfAEvwLkTDlVIL5h5v2WHiJy8QRMhn8YIQi7lCXOctCjazFvATTD+UEJOvBK8jqEltULXilLzPgwu2DYeNWf2ouQ7Hitw0lDHl5hXtW66IS9dnraRD3kKB5jRVJZ+9Khe9Zjto6DHpS3857YSf1wkHmVqYX3yLPRIgbc/J6Ltat9Jp/i5DNIQZEoiXYHKajQNCmyDN5QRBXwHDPmfmC24oxxHgd0U6krVRNQjFRJMq1E+KakuFFiAtThMDrZMxXYVJyGabMvy8G8/1R5NhrYWT+PZEr5Ii147qNq6nS/+8emJkUA9nftkCUDrlXUJOx7QFWwAf08FOsvyqE+cDByRjsojUWPlz3sG6BNhx+xOTCGezbsIIIYI6jQ5AdXWsFdcs+NIAE+gei4hOwaz/FuZyHtKfm+S/GqdGrCF93gQ0apnxCScisgrvoNvqtkAkYcWinvPS7strQsZJC/l4mQC2IvsY1NMpDmEGvW3BYywmKLeOdfvenGZ90nm0OSoKxmVKxE4ldU2d3zjAiF gXP2Ru0q MVQ9jATqu77TjrA3Fo41V0tzXSs8FeL7HeQPYQqwifAfMqI+cydp77OMCntm6uJ8mLPPe2XB/uQ8gvLGXkicptN1vVhnUbVDXDyyLY4kCtJrOkNM9IgOcdE/WKWNWJhsXLUIdRf3kTKYs0VVKO3ypuf6jjJZEqdAm7odKRjfykMjn03WeAP0TOY5D6ZP6HZcOWLFndrZnVXug4lwoVsr7ZVc+oBDJCFfompjtsR2Q1DqKomwd8tFis1nkB2S1fElEjasWSA5MceYmVlZar4/iwOSp8wMIVs99rI90zD8Mu3SVxxA= 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 (Microsoft) --- 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 fd5e84d0ec47..b794dcb7cae8 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -1188,4 +1188,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 4c28dd177ca6..9829979f3a46 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6989,6 +6989,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) @@ -7016,7 +7027,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); }