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 DE386EE49A5 for ; Mon, 21 Aug 2023 22:34:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45D04940018; Mon, 21 Aug 2023 18:34:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40C4594000B; Mon, 21 Aug 2023 18:34:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FC0B940018; Mon, 21 Aug 2023 18:34:03 -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 1EB0694000B for ; Mon, 21 Aug 2023 18:34:03 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DF57C8011D for ; Mon, 21 Aug 2023 22:34:02 +0000 (UTC) X-FDA: 81149565924.14.6433A8E Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by imf25.hostedemail.com (Postfix) with ESMTP id 8C5F9A0010 for ; Mon, 21 Aug 2023 22:33:59 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Uyj6ur9p; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf25.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692657240; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=O2Oxfl/boi0cnZiSNWsPGV8CAF5cWynnPQp10AszqzI=; b=poDI5PJMTpO/N+EhBuuJJEyJ+YDRE/3wqMLBYlUrC8eJZFL0TH4MmxcxQv7hX95w8u3Dh4 MR6Sg/BmY0mwd05cy8XtIr0mC/e50/+Dnx7AKP5tD8BsOFsJ80m2629OruX35DKSZhcFBZ cTgtecwMJkODsXwi5ih8qq4dBBnDT9k= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Uyj6ur9p; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf25.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692657240; a=rsa-sha256; cv=none; b=NxHtq7P2r6ad6BXu4iIi5n6gNYxovNQk9tgVjvALn0NWnJC2UMDPazamaQTeafruHqB89G CoIeuvaHG+MNTSGrR1AOkCxzqXsh2YhHtrIGoIkkEAXbcHH9gfw/sEPe/FakuGiwarTgU5 TuEkCId2CnVnifAXFirO678QYUCDdoE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692657239; x=1724193239; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=y1oGB6OYm+lMPRY3bo4wb8Bk5yhL5dA7ScBZDtcGFU0=; b=Uyj6ur9pLmLh0AnK8ciJj6LBFqki3skOBKZI0FDiKHsPT2gku2Rg069b NTHtDpr3PtpRVc60dYfwl4utdQL44fmjjD4UhFxPVNcIQwqpNkoY5GRor RsRE1PHI6QI1EmEAQ5O01hC4egGbc5akNYzlrbw+wSY67F59yNuB9Vrbl S1eZBWA7veiqzelFm8KLCuLmM/U3LEYMEy9KCSNowY+wa7qdLMQ1fA0h5 rvJH1jaCEeV0aMxnONR7Ih0gLTfKu4ffRz+Jql8VjbN7k57dKgrS942Po f4GpDRVqDnGFgd+Kq3c8GuZW/To1N5jBFEYqDRFMd7aAVGX3w5B421PD6 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="354038685" X-IronPort-AV: E=Sophos;i="6.01,191,1684825200"; d="scan'208";a="354038685" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2023 15:33:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="765533793" X-IronPort-AV: E=Sophos;i="6.01,191,1684825200"; d="scan'208";a="765533793" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2023 15:33:55 -0700 From: "Huang, Ying" To: Michal Hocko Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , Mel Gorman , Vlastimil Babka Subject: Re: [PATCH] mm: fix draining remote pageset References: <20230811090819.60845-1-ying.huang@intel.com> <87r0o6bcyw.fsf@yhuang6-desk2.ccr.corp.intel.com> <87jztv79co.fsf@yhuang6-desk2.ccr.corp.intel.com> <87v8d8dch1.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Tue, 22 Aug 2023 06:31:42 +0800 In-Reply-To: (Michal Hocko's message of "Mon, 21 Aug 2023 11:27:38 +0200") Message-ID: <87msykc9ip.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 8C5F9A0010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xqgi8wsbf7588coys5a1yimu8wswa189 X-HE-Tag: 1692657239-586551 X-HE-Meta: U2FsdGVkX18RVf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CTDmN6vJNEp/0DwzViZiAM5/OXW+IQVs1XnAHl7W9UyI6LkGmMUD6awk+0aDHEm+DM3pbaVTLSxHQEMGDPG1+fg1ScY= 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: Michal Hocko writes: > On Mon 21-08-23 16:30:18, Huang, Ying wrote: >> Michal Hocko writes: >> >> > On Wed 16-08-23 15:08:23, Huang, Ying wrote: >> >> Michal Hocko writes: >> >> >> >> > On Mon 14-08-23 09:59:51, Huang, Ying wrote: >> >> >> Hi, Michal, >> >> >> >> >> >> Michal Hocko writes: >> >> >> >> >> >> > On Fri 11-08-23 17:08:19, Huang Ying wrote: >> >> >> >> 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. >> >> >> > >> >> >> > Why is that a problem? >> >> >> >> >> >> The pages of the remote zone may be kept in the local per-CPU pageset >> >> >> for long time as long as there's no page allocation/freeing on the >> >> >> logical CPU. In addition to the logical CPU goes idle, this is also >> >> >> possible if the logical CPU is busy in the user space. >> >> > >> >> > But why is this a problem? Is the scale of the problem sufficient to >> >> > trigger out of memory situations or be otherwise harmful? >> >> >> >> This may trigger premature page reclaiming. The pages in the PCP of the >> >> remote zone would have been freed to satisfy the page allocation for the >> >> remote zone to avoid page reclaiming. It's highly possible that the >> >> local CPU just allocate/free from/to the remote zone temporarily. >> > >> > I am slightly confused here but I suspect by zone you mean remote pcp. >> > But more importantly is this a concern seen in real workload? Can you >> > quantify it in some manner? E.g. with this patch we have X more kswapd >> > scanning or even hit direct reclaim much less often. >> >> So, >> >> we should free PCP pages of the remote zone if there is no page >> >> allocation/freeing from/to the remote zone for 3 seconds. >> > >> > Well, I would argue this depends a lot. There are workloads which really >> > like to have CPUs idle and yet they would like to benefit from the >> > allocator fast path after that CPU goes out of idle because idling is >> > their power saving opportunity while workloads want to act quickly after >> > there is something to run. >> > >> > That being said, we really need some numbers (ideally from real world) >> > that proves this is not just a theoretical concern. >> >> The behavior to drain the PCP of the remote zone (that is, remote PCP) >> was introduced in commit 4ae7c03943fc ("[PATCH] Periodically drain non >> local pagesets"). The goal of draining was well documented in the >> change log. IIUC, some of your questions can be answered there? >> >> This patch just restores the original behavior changed by commit >> 7cc36bbddde5 ("vmstat: on-demand vmstat workers V8"). > > Let me repeat. You need some numbers to show this is needed. I have done some test for this patch as follows, - 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, that becomes 0 after idle. We avoid to keep pages in the remote PCP during idle. This is the number I have. If you think it isn't enough to justify the patch, then I'm OK too (although I think it's enough). Because the remote PCP will be drained later when some pages are allocated/freed on the CPU. -- Best Regards, Huang, Ying