[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251003103556.00006e3c@huawei.com>
Date: Fri, 3 Oct 2025 10:35:56 +0100
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Raghavendra K T <raghavendra.kt@....com>
CC: <AneeshKumar.KizhakeVeetil@....com>, <Michael.Day@....com>,
<akpm@...ux-foundation.org>, <bharata@....com>, <dave.hansen@...el.com>,
<david@...hat.com>, <dongjoo.linux.dev@...il.com>, <feng.tang@...el.com>,
<gourry@...rry.net>, <hannes@...xchg.org>, <honggyu.kim@...com>,
<hughd@...gle.com>, <jhubbard@...dia.com>, <jon.grimm@....com>,
<k.shutemov@...il.com>, <kbusch@...a.com>, <kmanaouil.dev@...il.com>,
<leesuyeon0506@...il.com>, <leillc@...gle.com>, <liam.howlett@...cle.com>,
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<mgorman@...hsingularity.net>, <mingo@...hat.com>, <nadav.amit@...il.com>,
<nphamcs@...il.com>, <peterz@...radead.org>, <riel@...riel.com>,
<rientjes@...gle.com>, <rppt@...nel.org>, <santosh.shukla@....com>,
<shivankg@....com>, <shy828301@...il.com>, <sj@...nel.org>, <vbabka@...e.cz>,
<weixugc@...gle.com>, <willy@...radead.org>, <ying.huang@...ux.alibaba.com>,
<ziy@...dia.com>, <dave@...olabs.net>, <yuanchu@...gle.com>,
<kinseyho@...gle.com>, <hdanton@...a.com>, <harry.yoo@...cle.com>
Subject: Re: [RFC PATCH V3 08/17] mm: Add throttling of mm scanning using
scan_size
On Thu, 14 Aug 2025 15:32:58 +0000
Raghavendra K T <raghavendra.kt@....com> wrote:
> Before this patch, scanning is done on entire virtual address space
> of all the tasks. Now the scan size is shrunk or expanded based on the
> useful pages found in the last scan.
>
> This helps to quickly get out of unnecessary scanning thus burning
> lesser CPU.
>
> Drawback: If a useful chunk is at the other end of the VMA space, it
> will delay scanning and migration.
>
> Shrink/expand algorithm for scan_size:
> X : Number of useful pages in the last scan.
> Y : Number of useful pages found in current scan.
> Initial scan_size is 1GB
> case 1: (X = 0, Y = 0)
> Decrease scan_size by 2
> case 2: (X = 0, Y > 0)
> Aggressively change to MAX (4GB)
> case 3: (X > 0, Y = 0 )
> No change
> case 4: (X > 0, Y > 0)
> Increase scan_size by 2
>
> Scan size is clamped between MIN (256MB) and MAX (4GB)).
> TBD: Tuning based on real workloads
Seems like a reasonable thing to do, but as you say tuning
data needed to justify how aggressive this should be and
those size limits.
Trivial stuff inline.
>
> Signed-off-by: Raghavendra K T <raghavendra.kt@....com>
> ---
> mm/kscand.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/mm/kscand.c b/mm/kscand.c
> index 843069048c61..39a7fcef7de8 100644
> --- a/mm/kscand.c
> +++ b/mm/kscand.c
> @@ -28,10 +28,15 @@
>
> static struct task_struct *kscand_thread __read_mostly;
> static DEFINE_MUTEX(kscand_mutex);
> +
Push that into earlier patch to cut down on churn / noise.
> /*
> * Total VMA size to cover during scan.
> + * Min: 256MB default: 1GB max: 4GB
> */
> +#define KSCAND_SCAN_SIZE_MIN (256 * 1024 * 1024UL)
> +#define KSCAND_SCAN_SIZE_MAX (4 * 1024 * 1024 * 1024UL)
> #define KSCAND_SCAN_SIZE (1 * 1024 * 1024 * 1024UL)
> +
Likewise.
> static unsigned long kscand_scan_size __read_mostly = KSCAND_SCAN_SIZE;
>
> /*
> @@ -94,6 +99,8 @@ struct kscand_mm_slot {
> unsigned long next_scan;
> /* Tracks how many useful pages obtained for migration in the last scan */
> unsigned long scan_delta;
> + /* Determines how much VMA address space to be covered in the scanning */
> + unsigned long scan_size;
> long address;
> bool is_scanned;
> };
> static inline void kscand_update_mmslot_info(struct kscand_mm_slot *mm_slot,
> unsigned long total)
> {
> unsigned int scan_period;
> unsigned long now;
> + unsigned long scan_size;
Combining a few of these or assigning at declaration will reduce the code size a bit
which is always nice to have if it doesn't hurt readability.
> unsigned long old_scan_delta;
>
> + scan_size = mm_slot->scan_size;
> scan_period = mm_slot->scan_period;
> old_scan_delta = mm_slot->scan_delta;
Powered by blists - more mailing lists