From patchwork Tue Mar 28 23:52:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 13191677 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 448BCC761A6 for ; Tue, 28 Mar 2023 23:52:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA62B900003; Tue, 28 Mar 2023 19:52:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0451900007; Tue, 28 Mar 2023 19:52:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B182900006; Tue, 28 Mar 2023 19:52:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 66772900005 for ; Tue, 28 Mar 2023 19:52:31 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3814C140B20 for ; Tue, 28 Mar 2023 23:52:31 +0000 (UTC) X-FDA: 80619958902.07.DA79FB2 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf28.hostedemail.com (Postfix) with ESMTP id 6377CC000D for ; Tue, 28 Mar 2023 23:52:29 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=lnDSw7kX; spf=pass (imf28.hostedemail.com: domain of beaub@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=beaub@linux.microsoft.com; dmarc=pass (policy=none) header.from=linux.microsoft.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680047549; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GLwBDStl/9V7AvgFeNpxkZhcBlWV4hLj39iIaU1+mbw=; b=77+4K1YdsydZ4o8xM+vajlLpZ2BhlcnesC0JiuZ1i6UQ71NfV7ojc2GbOjdeLHtd+rdd+C 3JxE2VP1Z2aq+Nrwp1tOfoaaEgo7uWsb7v7wijgsH0aBS1YpdSXg2lTaeuphXuQox1gght 6cjnbY3jlxdMUes/GEPowZsnWzvneJA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=lnDSw7kX; spf=pass (imf28.hostedemail.com: domain of beaub@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=beaub@linux.microsoft.com; dmarc=pass (policy=none) header.from=linux.microsoft.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680047549; a=rsa-sha256; cv=none; b=rGx49BSYFVAUJxeREtWdpB42vsJv4m3Poe4hHi/x9Aop/bqUeq6dhpTmgMNzd9n/eHTTvG qd+vgu7CH3ejuY3Ot0EW56g0mY0HA1Jlv0OLZMJ223gK2qycERW+hB8dCNiy5Xd4hwfHF3 22Au35mCXnh3zRk+ywtg6zMoHEl+f20= Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 4C5F720FDC30; Tue, 28 Mar 2023 16:52:28 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4C5F720FDC30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680047548; bh=GLwBDStl/9V7AvgFeNpxkZhcBlWV4hLj39iIaU1+mbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnDSw7kXl190S16SZ7QnjEeUWDeHKekuhDoSRnQdy0JADJ4C+EbHZWuBRIV+1REf9 kmaJYUE4Re0TJ7uYfzHBYqpzmFv1uu0IIHJDX/8wyApO9YfoSjrVSY1a/5EGpJURIc eyvkQqfYUHu7M4obR4ElQLCSixC9mOlhEv/wyPiw= 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, ebiederm@xmission.com, keescook@chromium.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH v10 10/12] tracing/user_events: Charge event allocs to cgroups Date: Tue, 28 Mar 2023 16:52:17 -0700 Message-Id: <20230328235219.203-11-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230328235219.203-1-beaub@linux.microsoft.com> References: <20230328235219.203-1-beaub@linux.microsoft.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6377CC000D X-Stat-Signature: wkres5pfi6xwy1e1ghkh3s4iwbjhuew8 X-HE-Tag: 1680047549-378092 X-HE-Meta: U2FsdGVkX18MPtiOjS9oWA3ILjOo5d61DSqVV7qVB+hM5a0tBQEmt+qC9KonAEhytyVWHszWl4H7JIVKS32OZozjSk6+7VUGDg8OOpE4ZUPqquPv4yr+ZJS+9r179cvmff7BOh6Qign6CWCEVyoGnp7OawvuXCRfhfUpjkY7ev45uXjDiGdZJq2KjJPAtogYK02uU6FR0iImcibd9VfjL2lccHYYdqz3Qq1sTx70NamXGxIK2PR6hbSqeWdDnDicz6BDHPwvcPbWnq/korq6Y35ndLDcmt8BxRDnE0Ex7hl8LFbkuxKWNrrzdvNRKUct+yBeXPi3br8lPv16lv42oDdhmXPJXURi2rzIG9epxv6Z/SIietYJq/E3VQlXIEukNrHFZ4CVNW/7iUdJARRhqOkLRNPgKsw/mvEdof2Clh20PrXVyT9ZgWr41TzDcNR2wuxj3MeS+HVALJDrqD3WBcnOuwuVih8iyTVGyYC4OsqOBDNuoP/aLHOrMpw5qEebpN/5Zkyqd6oe5DRot933SWPUeEYijWL40uB8JJibssUL/mO7y72iHAfWK08quyzhoAJZYXWv4p/+2t15BM99xcGf1BKmnVFr7gcqWp/T6Krv/b9W4erGcxgodcwe2Sib++X9SCrBqIJf4AJAplauJDBaoofa2GlmRmw5R/T0Za7dU3HJrn23Z/nWLls7sxH2f5bOd+W3/WMDIwYABDBGVydW9C1XnMyz8GM2/6SHXGIwd8ZxJGhVHUN+wIXNNi3Y8GDFjgxY/CTnJl6peOy7irSLca8zn9OT6bCj+CbDs+dyKVX+GyCn0jMUjP4qOrYZoXnzi/Dioy3KASLL6IP+FP+IfLVu/N4kUe5A21+IpR4dWu1fb1gSV+08N2x6SRZYMOOt6+xfkd3DRVwNZUQisyCAAzKctCHIo9yQz6v6Kcd1GLNjjdyTa2XezVwrq83cU7Pm0kx9rd8EK3TZULH dF64XSpd zrkczgXEzFiY9sm3nXmraw53hMzBDaUKtrhrOybJu4OJ5b21cUBVrRGy9ACLORQ6iwOd/1nJ2JzK8s74YKdVde6aT3dg4n7yBwW5fmGZ/bzVnQ3iV7Rv2X+h/49pu1TR8YOi8T2A3ER6sji4UU2SqOr1V2aE2DRMyei+ed5iV1FxTNwHDMrIP+FY4s2ne2B6gzIKnT2b+dg06fAr6P/+zbh9Eg56Io8CnbvUpC9u7jaWgYhgtJxrj6+ozmKm0RkSPOGZYyjlElctiXtExm0vs49AfmcbiD9HY2A0WS3Z/IhE0tZc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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_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;