From mboxrd@z Thu Jan 1 00:00:00 1970 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 D86FCCD68E0 for ; Tue, 10 Oct 2023 00:42:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D3738D00A7; Mon, 9 Oct 2023 20:42:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65BCD8D0089; Mon, 9 Oct 2023 20:42:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCB48D00A7; Mon, 9 Oct 2023 20:42:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3D2A78D0089 for ; Mon, 9 Oct 2023 20:42:16 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1269A1CAAD5 for ; Tue, 10 Oct 2023 00:42:16 +0000 (UTC) X-FDA: 81327700272.17.D59E83B Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf15.hostedemail.com (Postfix) with ESMTP id 499A7A001C for ; Tue, 10 Oct 2023 00:42:14 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=o87WvQrd; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696898534; 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=U2xnudV2rLqe7XibfZT3AT322yYpTfs1Ar5yIDcKWos=; b=Qz4IDeF/fckgZbeDtHChK5LbBXy7gZHPBv0y5MWJ2EMCcxUqVWzWBRCSRHY159oBkrVTUZ JLXdb747/C5Il2eu1fuUFlNKHCYAq5NA933hYJ531pkRaNYOpfFo2Mtd7CpT4YcL5ckIrV Od6dHSDmZ7D/SQSoQqlhZeO3Me3XEEc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=o87WvQrd; dmarc=none; spf=pass (imf15.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696898534; a=rsa-sha256; cv=none; b=S5kcavQzTCtnUq9lvsl9HgUOVEFpKCO17HBctVZy4mNhBWTdfK3zfTUZdMAvedjy9W2XBP Dj/1SAXfvMFfqL9OB6myj/OynQhL+1dDpSGHdozRukS7/OEhupmyh/Gwiphzq6VKZEjuSR sMBxS27WyoJ28Q317y3ngAHpe1tTl50= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id ECCA6B816F6; Tue, 10 Oct 2023 00:42:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA6E0C433C7; Tue, 10 Oct 2023 00:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1696898532; bh=Jh0sIBZh8nxYbq7VHsim1Kh7Mp+jQxSntzGqnBwKMdM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=o87WvQrd7I/dovg4pdMTbRabyl26XrcKQ0m+jND++sXRPeTn3nE4igwsAyn5wgNiX Yr/s6LBeJMB5FBRXOKggvWzX/+1pkIXQgQIJeXBIG6LxBVqf51T3yEvYVBmZsF4xiq oRbCdSydZNA7EQrMu7+Vt0QtSmlBj904i6oGEOCs= Date: Mon, 9 Oct 2023 17:41:35 -0700 From: Andrew Morton To: Huang Ying Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , Mel Gorman , Vlastimil Babka , Michal Hocko Subject: Re: [PATCH -V2] mm: fix draining PCP of remote zone Message-Id: <20231009174135.2357dcfcdc691a6ef61dbd9a@linux-foundation.org> In-Reply-To: <20231007062356.187621-1-ying.huang@intel.com> References: <20231007062356.187621-1-ying.huang@intel.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 499A7A001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: djwz7hu6gb9fx3ymjgfc7wty39ahqp84 X-HE-Tag: 1696898534-515839 X-HE-Meta: U2FsdGVkX1+bPtMFCF4iLgpw+B/DudJ1ZcAM7kljucoJBKRYaXgmglAB6K8mhWGxIyj+nO4qD4EkX++uPg3LRw6WHPmY+Ej15h4m2BY9m6LVuoHtWDPnjIbIG8rKCrv99tDrDx8Ic5q5VeDuyPNc0DxS7WIUysuoT2/bzs79nV8FH2R/YSbHjDRtss4h2chDZzgZG4082R1z27AuIbDoZmN0j7n1yzFwPnd1ZH/LNll3D1KfBhUnbZ0WR6nRrxiFqsJMdIFTacWsM+IsHkUhmlC59hY9UVBmP+vioXHhqOjBmhGuDCL2y0WsbesT5OkfN80+AGVKdoy9C/GguXOVOmzmE0VUbM2Q2DvvkMZrpoOAJ2NTwvkI/0HophGIiRY/hdM4y31Y0iq+r+SOL9nCLc6c/BIdC4H6yZRE8PY6RwkRWWcdCglnwqqYqqsEKZRiqKae50OpH4tgkC8L1vQT5402ozP+Nm128uRHi0CrPG+eyaMgpV4LlAVLcMnNN89FZ4vuf6gof3+GGBIKbwEdcj32YVVNcXm1hhbedg1ZQ4BSX2b6EkdwEHKm4UnWWzO5bbapjpMkirr8WelVy8H3jq0T4Is2FCN8Za3QJXmGDYX3WB2m+5OnMCCegRlR6QeLt5GLxkjmQJeY5y9DguZytEI5EUVbAE0ClM69gGcEvN11Rn66aKSbfO44LR37tv5RZj+57Ekw63ELX/IWjVUwDLuhUpyUBE5Fp8+MAy5r8Upk+pmdx/hU8R5TwO3x0vDPaLxd3AfBk3k8FSjLTccjVMLcj0zU8/2D8nbwNBErD3FUJTI3ztiCfqZW6fPuuP5cXxThfSw8efPUMhx01CaoJGnhRO/GVrDMlxbvUF019G8E/kODmtp5Dfdw7DowGL6F79r0kKUd4Ut9qzm7KmUiv2DcYfxJIY1Qfp3WwWXLku0GVg+LR0OQvHJqMMb/My6/fHuVEWS+euErOZd/tEC QQacZDnP ifN0zCWvK9MlL6zpZD/mIqZGjZBPv5oVwLosa6w1WzDSlDoAEYyfPO0AXmX2O5JxPqgn79CVNZdsBohoh7A281RV+xde1J5eq5m6/GXewX8ItHRiAdxfZybchSxH26O0XP8DKYGnjBEJ4fE1a/M1OWTSUIxl35KnVCmiIuWG157gNtK9iq6uynaIrR216DS8+wYTLhxh1nJ3O6mwYfoJ54ezjw0qBGzJhxmdCjFvmQwAaqn6gjGpzNO8sIJdSAH3Bw/CO 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: On Sat, 7 Oct 2023 14:23:56 +0800 Huang Ying wrote: > If there is no memory allocation/freeing in the PCP (Per-CPU Pageset) > of a remote zone (zone in remote NUMA node) after some time (3 seconds > for now), the pages of the PCP of the remote zone will be drained to > avoid memory wastage. > > This behavior was introduced in the commit 4ae7c03943fc ("[PATCH] > Periodically drain non local pagesets") and the commit > 4037d452202e ("Move remote node draining out of slab allocators") > > But, after the commit 7cc36bbddde5 ("vmstat: on-demand vmstat workers > V8"), the vmstat updater worker which is used to drain the PCP of > remote zones may not be re-queued when we are waiting for the > timeout (pcp->expire != 0) if there are no vmstat changes on this CPU, > for example, when the CPU goes idle or runs user space only workloads. > This may cause the pages of a remote zone be kept in PCP of this CPU > for long time. So that, the page reclaiming of the remote zone may be > triggered prematurely. This isn't a severe problem in practice, > because the PCP of the remote zone will be drained if some memory are > allocated/freed again on this CPU. And, the PCP will eventually be > drained during the direct reclaiming if necessary. > > Anyway, the problem still deserves a fix via guaranteeing that the > vmstat updater worker will always be re-queued when we are waiting for > the timeout. In effect, this restores the original behavior before > the commit 7cc36bbddde5. > > We can reproduce the bug via allocating/freeing pages from a remote > zone then go idle as follows. And the patch can fix it. > > - Run some workloads, use `numactl` to bind CPU to node 0 and memory to > node 1. So the PCP of the CPU on node 0 for zone on node 1 will be > filled. > > - After workloads finish, idle for 60s > > - Check /proc/zoneinfo > > With the original kernel, the number of pages in the PCP of the CPU on > node 0 for zone on node 1 is non-zero after idle. With the patched > kernel, it becomes 0 after idle. That is, we avoid to keep pages in > the remote PCP during idle. > Thanks, I updated the changelog in place and queued this for mm-stable.