All of lore.kernel.org
 help / color / mirror / Atom feed
From: Beau Belgrave <beaub@linux.microsoft.com>
To: rostedt@goodmis.org, mhiramat@kernel.org
Cc: anders.roxell@linaro.org, linux-trace-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-next@vger.kernel.org,
	beaub@linux.microsoft.com
Subject: [PATCH] user_events: Use alloc_pages instead of kzalloc for register pages
Date: Fri, 11 Mar 2022 14:30:28 -0800	[thread overview]
Message-ID: <20220311223028.1865-1-beaub@linux.microsoft.com> (raw)

kzalloc virtual addresses do not work with SetPageReserved, use the
actual page virtual addresses instead via alloc_pages.

The issue is reported when booting with user_events and
DEBUG_VM_PGFLAGS=y.

Link: https://lore.kernel.org/linux-trace-devel/CADYN=9+xY5Vku3Ws5E9S60SM5dCFfeGeRBkmDFbcxX0ZMoFing@mail.gmail.com/#R

Reported-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
---
 kernel/trace/trace_events_user.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 2b5e9fdb63a0..59c900789757 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1587,16 +1587,20 @@ static void set_page_reservations(bool set)
 static int __init trace_events_user_init(void)
 {
 	int ret;
+	struct page *register_pages;
 
 	/* Zero all bits beside 0 (which is reserved for failures) */
 	bitmap_zero(page_bitmap, MAX_EVENTS);
 	set_bit(0, page_bitmap);
 
-	register_page_data = kzalloc(MAX_EVENTS, GFP_KERNEL);
+	register_pages = alloc_pages(GFP_KERNEL | __GFP_ZERO,
+				     get_order(MAX_EVENTS));
 
-	if (!register_page_data)
+	if (!register_pages)
 		return -ENOMEM;
 
+	register_page_data = page_address(register_pages);
+
 	set_page_reservations(true);
 
 	ret = create_user_tracefs();
@@ -1604,7 +1608,7 @@ static int __init trace_events_user_init(void)
 	if (ret) {
 		pr_warn("user_events could not register with tracefs\n");
 		set_page_reservations(false);
-		kfree(register_page_data);
+		__free_pages(register_pages, get_order(MAX_EVENTS));
 		return ret;
 	}
 

base-commit: 864ea0e10cc90416a01b46f0d47a6f26dc020820
-- 
2.17.1


             reply	other threads:[~2022-03-11 22:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 22:30 Beau Belgrave [this message]
2022-03-11 23:33 ` [PATCH] user_events: Use alloc_pages instead of kzalloc for register pages Steven Rostedt
2022-03-11 23:44   ` Steven Rostedt
2022-03-11 23:55     ` Beau Belgrave

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220311223028.1865-1-beaub@linux.microsoft.com \
    --to=beaub@linux.microsoft.com \
    --cc=anders.roxell@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.