From patchwork Sun Jul 16 01:09:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13314750 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 C030AC001B0 for ; Sun, 16 Jul 2023 01:09:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8D9D6B0071; Sat, 15 Jul 2023 21:09:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3DFF6B0074; Sat, 15 Jul 2023 21:09:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D05B96B0075; Sat, 15 Jul 2023 21:09:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C10636B0071 for ; Sat, 15 Jul 2023 21:09:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8EA251202DE for ; Sun, 16 Jul 2023 01:09:35 +0000 (UTC) X-FDA: 81015692310.29.C7AB404 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id E151C40012 for ; Sun, 16 Jul 2023 01:09:33 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RNE0S0KQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of chao@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chao@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689469774; a=rsa-sha256; cv=none; b=ZRIIgaui4gTeq159VwVrbkvhlH4428lbBqBh3f6wSWRgUjiL6UvVKxPVbNbSgjvVg0e6Y9 gsNHnvJkpDPr8lOGuaw2ITAe1rDmRZEYRnOQnbTf7lPGWpXID92TPUcFBhqcQ+0OyzhpUP t17ce3SknkBuK/fwwXWct/GNZibZfJk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RNE0S0KQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.hostedemail.com: domain of chao@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chao@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689469774; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=lHWTTA67kIdojUfmyvgXKmILJ8BrAFEuc6q6jGxjRIE=; b=qc7E37lnGm8T05Qbq9iqiX/NQR9vw9r4pfYE1xKptgNp4sXlJzmxyh8t++CWXMVLFGxrFQ 1qqS0PHM4rcQWuDFT0IEp7xgWDrFw9IPtewOY73py4yX1Uqyjrr/UnZpYWuA8t11izWXpe wV0mjzh9hcMJIjLlXmHQBpzkSKs21w0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C831260C50; Sun, 16 Jul 2023 01:09:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3452C433C7; Sun, 16 Jul 2023 01:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689469772; bh=5SSm4qEXPJuLohs5+byCGS3o4lRGePIKkaLKy1/+IXc=; h=From:To:Cc:Subject:Date:From; b=RNE0S0KQf9cRwje4zpnYyVSB45dXyxazFqRNu79k0NvYqvDcqN3SDgAQKkSSlThfu bvt8zjM+7qrgXnrITpz0BXGwD6EIWrjEvP8Sgouy+zj3Ti9+08V0ssNOZS4t84SVjB +i7dELXzNCAV4Ps/cElbr5vod97Fi8CSEMEzQsKkGpjCI4AAnTvKvmFtgbTxa0igmt jaz3LqNmLDx1Uirxipq9HaXZTwq2bhq0XjBjmWxL89463OKLVZYI9/hm0sA1muGdRd sBVyyfPI2Yan0+hwlQsdkB2X/Vo7PgdhJx7e4N8Sl0NgCz4jmCBnYdCKiKthemyOTr QSYdaRb4YsDzw== From: Chao Yu To: sj@kernel.org, akpm@linux-foundation.org, damon@lists.linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH 1/2] mm/damon/dbgfs: reduce stack usage in str_to_schemes() Date: Sun, 16 Jul 2023 09:09:26 +0800 Message-Id: <20230716010927.3010606-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E151C40012 X-Stat-Signature: 6kgx3nmsyhchqkxr46yj54umuz5rg7sz X-HE-Tag: 1689469773-711571 X-HE-Meta: U2FsdGVkX19Uu9sorjJjpvE0Uohtn5k5lvN6ZDpbjRZCyLOivk2cJlGqqu11YMexAOMXJh/lU3UXVeb6qIAVLuF2vaTrHujQToM/pBKXDf3OHaCEzwp46n5q+l389UIYflr9uTby9JSsa22l6jJAhyJDx9c4qFB4HqJ3uy4xhtENb67ypAvqfTuSevly0380BW/rPnKp07sxJyTzu6QW48xEOplwA0wa0QB7xQwW8tbixPy3sqXFJzirkjh3UAjJRkT2GoVN1fU83Kjmk532qUqZAgPv2R/HrzFVFgvP/5pSZvrf5rYtn3e0YHPAFb1ylUrQGK6z1vTQ05UidwBcpFT8hQ/6KBxNBT9Agn06HBD2iU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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: struct damos_quota quota caused the stack usage of str_to_schemes() to grow beyond the warning limit on 32-bit architectures w/ gcc. mm/damon/dbgfs.c: In function ‘str_to_schemes’: mm/damon/dbgfs.c:292:1: warning: the frame size of 1496 bytes is larger than 1024 bytes [-Wframe-larger-than=] Allocating dynamic memory in str_to_schemes() to fix this issue. Signed-off-by: Chao Yu --- mm/damon/dbgfs.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 124f0f8c97b7..78acc7366895 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -237,18 +237,26 @@ static struct damos **str_to_schemes(const char *str, ssize_t len, int pos = 0, parsed, ret; unsigned int action_input; enum damos_action action; + struct damos_quota *quota; schemes = kmalloc_array(max_nr_schemes, sizeof(scheme), GFP_KERNEL); if (!schemes) return NULL; + quota = kmalloc(sizeof(struct damos_quota), GFP_KERNEL); + if (!quota) { + kfree(schemes); + return NULL; + } + *nr_schemes = 0; while (pos < len && *nr_schemes < max_nr_schemes) { struct damos_access_pattern pattern = {}; - struct damos_quota quota = {}; struct damos_watermarks wmarks; + memset(quota, 0, sizeof(struct damos_quota)); + ret = sscanf(&str[pos], "%lu %lu %u %u %u %u %u %lu %lu %lu %u %u %u %u %lu %lu %lu %lu%n", &pattern.min_sz_region, &pattern.max_sz_region, @@ -256,10 +264,10 @@ static struct damos **str_to_schemes(const char *str, ssize_t len, &pattern.max_nr_accesses, &pattern.min_age_region, &pattern.max_age_region, - &action_input, "a.ms, - "a.sz, "a.reset_interval, - "a.weight_sz, "a.weight_nr_accesses, - "a.weight_age, &wmarks.metric, + &action_input, "a->ms, + "a->sz, "a->reset_interval, + "a->weight_sz, "a->weight_nr_accesses, + "a->weight_age, &wmarks.metric, &wmarks.interval, &wmarks.high, &wmarks.mid, &wmarks.low, &parsed); if (ret != 18) @@ -278,15 +286,17 @@ static struct damos **str_to_schemes(const char *str, ssize_t len, goto fail; pos += parsed; - scheme = damon_new_scheme(&pattern, action, "a, &wmarks); + scheme = damon_new_scheme(&pattern, action, quota, &wmarks); if (!scheme) goto fail; schemes[*nr_schemes] = scheme; *nr_schemes += 1; } + kfree(quota); return schemes; fail: + kfree(quota); free_schemes_arr(schemes, *nr_schemes); return NULL; } From patchwork Sun Jul 16 01:09:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13314751 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 9E6AAC001DF for ; Sun, 16 Jul 2023 01:09:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5C026B0074; Sat, 15 Jul 2023 21:09:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABC1D6B0075; Sat, 15 Jul 2023 21:09:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95DEF6B0078; Sat, 15 Jul 2023 21:09:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 867846B0074 for ; Sat, 15 Jul 2023 21:09:37 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 56D591602E8 for ; Sun, 16 Jul 2023 01:09:37 +0000 (UTC) X-FDA: 81015692394.19.BB5ABAC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 9B33F4000C for ; Sun, 16 Jul 2023 01:09:35 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=c6LZpv+X; spf=pass (imf17.hostedemail.com: domain of chao@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chao@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689469775; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Y97oFiczw92IiJwlno40dI00kDDAzKTgLNIY/4J3RFs=; b=K/kw0cC09Cg3oAMxb0C4N2zqLuTXqqF1GWCoysSHjfp8HhlFZfyDc/qYPolghgoInnTV4i S5Wk9vLjiM/4TFVtdwsXtwko07ISU7S36kJraO26lLOuw8K56kD/vNOAQBicNZF4cbAiaT R0/iewoRXqkud5X8MuMdo51VdQbAnZU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689469775; a=rsa-sha256; cv=none; b=Vc+X8YdCSLkRHehs0C/pcNBmhXv8ky2iFjMaYHByI42etbZNBTPj6TeRRzKThsgpyUyjlP w/WvpkYCvizlqQnOby5qTeWkjPKY2JaXvpTtGB05VAxZ2+5ZsYWNlh2MYLVNc1vIgnnPqn aNftFx9PQLvaBNV/VwnF0wSBaiZz3vk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=c6LZpv+X; spf=pass (imf17.hostedemail.com: domain of chao@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=chao@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AA88160C47; Sun, 16 Jul 2023 01:09:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6A64C433CB; Sun, 16 Jul 2023 01:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689469774; bh=ynG3uNudPw4EsmIgbd5wO/+ejwNGpxxg7axI66LyiMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c6LZpv+XdvwV51008/a0gH39M+APPgJM1D7EOMzHvhYSMZ4+D9rHkfJmYJBPT690F I3n665Knoij7AITE//UPgEmnmhA7iRcmfJegbBSEp5mz7BYNtVNLLwqy5mck6iN/q7 5t3JmblHrXTGgqVwEP/wr8WRgHZjjGBu2YSC2lJRRUDPLWljHtK661ebqE4RNG4Kin 3D2+YeCk+ylACT8MLGW6/FRiwMxULxnhCHSZsBTNlC3BekaP5OpZC6/EqQH5Pm70Ti z3QbEtEwUtMhcsPLOZttOBKif81QBovz2Cvfrl/aQ3gtLvYqki3F0QTi0/PqfzK4Vu FouNsEgrezM9w== From: Chao Yu To: sj@kernel.org, akpm@linux-foundation.org, damon@lists.linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH 2/2] mm/mm/damon/sysfs-schemes: reduce stack usage in damon_sysfs_mk_scheme() Date: Sun, 16 Jul 2023 09:09:27 +0800 Message-Id: <20230716010927.3010606-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230716010927.3010606-1-chao@kernel.org> References: <20230716010927.3010606-1-chao@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9B33F4000C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: cfnoxyeau98zges94yciqriazgufzjzx X-HE-Tag: 1689469775-240927 X-HE-Meta: U2FsdGVkX1+i2ZHa4sZ20cezYMGNawajRcRI1oBSLmz7wwrW1tdMrPxLxVXdKM7W/jBh0h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KqUmoXBPiXxfnKM7EDGrTzD9dxE8nx7IAYGLbjRdJKOwL4wPJFyTH8oH+f5oNjXgaUti9py9O8eR4eNu/7bua0mx37GHEPvkB+FuN1Ysp7439VuQhQu4QpbUKz3D+xNgGOUj3O97x11kW14yLZB9cMoCHBEfXwqfD7otO6ieWCDb8/6BusRzK8RpIIKxOHeBp6alh1pn3uXFkGcF50AvETVLW8= 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: struct damos_quota quota caused the stack usage of damon_sysfs_mk_scheme() to grow beyond the warning limit on 32-bit architectures w/ gcc. mm/damon/sysfs-schemes.c: In function ‘damon_sysfs_mk_scheme’: mm/damon/sysfs-schemes.c:1526:1: warning: the frame size of 1280 bytes is larger than 1024 bytes [-Wframe-larger-than=] Allocating dynamic memory in damon_sysfs_mk_scheme() to fix this issue. Signed-off-by: Chao Yu --- mm/damon/sysfs-schemes.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 50cf89dcd898..35fa1b421c26 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1486,6 +1486,7 @@ static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme_filters *sysfs_filters = sysfs_scheme->filters; struct damos *scheme; + struct damos_quota *quota; int err; struct damos_access_pattern pattern = { @@ -1496,14 +1497,6 @@ static struct damos *damon_sysfs_mk_scheme( .min_age_region = access_pattern->age->min, .max_age_region = access_pattern->age->max, }; - struct damos_quota quota = { - .ms = sysfs_quotas->ms, - .sz = sysfs_quotas->sz, - .reset_interval = sysfs_quotas->reset_interval_ms, - .weight_sz = sysfs_weights->sz, - .weight_nr_accesses = sysfs_weights->nr_accesses, - .weight_age = sysfs_weights->age, - }; struct damos_watermarks wmarks = { .metric = sysfs_wmarks->metric, .interval = sysfs_wmarks->interval_us, @@ -1512,16 +1505,32 @@ static struct damos *damon_sysfs_mk_scheme( .low = sysfs_wmarks->low, }; - scheme = damon_new_scheme(&pattern, sysfs_scheme->action, "a, + quota = kmalloc(sizeof(struct damos_quota), GFP_KERNEL); + if (!quota) + return NULL; + + quota->ms = sysfs_quotas->ms; + quota->sz = sysfs_quotas->sz; + quota->reset_interval = sysfs_quotas->reset_interval_ms; + quota->weight_sz = sysfs_weights->sz; + quota->weight_nr_accesses = sysfs_weights->nr_accesses; + quota->weight_age = sysfs_weights->age; + + scheme = damon_new_scheme(&pattern, sysfs_scheme->action, quota, &wmarks); - if (!scheme) + if (!scheme) { + kfree(quota); return NULL; + } err = damon_sysfs_set_scheme_filters(scheme, sysfs_filters); if (err) { + kfree(quota); damon_destroy_scheme(scheme); return NULL; } + + kfree(quota); return scheme; }