From patchwork Fri Aug 11 09:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13350273 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 9884CC0015E for ; Fri, 11 Aug 2023 09:08:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1286C8D0002; Fri, 11 Aug 2023 05:08:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B1486B008C; Fri, 11 Aug 2023 05:08:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBA478D0002; Fri, 11 Aug 2023 05:08:35 -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 D8DD46B008A for ; Fri, 11 Aug 2023 05:08:35 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AA55D1C8AF0 for ; Fri, 11 Aug 2023 09:08:35 +0000 (UTC) X-FDA: 81111248190.10.5B5FDF7 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by imf16.hostedemail.com (Postfix) with ESMTP id 1DE5018000A for ; Fri, 11 Aug 2023 09:08:32 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=b8zsV+Kr; spf=pass (imf16.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691744913; 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=tCIRTN89TdovPdvKl0fthpMHCcOT0eprRrlu8+OPaFs=; b=uNTdnLSOqX9qy4wL0O8EcopptoPge/xzh3BWglbmC46Xw1hgdqFO/cI0RIepVZffKF/nHa pcRDoaSddY+aD+63v/iGGKCfyHkZTs6imAaZq9aoyRP+KwZb1ImdqmhvcUXCzbbHfbfHRe WADEt8Ij6RUlLr6jRBWk/l5s2Hraifw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691744913; a=rsa-sha256; cv=none; b=uExAz0RxFvMNuVAUCg7t3fh3/jFsazu/LSvEyGU+VCesL+MYQy8ClVU7NmgeW5QzHz26bv QEN331xF2RuT3onAvnrUfYi9dztr9vMCiYnGmoRUyy/qsTmZ8KDFTaOJDRDrRyCamhN6Rs OHxovo4sHGBm+eLgq3XuUWWeqKPhTjU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=b8zsV+Kr; spf=pass (imf16.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691744913; x=1723280913; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4zCoxQNaeT/5ThBR5TbY5aUu/39R4oWKDboADgANSxI=; b=b8zsV+KrUSl2SDT8qQHM5PHah1ebl0rtCorsaaetokSJnqpoToFIqwUZ IgQMsBUevG2O3Wrf2KlNML42zZcMI+92lcBxAlmjt2KqENttTR/p/u//m qfNm1934MjvySdA6fPKHK5HvtVTb+P/g32gfyPBn157gCUSRKdoTQdgHy kQy7QtkjVLKr57P9NPvWxg1n3Y+8wZVUt6Rj/wgZxhaqXPAy8m0Q9Zj7d piOIbx1fjva3OUMAx+s4lgXx08SUfonnVH5SgrcmCRw0lOTkfuugpQoml 7p/AJm0buxJolD6mfN+o09R9xbUSGhdWxbtcwRHMsvHhqGX4p0LQnM8mE A==; X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="458008353" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="458008353" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2023 02:08:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="876091008" Received: from jallred-mobl.amr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.28.249]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2023 02:08:32 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Christoph Lameter , Mel Gorman , Vlastimil Babka , Michal Hocko Subject: [PATCH] mm: fix draining remote pageset Date: Fri, 11 Aug 2023 17:08:19 +0800 Message-Id: <20230811090819.60845-1-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 1DE5018000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: t96e57zxenjt6xdj6ih4a9cg87tqpo1z X-HE-Tag: 1691744912-619947 X-HE-Meta: U2FsdGVkX18E4ithAbdKholHDyynA4W45UCTMf6Ed0mGFTerGCsbAuVr3TSmDLdIB/hNg05gP69J0+8d4SdHCmzWxCHvULX7oXbRO9IlS0Y5SebsWCbmBFjrTfB0d6a3Pxnpkq4EYQdwAxyRfss+u8GWQtKnqAuPtNAuopStL8+AAthgV/OOUsDwIqiMyHOJsI4YSzfAQgyAy37E4q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H52wBaQw53/340dNvCgPg1x0igW59kdA= 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: If there is no memory allocation/freeing in the remote pageset after some time (3 seconds for now), the remote pageset will be drained to avoid memory wastage. But in the current implementation, vmstat updater worker may not be re-queued when we are waiting for the timeout (pcp->expire != 0) if there are no vmstat changes, for example, when CPU goes idle. This is fixed via guaranteeing that the vmstat updater worker will always be re-queued when we are waiting for the timeout. We can reproduce the bug via allocating/freeing pages from remote node, then go idle. And the patch can fix it. Fixes: 7cc36bbddde5 ("vmstat: on-demand vmstat workers V8") Signed-off-by: "Huang, Ying" Cc: Christoph Lameter Cc: Mel Gorman Cc: Vlastimil Babka Cc: Michal Hocko Reviewed-by: Christoph Lameter --- mm/vmstat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index b731d57996c5..111118741abf 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -856,8 +856,10 @@ static int refresh_cpu_vm_stats(bool do_pagesets) continue; } - if (__this_cpu_dec_return(pcp->expire)) + if (__this_cpu_dec_return(pcp->expire)) { + changes++; continue; + } if (__this_cpu_read(pcp->count)) { drain_zone_pages(zone, this_cpu_ptr(pcp));