From nobody Thu Sep 18 20:21:59 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73A5EC4332F for ; Fri, 2 Dec 2022 23:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234950AbiLBXwP (ORCPT ); Fri, 2 Dec 2022 18:52:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbiLBXvr (ORCPT ); Fri, 2 Dec 2022 18:51:47 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55ABAFC80B; Fri, 2 Dec 2022 15:51:47 -0800 (PST) Received: from W11-BEAU-MD.localdomain (unknown [76.135.50.127]) by linux.microsoft.com (Postfix) with ESMTPSA id 07F2520B83F9; Fri, 2 Dec 2022 15:51:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 07F2520B83F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670025107; bh=4B+hoTP7POnFUmX9nsdG4gX/u7USendWfPsG/2q1TRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UHft+uRfhXKxPnFXYQUhCMd+8OV+qLCcBPxlX5WYNdtajIUYDinmASwJtEajr0pCY GZbvJy4WwBFF1bCal/RwaQFFf6QhXK+biiV4uRJ96l0lehjBV5/B4Jkl6fS9lX7MNM MUdGAXuDoPbX0yzWenDm96Eaaen+zhaxkqd0ygD8= From: Beau Belgrave 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 Message-Id: <20221202235138.450-11-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202235138.450-1-beaub@linux.microsoft.com> References: <20221202235138.450-1-beaub@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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_u= ser.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_en= abler *orig, if (unlikely(test_bit(ENABLE_VAL_FREEING_BIT, ENABLE_BITOPS(orig)))) return true; =20 - enabler =3D kzalloc(sizeof(*enabler), GFP_KERNEL); + enabler =3D kzalloc(sizeof(*enabler), GFP_KERNEL_ACCOUNT); =20 if (!enabler) return false; @@ -502,7 +502,7 @@ static struct user_event_mm *user_event_mm_create(struc= t task_struct *t) struct user_event_mm *user_mm; unsigned long flags; =20 - user_mm =3D kmalloc(sizeof(*user_mm), GFP_KERNEL); + user_mm =3D kmalloc(sizeof(*user_mm), GFP_KERNEL_ACCOUNT); =20 if (!user_mm) return NULL; @@ -652,7 +652,7 @@ static struct user_event_enabler if (!user_mm) return NULL; =20 - enabler =3D kzalloc(sizeof(*enabler), GFP_KERNEL); + enabler =3D kzalloc(sizeof(*enabler), GFP_KERNEL_ACCOUNT); =20 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 =3D 0; =20 - field =3D kmalloc(sizeof(*field), GFP_KERNEL); + field =3D kmalloc(sizeof(*field), GFP_KERNEL_ACCOUNT); =20 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") !=3D NULL) validator_flags |=3D VALIDATOR_ENSURE_NULL; =20 - validator =3D kmalloc(sizeof(*validator), GFP_KERNEL); + validator =3D kmalloc(sizeof(*validator), GFP_KERNEL_ACCOUNT); =20 if (!validator) { kfree(field); @@ -1165,7 +1165,7 @@ static int user_event_create_print_fmt(struct user_ev= ent *user) =20 len =3D user_event_set_print_fmt(user, NULL, 0); =20 - print_fmt =3D kmalloc(len, GFP_KERNEL); + print_fmt =3D kmalloc(len, GFP_KERNEL_ACCOUNT); =20 if (!print_fmt) return -ENOMEM; @@ -1498,7 +1498,7 @@ static int user_event_create(const char *raw_command) raw_command +=3D USER_EVENTS_PREFIX_LEN; raw_command =3D skip_spaces(raw_command); =20 - name =3D kstrdup(raw_command, GFP_KERNEL); + name =3D kstrdup(raw_command, GFP_KERNEL_ACCOUNT); =20 if (!name) return -ENOMEM; @@ -1692,7 +1692,7 @@ static int user_event_parse(struct user_event_group *= group, char *name, return 0; } =20 - user =3D kzalloc(sizeof(*user), GFP_KERNEL); + user =3D kzalloc(sizeof(*user), GFP_KERNEL_ACCOUNT); =20 if (!user) return -ENOMEM; @@ -1861,7 +1861,7 @@ static int user_events_open(struct inode *node, struc= t file *file) if (!group) return -ENOENT; =20 - info =3D kzalloc(sizeof(*info), GFP_KERNEL); + info =3D kzalloc(sizeof(*info), GFP_KERNEL_ACCOUNT); =20 if (!info) return -ENOMEM; @@ -1914,7 +1914,7 @@ static int user_events_ref_add(struct user_event_file= _info *info, =20 size =3D struct_size(refs, events, count + 1); =20 - new_refs =3D kzalloc(size, GFP_KERNEL); + new_refs =3D kzalloc(size, GFP_KERNEL_ACCOUNT); =20 if (!new_refs) return -ENOMEM; --=20 2.25.1