From: Beau Belgrave <beaub@linux.microsoft.com>
To: rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, dcook@linux.microsoft.com,
alanau@linux.microsoft.com, brauner@kernel.org,
akpm@linux-foundation.org
Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v4 10/11] tracing/user_events: Charge event allocs to cgroups
Date: Fri, 2 Dec 2022 15:51:37 -0800 [thread overview]
Message-ID: <20221202235138.450-11-beaub@linux.microsoft.com> (raw)
In-Reply-To: <20221202235138.450-1-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.
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
---
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 3fdf5c79c1e5..ae8727560538 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_KERNEL);
+ enabler = kzalloc(sizeof(*enabler), GFP_KERNEL_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 = kmalloc(sizeof(*user_mm), GFP_KERNEL);
+ user_mm = kmalloc(sizeof(*user_mm), GFP_KERNEL_ACCOUNT);
if (!user_mm)
return NULL;
@@ -652,7 +652,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;
@@ -860,7 +860,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;
@@ -879,7 +879,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);
@@ -1165,7 +1165,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;
@@ -1498,7 +1498,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;
@@ -1692,7 +1692,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;
@@ -1861,7 +1861,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;
@@ -1914,7 +1914,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.25.1
next prev parent reply other threads:[~2022-12-02 23:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 23:51 [PATCH v4 00/11] tracing/user_events: Remote write ABI Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 01/11] tracing/user_events: Split header into uapi and kernel Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 02/11] tracing/user_events: Track fork/exec/exit for mm lifetime Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 03/11] tracing/user_events: Use remote writes for event enablement Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 04/11] tracing/user_events: Fixup enable faults asyncly Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 05/11] tracing/user_events: Add ioctl for disabling addresses Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 06/11] tracing/user_events: Update self-tests to write ABI Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 07/11] tracing/user_events: Add ABI self-test Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 08/11] tracing/user_events: Use write ABI in example Beau Belgrave
2022-12-02 23:51 ` [PATCH v4 09/11] tracing/user_events: Update documentation for ABI Beau Belgrave
2022-12-02 23:51 ` Beau Belgrave [this message]
2022-12-02 23:51 ` [PATCH v4 11/11] tracing/user_events: Limit global user_event count 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=20221202235138.450-11-beaub@linux.microsoft.com \
--to=beaub@linux.microsoft.com \
--cc=akpm@linux-foundation.org \
--cc=alanau@linux.microsoft.com \
--cc=brauner@kernel.org \
--cc=dcook@linux.microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).