Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6523943rwb; Mon, 5 Dec 2022 13:41:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4tKfUpedKMsshyODBNYwRCgbQIpyAi4TZPXIwnQkH6hu63wg816m7MVogjeojs+vebfuuU X-Received: by 2002:a17:906:b103:b0:7c0:9a2e:2840 with SMTP id u3-20020a170906b10300b007c09a2e2840mr22421138ejy.404.1670276508190; Mon, 05 Dec 2022 13:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670276508; cv=none; d=google.com; s=arc-20160816; b=DroKNo4aIYmHx3wxtpUbxOpzyF5KowxaQywB/CLWvu+ii3346yiKAGmfAOXconzhGy jvQG8Ah19i/ItHOT4Y5Wg/ij8bYf5obwsOz8a8EKdFhJe1CjMCvI9bhXivPGZQ5WeXZk NYe1Quj5xT0gE2wUTX5cjyBZTZ2V5sF+jYbKq8c2vlcFDzK+U5ogImLPxb4Sj19h+xiv IyAzcUZTiMjfXRCu+95bNt2g2y9UESIMhuY8KQ6kmFKybpi1Ib2fa05I1D0BWSDKavSy uiQaID6G2vfcnj92+fumTEfUyLhHaCIbEb2szz25RWHjxYlSTf5xBhRhaOSA6K4FduBc QW3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=uNBhqwNXhSFNYmJNgFRJNFpkrMNjAHn0mdRb467MsVg=; b=O77L5P0nb0HM2R2BYuFGZoXblyonerzaKt9YB0e6nsDwOgIxm3UylVrWCt3t0GkExT 0ie8uN2JcaiaZq/km+b0OuFg7yA/wRxszeQ7cPExftnSx2Y0t1bbWyY8AZSqvIvYodeX ahNCs9+ao3ZODk8LJnlORO+z5mQFgRazrrPHHFKTvvUhBiJnnwJZEaw9XlbbEICrxBJK 3wHP4X4n+MfZ93zr8Ociphc5JnNb+TZN2Cf1ycZV4cWfKMVqsIHBU174maUmC5+FDfH1 pN2xao6YYkz24KfMuJUiUXrTsY4liGK/NDb3c6b6t5eke8sf1unFrMCFw9VoY3jwx/sl Yu+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Qmh6Kzg0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a0564021e9500b0046b6bc083a5si489990edf.560.2022.12.05.13.41.29; Mon, 05 Dec 2022 13:41:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Qmh6Kzg0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233790AbiLEVBG (ORCPT + 80 others); Mon, 5 Dec 2022 16:01:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233551AbiLEVA1 (ORCPT ); Mon, 5 Dec 2022 16:00:27 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A42EE2528D; Mon, 5 Dec 2022 13:00:26 -0800 (PST) Received: from W11-BEAU-MD.localdomain (unknown [76.135.50.127]) by linux.microsoft.com (Postfix) with ESMTPSA id 4A2AA20B83FB; Mon, 5 Dec 2022 13:00:26 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4A2AA20B83FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670274026; bh=uNBhqwNXhSFNYmJNgFRJNFpkrMNjAHn0mdRb467MsVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qmh6Kzg0gqqr8TJmMar0035REOJ5lM/cMcKsVAQl71Y4WMGRVrxgblEQNjOEySERz Fk9E+HwEnU5MNBGeqz2ymvjQcOO1911BENa3J3Rkee6tzg6OuVN/pSu3Oc4UpA/BUT 4KCCvxl+uuxKu5QxY7AVWM0DHDgds3RVfte81KLQ= 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 v5 10/11] tracing/user_events: Charge event allocs to cgroups Date: Mon, 5 Dec 2022 13:00:16 -0800 Message-Id: <20221205210017.23440-11-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205210017.23440-1-beaub@linux.microsoft.com> References: <20221205210017.23440-1-beaub@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ebbde72e1f85..36def244a755 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 = kmalloc(sizeof(*user_mm), GFP_KERNEL); + user_mm = kmalloc(sizeof(*user_mm), GFP_KERNEL_ACCOUNT); if (!user_mm) return NULL; @@ -652,7 +652,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; @@ -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 = 0; - field = kmalloc(sizeof(*field), GFP_KERNEL); + field = kmalloc(sizeof(*field), GFP_KERNEL_ACCOUNT); 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") != NULL) validator_flags |= VALIDATOR_ENSURE_NULL; - validator = kmalloc(sizeof(*validator), GFP_KERNEL); + validator = kmalloc(sizeof(*validator), GFP_KERNEL_ACCOUNT); if (!validator) { kfree(field); @@ -1165,7 +1165,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; @@ -1498,7 +1498,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; @@ -1692,7 +1692,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; @@ -1861,7 +1861,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; @@ -1914,7 +1914,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; -- 2.25.1