From patchwork Mon Feb 17 15:34:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13978090 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DDBEC021A9 for ; Mon, 17 Feb 2025 15:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Subject:Cc:To:From:Date:Message-ID:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=5GzUE8+22PDvx9TU35PcoTRaUTTz7IbxNCev5oEIp2I=; b=0vW40eIT+m8QrM p8SCEfFGnc5X8MuWoATympx62ItIl1qLxwFAPKgw2VmLOw6mXqx5WVnhdDRTkmDT0ftPjSCT6ATvQ gUCym4rNR0Z3N6OI+wiudCrWS5EMQsT9gRU0xaO55rqsTTcYxS+03z1YKfNg746x0jqKeP7dj7cys TlwC8a+IYoi9DH45VfGs4A2BoiKi3wjGAnd3cM4wZfVR0hFrEHw4v/iEK6TpiaqB44ISWNQ6FNW/t K6Sgb20315Fy6J4eyo4cp/kMSAgKYlGoBoqmvxxKKNr9PLQevlr7/+2HkUotjAeL+7eLZbedKJjgL FT0r82V7m0ipkqsa3ORw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tk3H8-000000056Ym-47EZ; Mon, 17 Feb 2025 15:43:14 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tk38t-000000053yk-1z9g for linux-arm-kernel@bombadil.infradead.org; Mon, 17 Feb 2025 15:34:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=5GzUE8+22PDvx9TU35PcoTRaUTTz7IbxNCev5oEIp2I=; b=f42h6zekR8E003dFaSQZ3+S59X hPOGI8ryHsmk3ZC5mhvpCl14RUmayquRAZRFVlEAhutDauriAY89QCIuzm8pJwoxj1rIg+5IUwPh9 sZaf/mbAwk6lPcBAnfhkWz1pISD7alxOlf6BDX1k51Vbhe4EQCXn3NUQFXs2x0c6DllmcIGOJbiCI zNYPSw3dqvPsQOxsst7waJhmmuIWRMXfB0Pnr2JWRgGnUWADiTZOSrS69ccOfvSaBkx9FzX98Wlli L3SM/5nnyqSRi2sLiHbJPzJpUWA18EGSRedc6t3O3Q4+MJIYiHjjr7kZwg9JQ/jVPnSwA1EmHtwHh 8VvgS53A==; Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tk38o-00000001qnd-2nVm for linux-arm-kernel@lists.infradead.org; Mon, 17 Feb 2025 15:34:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 75C57A4162A; Mon, 17 Feb 2025 15:32:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DE74C4AF13; Mon, 17 Feb 2025 15:34:34 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tk393-00000003aLr-3wJu; Mon, 17 Feb 2025 10:34:53 -0500 Message-ID: <20250217153453.792481985@goodmis.org> User-Agent: quilt/0.68 Date: Mon, 17 Feb 2025 10:34:06 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf , linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Peter Zijlstra , Linus Torvalds , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Zheng Yejian , Martin Kelly , Christophe Leroy , Josh Poimboeuf , Heiko Carstens , Catalin Marinas , Will Deacon , Vasily Gorbik , Alexander Gordeev Subject: [PATCH v4 5/6] ftrace: Update the mcount_loc check of skipped entries References: <20250217153401.022858448@goodmis.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250217_153438_915030_D457D84B X-CRM114-Status: GOOD ( 14.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Steven Rostedt Now that weak functions turn into skipped entries, update the check to make sure the amount that was allocated would fit both the entries that were allocated as well as those that were skipped. Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index e3f89924f603..55d28c060784 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -7111,7 +7111,29 @@ static int ftrace_process_locs(struct module *mod, /* We should have used all pages unless we skipped some */ if (pg_unuse) { - WARN_ON(!skipped); + unsigned long pg_remaining, remaining; + unsigned long skip; + + /* Count the number of entries unused and compare it to skipped. */ + pg_remaining = (ENTRIES_PER_PAGE << pg->order) - pg->index; + + if (!WARN(skipped < pg_remaining, "Extra allocated pages for ftrace")) { + + skip = skipped - pg_remaining; + + for (pg = pg_unuse; pg; pg = pg->next) { + remaining += 1 << pg->order; + } + + skip = DIV_ROUND_UP(skip, ENTRIES_PER_PAGE); + + /* + * Check to see if the number of pages remaining would + * just fit the number of entries skipped. + */ + WARN(skip != remaining, "Extra allocated pages for ftrace: %lu with %lu skipped", + remaining, skipped); + } /* Need to synchronize with ftrace_location_range() */ synchronize_rcu(); ftrace_free_pages(pg_unuse);