From patchwork Fri Oct 18 07:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MengEn Sun X-Patchwork-Id: 13841337 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 41ADFD3C55E for ; Fri, 18 Oct 2024 07:58:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1B556B009A; Fri, 18 Oct 2024 03:58:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCB9B6B009F; Fri, 18 Oct 2024 03:58:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6CBA6B00A0; Fri, 18 Oct 2024 03:58:04 -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 8A6E96B009A for ; Fri, 18 Oct 2024 03:58:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C8F851A17D3 for ; Fri, 18 Oct 2024 07:57:42 +0000 (UTC) X-FDA: 82685969352.21.F894F83 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf23.hostedemail.com (Postfix) with ESMTP id 5AE03140017 for ; Fri, 18 Oct 2024 07:57:55 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XCzBr0Aq; spf=pass (imf23.hostedemail.com: domain of mengensun88@gmail.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=mengensun88@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=1729238233; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=Drm6GSMszdRwDqRBijgtPROGYu2UjXAmF0Jy5tagAhk=; b=HqKkm7WtOgevN7wG14eDJYultPvSvX8uE5HiQJ5muhwCfcSXG26yG6stFbxcbGvKtQzWQM nu60rnZ7b+9oFhZnv6+LY2x6UeZUVdup5M+y9JLo60I60Z9mUag9scBoO2py01A8a/w49D 0D8QM8RiGvM5xtfiBVwWNFWraTKVb3Y= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XCzBr0Aq; spf=pass (imf23.hostedemail.com: domain of mengensun88@gmail.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=mengensun88@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729238233; a=rsa-sha256; cv=none; b=Npir1SMZ8d4CFsI2SbsBCZSdiGgUvD+2e8chqrGT4rBEnAU4ed9cWpoLk4EiyWvgMd2MOU E3oyZwB6r/ErAA73woXXC+ktbukw/AQVbDkBbROo9fDMo3BL5g3/H7NDLLdppAMFQ4Lr9i mIVKSACk9T30JXIydvyb4sHmUVoOaGA= Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7ea68af2f62so1466021a12.3 for ; Fri, 18 Oct 2024 00:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729238281; x=1729843081; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Drm6GSMszdRwDqRBijgtPROGYu2UjXAmF0Jy5tagAhk=; b=XCzBr0Aq19cM0IVxHeuYHwkXbtUkHIH/78/WG60EIycBGgk2IgIaqeB7EUfB3Ft2Qb 46Lj85os+l5gRvXNbSuCepFyhBUQdrqMB0c4MP8L+a6OYlvudjMt8EoZddAtkK/1QgtK 7B9T0fg0aMZSwg7a6yjmlS/KuIylXByFhX/OhK366mPCHR/Hc2nraTu0DOoE7N8uBger ok68gMepOJuFEI5pfR8B+cPIhVgK3w/KSgxn31VFwEWEC1odc+GCPMP73o7rDp7lDYtR U5ceUt3BMCOnn7klefo+1mGMZnT1t+nD1ZDkhqULMsaKqZ6atrGPetLEo8WZRra/Qly5 m5pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729238281; x=1729843081; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Drm6GSMszdRwDqRBijgtPROGYu2UjXAmF0Jy5tagAhk=; b=g2X+2loFYMXrQBVVd83LWXhY18FoSQmGKx6vyI5sbsenEcGK1mF8aWp0ZElLIvARus Z7i1dQKjws0NmU/MMi+bJsYYinJaG6XSftnvV2+OpSg2BzMZ22cW54dULOCJl9XUorFd eie8GzjN5DjGd27RgA4TmmVHJXHyEaOOA+sXp+QXJZmyR0TH1eNMZoTvdmZX+l4l1DJf GDN9lemkFZt4eD5Ekgz7apaX4pst9ed0xfo+WS8Nf+ADlvO5Po34F+Y3lUHTNhbw7TZi 2F7u03ZLIoGRlKp2mX8H+usQ/Q5YTIaEdMnVa27CLQ6IXAP19u1vVFIQ+L0YtUUrBIWs z/xA== X-Gm-Message-State: AOJu0YwAYoDdycuQvasOo5Il/fwj4MOYsC8WudmKeFTEwwUCsmICefVi WlYaRjfZKh0/Puync/HG4uWQmRg8zq1k/wt6mJqHPo6jOB3/3W9p X-Google-Smtp-Source: AGHT+IG4zD6/7f12yR/mjUbybtqozcn/vgZSk2HbLlusGBxbrjzCt4vXo/MKgYMbufIpewVJGmwk8A== X-Received: by 2002:a05:6a21:4d8c:b0:1d9:1fac:7256 with SMTP id adf61e73a8af0-1d92c52a598mr2108382637.30.1729238280938; Fri, 18 Oct 2024 00:58:00 -0700 (PDT) Received: from localhost.localdomain ([43.153.70.29]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e55d7970f4sm1290248a91.5.2024.10.18.00.58.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2024 00:58:00 -0700 (PDT) From: mengensun88@gmail.com X-Google-Original-From: mengensun@tencent.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, alexjlzheng@tencent.com, MengEn Sun Subject: [PATCH linux-mm v2] mm: make pcp_decay_high working better with NOHZ full Date: Fri, 18 Oct 2024 15:57:57 +0800 Message-Id: <1729238277-26683-1-git-send-email-mengensun@tencent.com> X-Mailer: git-send-email 1.8.3.1 X-Rspam-User: X-Stat-Signature: biqifbshyizo4mm3ag9z69gzb4m7k66d X-Rspamd-Queue-Id: 5AE03140017 X-Rspamd-Server: rspam11 X-HE-Tag: 1729238275-977253 X-HE-Meta: U2FsdGVkX188y8zgyqe/3YdsmfhgRK9iYD+A8f0YW5O1efMAHMMUxiVMxF2gusD0TXVajwNW9w1wPQAl8CIplD3tXeF+CN7OdZKYocct7+hxxYlvH60Sq9nTTLu2UOiaUhq1rYIq3Wvof1xqPkyAtC1/5eKIkpTZTgQy8FG6Pxjg1B3x1TzctTyQH/znBMs/fcrVqTwBohQ2n3OLMvzBNIe6XwDWxkIk9fCPyFo1W64nsAUWgSh3Myk2YLu5k3xZfynM9kGXPA+Om0eqCBCM+8e98UxgienX3lNZMLb9dn2QPsShauaJBJUvRreatRzoUTCynhpuytGqR9cvpzDMOUsfWIYklVzQQFpN0nH1YWsaBg9LlZHx0E7IR2KM966aDCtWYZHONXYsZbyauzdfCyT5mV6jHard2FEmWBIzzeZcNboPXgGMC4YU5WCd3Z4AQTcJx48G8IpJjK9JU8YLwmT/AWscZUz6bGEEv4a6rk0oosfuixqgTkZLj3q0ngQKixMaURBIzjdo4vHB4IRv5TLP2MXSafzTlbLE9vae8o2P8Tn9cSSCCstXG1WZ+0tHSXe3JrCJr/yJUBJLkq23Lge569rwZGi9QQmyiYWVaDuKzsvx3PTy0Jj8QvvEMAirk1ODlXax/Ex5/CuYYDMLyDnEMoG4wSuIChkDalAKDmaZY0zktK7+IS1vknJBK5uzyCSaQ+Vg4QwI+O6scoe8BCkgMvZxfUHT5wuimcjJo4J0Fkh+oyxLB91st2IiEsDR48R5UIld4+SlO1S5Siv9uB1jBt9UaWpniq9VENJfVoQI238bK805x7QC2J250RYHI/+e4lOgEvT63py7YfHR9t3GDrRJkiCETlRDLcvwE0xZq3FCWeCvAa7JP0kC/nCBMwDn3jSRPHdInQ2AJKYlCMRMk07dhzs4ZXiq6P2cvMhp2IqW/ydYVPPll6iBI8/HsFqino0zVq1A2zHwCYk hVSyAjqP 1orGH0gpTzBuHoHPWk1SXV5Vy7fPXWoXl/8Xol7sNZ5xHYoDJN3nk2l2T7OW3N/sOKvPK5BxOhW6N6NCUDBFRg/1+/BbBeq7OmQm3583R2xxIMNG0aRyDmu78f/0/WhyB6FlBnEOCzPqBSlKx0oRuHaRY8Vy6cH4S7146vxkdKlktM1UnAuNhwABL5RPNhrRVKWzYsWcWf/C+Lgk5rym9jOKpsdsMFIb6AT0Ocm/ftnehZ18Da3btQ7v/jQKYw+VkgH6UkWVAjYJjNYY6+x+gsOsNqc7aEvFDbHPusknuzJl9jnL/I1RcjS7iUrISjJagY1+35zymqixLcppj8wUtXnl3kmTwtECrfsfpiwVT9B775dzfvPpMsSrTJZ1pY19zu9YZ8QpBo+M2IsT1x3gQpeNl7MchGGoEPjMUXMYucueGqzM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.010005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: MengEn Sun When a cpu entring NOHZ full, quiet_vmstat may flush percpu zonestats and nodestats. The vmstat_shepherd only check percpu zonestats and nodestats to determine whether it is necessary to fire vmstat_update on the target cpu for now. If a process on a certain CPU allocates a large amount of memory, then frees that memory, and subsequently the CPU enters NOHZ, and the process not freeing and allocating memory anymore,the vmstat_update not being executed on the cpu. Because vmstat_shepherd may not see zonestats and nodestats of the cpu changed, so may resulting in vmstat_update on the cpu not fired for a long time. While, This seems to be fine: - if freeing and allocating memory occur later, it may the high_max may be adjust automatically - If memory is tight, the memory reclamation process will release the pcp Whatever, we make vmstat_shepherd to checking whether we need decay pcp high_max, and fire pcp_decay_high early if we need. Fixes: 51a755c56dc0 ("mm: tune PCP high automatically") Reviewed-by: Jinliang Zheng Signed-off-by: MengEn Sun --- changelog: v1: https://lore.kernel.org/lkml/20241012154328.015f57635566485ad60712f3@linux-foundation.org/T/#t v2: Make the commit message clearer by adding some comments. --- mm/vmstat.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index 1917c034c045..07b494b06872 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2024,8 +2024,17 @@ static bool need_update(int cpu) for_each_populated_zone(zone) { struct per_cpu_zonestat *pzstats = per_cpu_ptr(zone->per_cpu_zonestats, cpu); + struct per_cpu_pages *pcp = per_cpu_ptr(zone->per_cpu_pageset, cpu); struct per_cpu_nodestat *n; + /* per_cpu_nodestats and per_cpu_zonestats maybe flush when cpu + * entering NOHZ full, see quiet_vmstat. so, we check pcp + * high_{min,max} to determine whether it is necessary to run + * decay_pcp_high on the corresponding CPU + */ + if (pcp->high_max > pcp->high_min) + return true; + /* * The fast way of checking if there are any vmstat diffs. */