From patchwork Tue Jul 23 03:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Peng X-Patchwork-Id: 13739312 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 A4091C3DA63 for ; Tue, 23 Jul 2024 03:55:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D1A76B0089; Mon, 22 Jul 2024 23:55:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25A036B008A; Mon, 22 Jul 2024 23:55:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D44A6B008C; Mon, 22 Jul 2024 23:55:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DF70E6B0089 for ; Mon, 22 Jul 2024 23:55:23 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 92A10A171F for ; Tue, 23 Jul 2024 03:55:23 +0000 (UTC) X-FDA: 82369652526.10.0FD743F Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf05.hostedemail.com (Postfix) with ESMTP id C56D6100006 for ; Tue, 23 Jul 2024 03:55:21 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Io8tx8c3; spf=pass (imf05.hostedemail.com: domain of flyingpenghao@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=flyingpenghao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721706899; 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:references:dkim-signature; bh=2p0RnXBXScYnMr+fs4pThEFf34PIi37xwRHTjB7LssU=; b=Oesy4yasi2injVdZPA/IA6qdRXTxFB34NLLIP7zaTB75MdCYnRw1nFoHW1nu32XXQPpDkZ QXvg88GGytrCvfQNwbf3KgShlzgqlFEj37OHCV2e0rb5wpOWLvGRQTsZ/HnA+p75p2OvaM cHiaLiAffyqh+dmQMw134KOdjHQB7SM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Io8tx8c3; spf=pass (imf05.hostedemail.com: domain of flyingpenghao@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=flyingpenghao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721706899; a=rsa-sha256; cv=none; b=eaTD/C2Ir5xd6OKqRDFZ7ba5tM+HIjzDASANz7ouH34m4Zj8vqf4uUxQTjXvK2hwe49DXv jMqpmVkesRmDhC45hCOF+z7R8KzAyYcBsniC/E6811uH9xENEo2aUaPt+efl0lYABp6K8M 5ofwrHDreO9hkSZbblmx8OhshYbYPLY= Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2cb4b6ecb3dso2526715a91.3 for ; Mon, 22 Jul 2024 20:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721706920; x=1722311720; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2p0RnXBXScYnMr+fs4pThEFf34PIi37xwRHTjB7LssU=; b=Io8tx8c3Gcj6PxgjTqPrBPqLkWvY1q+Em/YK4uiw5BKGG7EurfF5m/mlXE3gytBW8G 4jPq3W/4UKw2uMKE+N1hpKwZppFIw+MGduKj7ICoOzGYAlXEx04wnee0KKv08HXLoqaf P5CCdcZwCeO0pDOQEoOz6FFPq9gH2g5+vplpIhGUHllzBzYULxgqC0D3WS4bpSq6f2t9 iOevyJO6EkK2k9435g4kOQhpEMWf7pZBGmIir2AMkHlQgAmuybgYqtZxnFXR+o80PkhY 7FLPTGOj4veCAOsrQY5X1y/iEe868QwUjCHe/49e23EANpeITHYnSuIiD/QJTs8Sme2N QaLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721706920; x=1722311720; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2p0RnXBXScYnMr+fs4pThEFf34PIi37xwRHTjB7LssU=; b=oajykYPkoUH0sO02lq4GCjOXUSxTn1CIr8p26sCSvRXpVcCseoWtQEezUAZSqfmYlb HxAw41IAD+aQTERRYmzw//f8oXnrei/GAzCvoqbyxqQIh1a5l66GGCPFQb2ryWqMnd6J A2RrQBB781xlc/b3KCIxedC/MFu03rWnNRZc3afk8KzSRlPW9puQiJdQXAXNMX8sETpa CyZ3o1AFAqV1/lShLknuvLoCWsGAbUO/lKf7+AeumHUW8u0drlUTCFkww2+XEwstytsr w9KSo9Ur4yYSdirNEmhBOePxd7KO9XhwhbyMi9QJEUGOJXZ3XnpjWhVnSPcMO59FhE8m Lo4g== X-Forwarded-Encrypted: i=1; AJvYcCUt1pbTuXBvvyeyyaDbftwLe9tTZtiGNspJ4yZhkLtEgp/YKYZsDzYQgoRL3+mRK94GFwkkompB26De+kLIjCtzKIo= X-Gm-Message-State: AOJu0YwokXy7rZCPzc022hLwWaLiHcGpW3qWOfPJlGyOzXlwswladRvI epI39cUut/Bcnj7p+t+yA2FdAyQZ5KjEJivIjyhVlUIo6sq3AWkcCPFNvQ== X-Google-Smtp-Source: AGHT+IF4Xzkp0jdQnpvfnVe1sLE5NxasDzZVMgfCpy9HYMw5CBoE58UN9jo12Spg0OG9dr0aHUq2vQ== X-Received: by 2002:a17:90b:1b45:b0:2c9:6514:39ff with SMTP id 98e67ed59e1d1-2cd85d8dcbbmr1435980a91.33.1721706920209; Mon, 22 Jul 2024 20:55:20 -0700 (PDT) Received: from FLYINGPENG-MB1.tencent.com ([103.7.29.30]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf80a9a4csm7946372a91.55.2024.07.22.20.55.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 20:55:19 -0700 (PDT) From: flyingpenghao@gmail.com X-Google-Original-From: flyingpeng@tencent.com To: sj@kernel.org, akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, Peng Hao Subject: [PATCH v5] mm/damon/lru_sort: adjust local variable to dynamic allocation Date: Tue, 23 Jul 2024 11:55:13 +0800 Message-Id: <20240723035513.20153-1-flyingpeng@tencent.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C56D6100006 X-Stat-Signature: ttmg8w4imjcyh71rj3q5r9rzt5ba8w5o X-HE-Tag: 1721706921-692484 X-HE-Meta: U2FsdGVkX1/+01dp3iCw3R3yu4KLd5D8KY6+IW8HoLJSO0iy1j8rA0WjwvvysP0pF7miWBYOn7IhdTQjiId+0dyEwaaR5NCb/CN+U7gnaD/tLdFRq4eNY9l00MFZ8D/2rHj4VklgrriMb9QgD0lxjXqZqYpmGQpYnsavXbeNcBKoF7L6kKBOwQMsjaB+oktHw/nPOJA5e9Jlu/wLsQynYe4njL93D8x3JklBzF/key8a35+N4mCZigWHZPQvnjQtv9i4RMoOWS5FjIweRcs7e2y3177YHw0IgO1Xg4Mf70hde1tgfJ7QLyxAswNmQsSc4byq6K7xxGJ5PE47YePkmA8CcjOCPoONI8w2S8uOGC/l6yYsZl6TCw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-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Peng Hao When KASAN is enabled and built with clang: mm/damon/lru_sort.c:199:12: error: stack frame size (2328) exceeds limit (2048) in 'damon_lru_sort_apply_parameters' [-Werror,-Wframe-larger-than] static int damon_lru_sort_apply_parameters(void) ^ 1 error generated. This is because damon_lru_sort_quota contains a large array, and assigning this variable to a local variable causes a large amount of stack space to be occupied. So adjust local variable to dynamic allocation. Link: https://lore.kernel.org/all/20240711081051.66560-1-flyingpeng@tencent.com/ Link: https://lore.kernel.org/linux-mm/20240719174234.47017-1-sj@kernel.org/T/ Signed-off-by: Peng Hao Reviewed-by: SeongJae Park --- v4 -> v5: rebase on latest mm-unstable tree. v3 -> v4: adjust release point, tweak format, etc. v2 -> v3: don't change histgram array in damon_quota, dynamically allocating local variables v1 -> v2: don't modify global variables and change the histgram array in damon_quota to dynamic allocation mm/damon/lru_sort.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 4af8fd4a390b..0b35bd5fb659 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -148,12 +148,17 @@ static struct damon_target *target; static struct damos *damon_lru_sort_new_scheme( struct damos_access_pattern *pattern, enum damos_action action) { - struct damos_quota quota = damon_lru_sort_quota; + struct damos *damos; + struct damos_quota *quota = kmemdup(&damon_lru_sort_quota, + sizeof(damon_lru_sort_quota), GFP_KERNEL); + + if (!quota) + return NULL; /* Use half of total quota for hot/cold pages sorting */ - quota.ms = quota.ms / 2; + quota->ms = quota->ms / 2; - return damon_new_scheme( + damos = damon_new_scheme( /* find the pattern, and */ pattern, /* (de)prioritize on LRU-lists */ @@ -161,10 +166,12 @@ static struct damos *damon_lru_sort_new_scheme( /* for each aggregation interval */ 0, /* under the quota. */ - "a, + quota, /* (De)activate this according to the watermarks. */ &damon_lru_sort_wmarks, NUMA_NO_NODE); + kfree(quota); + return damos; } /* Create a DAMON-based operation scheme for hot memory regions */