From patchwork Tue Feb 21 21:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 13148407 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 58A5DC64EC4 for ; Tue, 21 Feb 2023 21:12:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C012D6B0083; Tue, 21 Feb 2023 16:11:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BDD5B6B0082; Tue, 21 Feb 2023 16:11:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2B156B0087; Tue, 21 Feb 2023 16:11:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8E89A6B0082 for ; Tue, 21 Feb 2023 16:11:55 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3AC531C1D2E for ; Tue, 21 Feb 2023 21:11:55 +0000 (UTC) X-FDA: 80492546190.27.9F4DE58 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf16.hostedemail.com (Postfix) with ESMTP id 5544E180007 for ; Tue, 21 Feb 2023 21:11:53 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b="DFb/gknM"; spf=pass (imf16.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=1677013913; 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=FGUHppw0eN3RvWjsOvRhSzClNxI6jmBbdioRR5OCadvOdRz2U3CekrhvAwn5zepZYOEHy8 BI2rOuzSl8U86iJQGKW6txMojSPp/st9Yfosnh9J5i5BSMKaoIU+Vc1vbhsFDHPlnSawUr 1j8g+6oQ3WReg7B9Qj+7bcROsxy5Fno= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b="DFb/gknM"; spf=pass (imf16.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=1677013913; a=rsa-sha256; cv=none; b=e44M900hl+CzKJLqElxNZlzbRSJ4bSv8Ivj92mg94tsPYEwEcV1YQyeKH1Kv1cXpt/8ZBi K0NusP0aLOpuZZp+EknXM49QOtIJPsSyB71/6K5GC59tkZbiuFZX7r/Cet3CQil6L+Y8I1 Jnr2u6VU0waKdgKAegzgoQoLA36ILFk= Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 517E720BBF92; Tue, 21 Feb 2023 13:11:52 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 517E720BBF92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677013912; bh=IeyP4hszPxXQh3EfDrorhwGAyqHtWNJ8d/cCBZiRrsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DFb/gknM+mi/vihppHUU0KM7C+O4SVHVXHJmj8uZTYF5D/ikRqZp6FkFJIs+BTzb2 ZR2UW1qpSfHJN9gEd4YxwjrKcOfHckBDudI60lWN0AmRkWs+x7fdhwIeuIhDGkNMAE GhoVZnVd60BQ8o8Y/Tyos70WS5dq1Xlfu0faEm1k= 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-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v8 10/11] tracing/user_events: Charge event allocs to cgroups Date: Tue, 21 Feb 2023 13:11:42 -0800 Message-Id: <20230221211143.574-11-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230221211143.574-1-beaub@linux.microsoft.com> References: <20230221211143.574-1-beaub@linux.microsoft.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5544E180007 X-Stat-Signature: eem1tmax1xqg5d6diqfgw7au5471t97q X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1677013913-622771 X-HE-Meta: U2FsdGVkX18fA+OpKZWlIhkhu+n5SntAlu2p693SLXcs1AFEq5wpbnmZ+bXmB89WNqF3P5ZBWbDXrivNvpTMSIa6tBJ3bAtkvhcoFlt+OPKYRoSEd7CFnr/dGbrQNdFMwC/jmFLWe6C/FM9kphMZIUtRj85D7KyefHXAJBPL0+EslnjAYc230aLj6mHXGqvkq16gvle2MJAGzeZsxWypaNlv9Cs4bB7jDmLG0nKft+oMaz4Pu+z8TRLR+X1J1h6lLwthJiHOsKwJSSo01X+Ea0ARm1aMjHbIe9ndX9l8yo+J4M6NNhyT3+ggFNrYjSyYJ9mjbfuanrSEGpZlPDfpEZu7KVkRGnNwf/jGNgsi6i19M554RS5CxVkSkV/0qms9EnGkxbqZpLbITXSUc28sNmIEvxnyNHYGYLht71IOLEgB1GEe15SEEElYY2oM4/t+YGp8/Ol3v577FjLja7pAbOw58MkGbVx9ripvNTlmZkum8ju6Dqr5Bo/5GlIlBu1SYmbwIG0IFSiTHzSrzYa2XOCvAl8ACwdJ/N9NiWDDmjT4jgFi4jxffiFkPbEoDYVLMCDqquimHNLkGmSVrrpLQMWOAK+sE4tTNbUMhDlMwvNEQxoiV46WBi68jQCAwrfHYhQIvMkGH0zNqlKitf9gbGn/Ocjkl6LJdcjABayRBTCTAdPMoN6aTspCgtI6nnRGUs9BtRG/5QIldS7F8XqQ6D1tXdwHmthzbF73RiTxyHMSgUe2zO85mju43f6n0U3byLqUZtrSKzDA1DVLs5tvEklOOR3lmQHTTh8s9LjsmikcJ39wrI+U5GjYupe3rfwABycs/9RJWGysGpaxlskhr2yeVRPxTF4BoFa9XMaLegbfqsT9GB0H8MW6kdI2kTEtfXYG1+2qZzyq1bEdZznsLgiRwEGini9A+LMj85jD4FGpHpkJigRSynJWonjaR/cetfJ24TgjL5kIweQL9Vn j+LQZEmc l9ijZYiwOj/5wQUhrDrrZAw0h7FkSUtrIWb/T++RSXIrbMuSJ5vYf3V1oDiglU6T0HyDs2dQL8X3F42Ix+MqiLcu5pCvauZMSNdSpoBK7g1pw+XhMyjrosDW178xTX42sQTF3WC4AB7x/Ndx+SQfEWaMCUBdrL9HWPb+Apd0g5uLMJxH9XuvvwDnXP2q+FZjlWTCRsaDB/R9KfVtPltzQv3iseb6yi4l4tYO8a2vqwxter423NoLy3jOdMK+PzTNi5OKXzKtpiMNQvpp+LKhskVCsGXdTyzd+dSX9J3Sdybqw6wU= 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;