From patchwork Fri Mar 24 22:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 13187435 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 BB018C76196 for ; Fri, 24 Mar 2023 22:31:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EB51900005; Fri, 24 Mar 2023 18:30:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4747C900004; Fri, 24 Mar 2023 18:30:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29FC0900005; Fri, 24 Mar 2023 18:30:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 10D6A900004 for ; Fri, 24 Mar 2023 18:30:48 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E301B160A59 for ; Fri, 24 Mar 2023 22:30:47 +0000 (UTC) X-FDA: 80605237734.10.624C047 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf01.hostedemail.com (Postfix) with ESMTP id 31C914000E for ; Fri, 24 Mar 2023 22:30:46 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=sI8mD6Xb; spf=pass (imf01.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=1679697046; a=rsa-sha256; cv=none; b=bKWeVB54JG6V8FPoenlkln+ywFleqkjcYh1uNYYvp61Uh+34PX7SM1pLeunVBt0YGWRRpI mVoJUfkpNsOtuxQp5+/LDy3j6EZU7ZiaMhu5LEWqcR5eHynjhLox5xlkq8qXOhT5HmfRhd Mrxz7a//m3f7n0j1XZjrBS4mrec+N5I= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=sI8mD6Xb; spf=pass (imf01.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=1679697046; 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=eIw6s9h2R0BdpXArJd2boh/JppD1FJ+OyPFgpZ3XyhT8MTU5XRxGrOcBYSZf2qTfnVziUN PZ6f6eUy5qXkJGw0STo5+Jv9f+56f9uzJjBNKpgRx/9gu9eBP378CbuQPzt1SBQvpuDiQi 14QB8TS0OWT2iRLNRkuOfzaia6DLQRw= Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 5E8C520FC4F6; Fri, 24 Mar 2023 15:30:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5E8C520FC4F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679697041; bh=IeyP4hszPxXQh3EfDrorhwGAyqHtWNJ8d/cCBZiRrsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sI8mD6XbffTrTe6OV9fXtMnS45eeEG7fqfdRdFdd2DhDmRcMeiKnuvsF8EsWN9Xm/ QrVESBXRc5aGxq8fimVJdnf+vapiCdTa/vFnANgrNRXFWxFrY2PMTJyZSakgWmcS9Q 6X5aYMJwRcGgw9nQlU98ZqSA7dUO3AAwTqx0Zbyg= 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 v9 10/11] tracing/user_events: Charge event allocs to cgroups Date: Fri, 24 Mar 2023 15:30:27 -0700 Message-Id: <20230324223028.172-11-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230324223028.172-1-beaub@linux.microsoft.com> References: <20230324223028.172-1-beaub@linux.microsoft.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 31C914000E X-Rspamd-Server: rspam01 X-Stat-Signature: 1qe4na5cqgiw58kcqqfp1fjmnbdruk8c X-HE-Tag: 1679697046-743204 X-HE-Meta: U2FsdGVkX186jP6C4GEdp+ewc8N3+7w8n19JgtFj4kfFg/pIjXTd0PdMuTO2Tvlza1tDbmu0D5dv1u22Vlk9LjuFBzPyS1/r65nqcpNuMct0PeP7rcGY8nT16hefkNU44F+jblhjk+ywx8ufx7Dl0ZvbqzAKgYqXbFlVZ9g6tqD8hRtoi37pSL5bn5ymTXEMrjtzVu1AzoO3VjOOmQnuuS8umSoaLX1eb9f07uFpI1VHYlkhzeKYWPqX2A7FC8luHgMEal3zn2AQ9An/ekGnElkm+qDBD5XZOHio6/LRsW7bVT74AtTWWkBT9XaK1/5nEdY6Fuo/ExDRibQXjjam58XBv8d+Lqtl6+gRX+cSvv2dAOfRc4Do5GlnALWbeAEL0e9q3WHOyJPrjT5BfY0W18lZ25O4HwzH33xD0yBVE/StgeeYIAEIzAnlqtrq6QzrYPE1K3nLAKQuo0a58X2OiCaPrUoMudlNj68Zzyd9gLkkluT4Z9Jn7jvHk8uZnyQkzkGJAK8q8kx1jkxihJUjbB1ZR+0bp1najDq/euQpNbNGHukUi4byVwNK3sohMCGJTZgkSyaW3spEwewI4XVdoN2gjFAx0/dpH73oD8G1Pnw4cRjSj96YoxoZtqL+OKmyUHQYlfokpDbKVIEaYPcWdiDRQeFnmLp1BPeKg9V03XcdL6SLT6dWgjbDxJeO/XeT8lnmhZBEaLNlxGkZuChc6U7Pg65TeSCGC8Q8Z4wSh4j/my2Zf0QAFIx+glr4NUQS8+NhVSOQeFaOB74WE9YE9BY63reyGRZalynaXkLtBjUQdm5vVYdEUEZs5ERctxWBXlmzQoovvXX12fDFfM+8D7lGVYToPFxk8BnubEbr7lXS/CVFLheCRQHpVrjVHd0EkqjDHqq+gb+nGCJCIR8XHks9p9ZJ1xI3SlQDb4LniTHdD/Nl5VFBCYhUFbbWkA2gCpXfdJpYohEf8uh2BoO uXGFJm+h Tv7j5kdRUDxxgKAC7dX74t0bTCQfUFp/QJU3otrjHQdu0mxJL34TjxCe4IpY7bnLw9pnIuwCaFlU7WldfXPHsRnI7l6VgUiwnt2Vkjgr8XJugulKZVqSyP6FkbwRtvsHxCyQTNyXzyBebnQ29ajKpukUeynrW8xkZHUtx/jxNPzuJbTUQ9c0YMp0CYfMfiGlVnWhut27ur+FeQJXyySjGDLe3Q0H241qcep4xq9xV/6Hvtk7gkBI1vqerlBEy/Myc7VcCx7XQQiWLUxRWXj7ZO1QUkzwgqS7pwiEUHGsMiKPSQNE= 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;