Received: by 2002:ab2:7988:0:b0:1f4:b336:87c4 with SMTP id g8csp90679lqj; Thu, 11 Apr 2024 10:37:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsgZ3NV6JOLratRRVz7yYpWHn9mYWnKi2itRJgyMsWjSDQ0kMX80aTMmJcYzhRmaOr8HcQ83jvjdcw4f/1TkUCCjjlBBOaR+4E76RzLQ== X-Google-Smtp-Source: AGHT+IHoygo4fZaYs9z2zrf8CyT63PsucvmMKkcYKxN5tP3Hl7jqD7jS6cGsDxfJDZPEfwGIDKI+ X-Received: by 2002:a05:6a20:1b0a:b0:1a7:5185:868b with SMTP id ch10-20020a056a201b0a00b001a75185868bmr390373pzb.60.1712857038980; Thu, 11 Apr 2024 10:37:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712857038; cv=pass; d=google.com; s=arc-20160816; b=1DMeqriyoKe7HaaAHrNes39IwbH8KgRhuE6Tlbykne80Tsrn9yjKob8ZBMWZxX3AUj FC+qc+Qw1mfgKJB77kO5QwCi6Q8OaY7E63AAJE5lgCsuvX60Ot37Wg3EWoOomdhPHFhc c4UN+KqKjQRSWoGqejZ132dB+/JkoKhhCzboUlDb41Joz25IBhOl4H2Fzj9qhOj2aGXE V2Ij6+C2PqG9ZQmr7dzckpyPB1ggN6bAPZ4dEgt8UE4SWHTD1AuxMvkYcora/j2VT0st idqU6JKC0EgCviyLqPbI6hN4eO2gbvY1gRlK7NeUQp/ehJmvTaZVSUfO4RgD7Wv+K1Ck ZPBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vm3ydTCRRAtVPv1Cqap2BhrLwXDmUejZHajDNaqcY9k=; fh=gMFRjFG9KasUYvwr0WK5/KYxde7tueU8fZSQFYWo6W4=; b=Ru07kOKH19dCEfGnL3Whh+qkmX+IcR09bdAhSxX5OvefzuHyYFcBMkOAejBUVtutFK 1ctjg2XVkqBNk//6g26+QTxEJXvuRQbpC/iZzlbs6eL4mFEgvkmbBzOA3znkh7DUG9nN V0mCXSoDlRgWYwlmgxYQiQkyvUkKQfRYVQO3Rd05Krc2JqopMLflVJgXf3els7NFxiDc /J7gy1vTzMzflJbTIZ8FvTWXurrk7+VrQA+KIZ+CJpuLJrLAPzqNuc7aZ04RH6iSsxlC 5r8BTOrdmIxQEpcmWHJcJqmOn3RUUwTgEBWUPBK4eaEcdaDKVycRcH+rNNw3r9QJ7ztp apBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dBjNsDOQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-141274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id cm9-20020a056a020a0900b005f3fe76ea9esi1652446pgb.649.2024.04.11.10.37.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 10:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dBjNsDOQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-141274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A0CE7283198 for ; Thu, 11 Apr 2024 17:37:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3D1F14E2E0; Thu, 11 Apr 2024 16:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dBjNsDOQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AAE214D43D; Thu, 11 Apr 2024 16:06:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712851578; cv=none; b=dbQa1bvOfgl28SrWyW/TDkwjcql0lZnDZw8lFfR2iYRuE3nkK71+In+t7klcu7W4NeVCC6Loxn2a7C6HHs1LKnOWnTy1zA7wJ64cwYJfhWlzbFSM5J9am8vaU8kTI1EvzAh0mGA90lC1im+TLn77jTyXxd/9wdIvUCSSN8Oprrk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712851578; c=relaxed/simple; bh=btBuaAPySyacvFLoesSF8jmcxuZmKLyhOW9rUao98hE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IJ0f/eQ+DjjMnyzP3vKAF5L+NImgJhYVeMQ2ODI3OiV8/Fv/3Vfr8dHB/eu0jV0tMVHgyTjrxpXTCiHQSbrfKCYZUbfxppgLJl/ZAYp5zTvTerck3jwLpYWigZAI1RtAmlTN4nrUZW872XRMZHQ1KDIQsUrTksXMsvi86Y16uyc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dBjNsDOQ; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); } -- 2.43.0