All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Beau Belgrave <beaub@linux.microsoft.com>
Subject: [for-next][PATCH 21/25] tracing/user_events: Charge event allocs to cgroups
Date: Wed, 29 Mar 2023 15:45:37 -0400	[thread overview]
Message-ID: <20230329194553.300997623@goodmis.org> (raw)
In-Reply-To: 20230329194516.146147554@goodmis.org

From: Beau Belgrave <beaub@linux.microsoft.com>

Operators need a way to limit how much memory cgroups use. User events need
to be included into that accounting. Fix this by using GFP_KERNEL_ACCOUNT
for allocations generated by user programs for user_event tracing.

Link: https://lkml.kernel.org/r/20230328235219.203-11-beaub@linux.microsoft.com

Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_user.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index f88bab3f1fe1..3a01c2df4a90 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -442,7 +442,7 @@ static bool user_event_enabler_dup(struct user_event_enabler *orig,
 	if (unlikely(test_bit(ENABLE_VAL_FREEING_BIT, ENABLE_BITOPS(orig))))
 		return true;
 
-	enabler = kzalloc(sizeof(*enabler), GFP_NOWAIT);
+	enabler = kzalloc(sizeof(*enabler), GFP_NOWAIT | __GFP_ACCOUNT);
 
 	if (!enabler)
 		return false;
@@ -502,7 +502,7 @@ static struct user_event_mm *user_event_mm_create(struct task_struct *t)
 	struct user_event_mm *user_mm;
 	unsigned long flags;
 
-	user_mm = kzalloc(sizeof(*user_mm), GFP_KERNEL);
+	user_mm = kzalloc(sizeof(*user_mm), GFP_KERNEL_ACCOUNT);
 
 	if (!user_mm)
 		return NULL;
@@ -662,7 +662,7 @@ static struct user_event_enabler
 	if (!user_mm)
 		return NULL;
 
-	enabler = kzalloc(sizeof(*enabler), GFP_KERNEL);
+	enabler = kzalloc(sizeof(*enabler), GFP_KERNEL_ACCOUNT);
 
 	if (!enabler)
 		goto out;
@@ -870,7 +870,7 @@ static int user_event_add_field(struct user_event *user, const char *type,
 	struct ftrace_event_field *field;
 	int validator_flags = 0;
 
-	field = kmalloc(sizeof(*field), GFP_KERNEL);
+	field = kmalloc(sizeof(*field), GFP_KERNEL_ACCOUNT);
 
 	if (!field)
 		return -ENOMEM;
@@ -889,7 +889,7 @@ static int user_event_add_field(struct user_event *user, const char *type,
 	if (strstr(type, "char") != NULL)
 		validator_flags |= VALIDATOR_ENSURE_NULL;
 
-	validator = kmalloc(sizeof(*validator), GFP_KERNEL);
+	validator = kmalloc(sizeof(*validator), GFP_KERNEL_ACCOUNT);
 
 	if (!validator) {
 		kfree(field);
@@ -1175,7 +1175,7 @@ static int user_event_create_print_fmt(struct user_event *user)
 
 	len = user_event_set_print_fmt(user, NULL, 0);
 
-	print_fmt = kmalloc(len, GFP_KERNEL);
+	print_fmt = kmalloc(len, GFP_KERNEL_ACCOUNT);
 
 	if (!print_fmt)
 		return -ENOMEM;
@@ -1508,7 +1508,7 @@ static int user_event_create(const char *raw_command)
 	raw_command += USER_EVENTS_PREFIX_LEN;
 	raw_command = skip_spaces(raw_command);
 
-	name = kstrdup(raw_command, GFP_KERNEL);
+	name = kstrdup(raw_command, GFP_KERNEL_ACCOUNT);
 
 	if (!name)
 		return -ENOMEM;
@@ -1704,7 +1704,7 @@ static int user_event_parse(struct user_event_group *group, char *name,
 		return 0;
 	}
 
-	user = kzalloc(sizeof(*user), GFP_KERNEL);
+	user = kzalloc(sizeof(*user), GFP_KERNEL_ACCOUNT);
 
 	if (!user)
 		return -ENOMEM;
@@ -1874,7 +1874,7 @@ static int user_events_open(struct inode *node, struct file *file)
 	if (!group)
 		return -ENOENT;
 
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL_ACCOUNT);
 
 	if (!info)
 		return -ENOMEM;
@@ -1927,7 +1927,7 @@ static int user_events_ref_add(struct user_event_file_info *info,
 
 	size = struct_size(refs, events, count + 1);
 
-	new_refs = kzalloc(size, GFP_KERNEL);
+	new_refs = kzalloc(size, GFP_KERNEL_ACCOUNT);
 
 	if (!new_refs)
 		return -ENOMEM;
-- 
2.39.1

  parent reply	other threads:[~2023-03-29 19:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 19:45 [for-next][PATCH 00/25] tracing: Updates for 6.4 Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 01/25] fprobe: Pass entry_data to handlers Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 02/25] lib/test_fprobe: Add private entry_data testcases Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 03/25] fprobe: Add nr_maxactive to specify rethook_node pool size Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 04/25] lib/test_fprobe: Add a test case for nr_maxactive Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 05/25] fprobe: Skip exit_handler if entry_handler returns !0 Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 06/25] lib/test_fprobe: Add a testcase for skipping exit_handler Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 07/25] docs: tracing: Update fprobe documentation Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 08/25] selftests: use canonical ftrace path Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 09/25] leaking_addresses: also skip " Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 10/25] tools/kvm_stat: use " Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 11/25] tracing: Add "fields" option to show raw trace event fields Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 12/25] tracing/user_events: Split header into uapi and kernel Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 13/25] tracing/user_events: Track fork/exec/exit for mm lifetime Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 14/25] tracing/user_events: Use remote writes for event enablement Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 15/25] tracing/user_events: Fixup enable faults asyncly Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 16/25] tracing/user_events: Add ioctl for disabling addresses Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 17/25] tracing/user_events: Update self-tests to write ABI Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 18/25] tracing/user_events: Add ABI self-test Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 19/25] tracing/user_events: Use write ABI in example Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 20/25] tracing/user_events: Update documentation for ABI Steven Rostedt
2023-03-29 19:45 ` Steven Rostedt [this message]
2023-03-29 19:45 ` [for-next][PATCH 22/25] tracing/user_events: Limit global user_event count Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 23/25] tracing/user_events: Align structs with tabs for readability Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 24/25] tracing/user_events: Use print_format_fields() for trace output Steven Rostedt
2023-03-29 19:45 ` [for-next][PATCH 25/25] tracing: Unbreak user events Steven Rostedt
2023-03-29 20:29   ` Steven Rostedt

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=20230329194553.300997623@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=beaub@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.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.