From patchwork Thu Mar 23 19:06:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 13186007 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 75206C6FD1C for ; Thu, 23 Mar 2023 19:06:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA7576B0081; Thu, 23 Mar 2023 15:06:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C56DF6B0082; Thu, 23 Mar 2023 15:06:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1E686B0083; Thu, 23 Mar 2023 15:06:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9440C6B0081 for ; Thu, 23 Mar 2023 15:06:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 640C2407A2 for ; Thu, 23 Mar 2023 19:06:21 +0000 (UTC) X-FDA: 80601093762.01.4D6FC43 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf23.hostedemail.com (Postfix) with ESMTP id 9F520140020 for ; Thu, 23 Mar 2023 19:06:19 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=EfKnlK7i; spf=pass (imf23.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=1679598379; a=rsa-sha256; cv=none; b=cjcIVGSYXobWPyRv/jjMEu2huZlo1iNgu5SDT+lTGjEJ6wkXcDWoUtOo3RxANQ0xP9+z3L XndWjDz3WIjmf0/Y2vTJsqGjODcJXVz92RuGQ4USzm0ARRblMhS5U6MM27TgZZ8c58dP8Q p3Hc/v/jwMlP884bjD8oZI1XEaSqvLQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=EfKnlK7i; spf=pass (imf23.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=1679598379; 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=IeyP4hszPxXQh3EfDrorhwGAyqHtWNJ8d/cCBZiRrsA=; b=k2Vj7TCi57u0R1rYrbUs4u0Qdh69J9pRK0wVC8fKezARYTukH9Fvg8Xfh/Of2pJbeHHc9w Qm3H2/JsRRMQGDAx5f3roUjKhmo+n6LxQU0WyatygTMYjT5YJwI2otHoxjUw+H2TMPpeFF 7z2ORcR6IyC6RBG/65BEhnuugoT7qy4= Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 4A39B20FC3DB; Thu, 23 Mar 2023 12:06:18 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4A39B20FC3DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679598378; bh=IeyP4hszPxXQh3EfDrorhwGAyqHtWNJ8d/cCBZiRrsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EfKnlK7ie91+JWQuzGeux+r1OouVbdyw5cZV/Gy6GM4l20qRWT/ys7CYOjDmpcVSd E519AOwKHNkh3mEfDJa5NggLTDkb/V4FYswrmE2O6Ow9tc5m2w8gQXGRVBNRuZ5tCl EttGf1S+GuVT7g2/HJxZhVjie1a5zQHbaVu/zYi4= 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: [RESEND PATCH v8 10/11] tracing/user_events: Charge event allocs to cgroups Date: Thu, 23 Mar 2023 12:06:09 -0700 Message-Id: <20230323190610.251-11-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230323190610.251-1-beaub@linux.microsoft.com> References: <20230323190610.251-1-beaub@linux.microsoft.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 9F520140020 X-Rspamd-Server: rspam01 X-Stat-Signature: 5orcxfz4twsjmziw4pps9ta41wcuehui X-HE-Tag: 1679598379-475977 X-HE-Meta: U2FsdGVkX1+UBjWbgh6iDW4/1jIquMrJ7jw2tQW4BFld/zFwliBzyFDrlOqjsYraO41BMZW0kiMcuX4btJahUush2cxlDW5KBaljUSyEtH1Zs1tya4Wa5kbbBYgToKAy+lu8cTe4R8IHQOZOHRlEaUrK9PNK3KOT5EvG7x2GSTjEXddaEHzcn0QNk/zeM8wMjfLSTkJAm2gKJXiVgq3giKBFL/EwFjHKO3uBnv1pkl41uG43NvmANGp63ELYqQZjC3wkgo8MzU51/nXo0N+NY5AkIUzfbMpZV+4Onmi8TSZSvFHz1JxABRUyFuLavCgAbR/5TapFhZw0saDaCsB0g+nzS5yxUnURgqBjeNPFyo9aX5RmnfkgaAE0A2eAlTjggYhkEGPyER4UERJGaIcBWCgjpKXWdEqY1uxLynv/XdNk6+YZX43FJqWscmaPo7H/Bc2t/hyyvDVKOu5YHJ4aztsCodubZKPKKZ4adM6ISxdTGFHgb2I38c8D20bb3SY3UmJvRu4wd53RjwyxO5A3m1Yn1GTPRM1SZghmPFBKdOQYAuMdTT5M18QzqO+S+eRkOlAQnmaQvbQtnl4WISG8S1+AJIjXVGjIUqIDB6vsEUIIVoW+dn4c+RZNQ49x6Q+BO63/7qO830D6u1tNdZGec6kjzlZh8t1JDdmgaWXdperW9/5mhavUI3cMaeoGQwLhF9D0tBM5Uc8RMPwPke6V38r6DRhL56aQQcmH4t7QA/0DlWr9dtT7H3Wl3b4lB373Oli9KZJesS0C2Cbnkm2ZYYWtHXYNYvoc0NvTb40yWhshvx6M/p7W1XG/CKDAfUQBkbt6jVClgtcJkBOcR4xPmMYKE2q6eWUOCi7wsCkYci7b+dlB8tbBLxGmg5AewA+t6kZlHRQrwc8HfvOFI6ML0fmQpQ2CXzrCZyLeSJ5jupnhUBblnhQ1QLG4rSkeO7+B+lVlG3vMIJX1EgO13BK pL0bK3fr T6odo8XEsBoLgoOmchkdK+s8qCHNJq0YL9xzgWDkX8W+81BBeqVRsVmOjcxLSjo6wq+banC2g5xcAlH+wKUHrgaKL1uejVRZie2p2l0NGSpQSqClqW/8SWnUvMF0STMzBy8shEIfKs2mWEZsrs41kCOOBlBs9B78a5Sbup+DhpX7AF642XMPsZgjZYwSEeR3BzscbjrkBLZidvIrBCJolB7YoegrbaNhG/n0DsldhSPvZTGk/nX7GNFkgnLOcIYQGdxVxyZYNkFGE/Oj1+6ZMCq2xAZ/ppTDnY3BGYJT7Ug8ZPGU= 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 e4ee25d16f3b..222f2eb59c7c 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;