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/jBh0hn04jdAJKtR/VlGSMWEmv7vF14vSoY2UgNsTW46xR33X8DyjAMku3Yq5MoWLylJD8hGpZ3R7KvdIzaY4bf3gbzncUDnI+c+XmUGE+cinadfZcZi6LU4oF6Gk1a3tdV043iZbsEWOaLgck7M+DGMRMldznbSWKcxxIYbQsyQjXprcoRRtXJ/pHgMh1qNmx3434PfqXpLFeAccVEjPBAurwgUTWZ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LW8= 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; }