From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B0B62347FCD; Thu, 2 Jul 2026 16:39:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010350; cv=none; b=Es28+dReOI21ZRff2iF62AiugB6xiBvGSNvrLTC0e6QtFG1bbMPPmVnJLMTNqcpV4/tMmq5D5Q4dWp3AkYS1Pt0lkJth8OTSP7oTIuFlt5JSyD90LTB4JYQ8gyew98jzeA9WCqqYJLk5QgTBtn5mVYttFhxIq/uTdqy54s41lv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010350; c=relaxed/simple; bh=GHnFepdZXIQxV0rzYT81M5DAwaLcHY3O6pCZdjWWUeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ii8mOW+UxwqspJBL9RwpeGfyNQoXLxz4jXZB3B1N12Je08RJu4ITTtVoNyH9i98oV8AmOHEYRj7jCQkdukdpCeyJL8IVvDK6AD5sqCn6dCEEOe5XGhtcn3iMUfwArBNS7o5BYKI+QCT9zJFEH8nnw36h1R4yugCL+HE4Bm3Rc/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TPQfL39a; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TPQfL39a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB6921F00A3A; Thu, 2 Jul 2026 16:39:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010348; bh=uvpSEFZRv3AShJspKNduuhkhgSIPOIYZompZDzN++ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TPQfL39arJbuDQYT+t7DmFRzuxmc3FPgF0c2jBKbKB+Jy36Oo5RUXUedMSmGRsTSA unL3cr4CYSuD+n1aLvZK+TF2Rv7ymQTGagIpT6N3fdaB/VLPQG1AG95d6ssKL7HyHF SV9ERydFLri0aYJxA+2GuG3gVJOocwYyRE16OBnQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, bpf , 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 , "Steven Rostedt (Google)" , Andrey Grodzovsky Subject: [PATCH 6.12 076/204] ftrace: Update the mcount_loc check of skipped entries Date: Thu, 2 Jul 2026 18:18:53 +0200 Message-ID: <20260702155120.262197363@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steven Rostedt [ Upstream commit 4a3efc6baff931da9a85c6d2e42c87bd9a827399 ] 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. Cc: bpf Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Masahiro Yamada Cc: Nathan Chancellor Cc: Nicolas Schier Cc: Zheng Yejian Cc: Martin Kelly Cc: Christophe Leroy Cc: Josh Poimboeuf Cc: Heiko Carstens Cc: Catalin Marinas Cc: Will Deacon Cc: Vasily Gorbik Cc: Alexander Gordeev Link: https://lore.kernel.org/20250218200023.055162048@goodmis.org Signed-off-by: Steven Rostedt (Google) Signed-off-by: Andrey Grodzovsky Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ftrace.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -7155,7 +7155,28 @@ static int ftrace_process_locs(struct mo /* We should have used all pages unless we skipped some */ if (pg_unuse) { - WARN_ON(!skipped); + unsigned long pg_remaining, remaining = 0; + 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);