Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1198947pxj; Fri, 18 Jun 2021 01:36:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ/EYfZ8Fb1vPeIY5oo2s1Xg4/anPsa4qc2hk657WVLTBywya08O9tsOTHQ8XQRFnlbPG3 X-Received: by 2002:a92:dc92:: with SMTP id c18mr6048644iln.191.1624005386645; Fri, 18 Jun 2021 01:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624005386; cv=none; d=google.com; s=arc-20160816; b=s8AZREhZOejv1l5oiy73TL2AsRQKO9n7J5i8yLFKmq0lYTMIhANr6asQAYJR3eYk4i gXH6Kv9ZsuP8T+r9aKNk0Usm7fJcuspxcflBIpTEqhnu6ba50VFGowZ+LhKEpgrSfYAf +6l5cwlJ/v8VmPPeQ0Dwl6gArEmkeZ8MSt2f4yXM48Ir3xf2LjZesokvQyu/jjjzWfK4 1ddaeRzRK1IPr1iux4SqdEgGB5vdZ3yazrrcEcFRrcJKtRZD658ZBRFwBU3G4xZ/uwv6 +ptXGxCPVYf5p4VXVHxKXCmlqM9VlNlSBmJ3eYd+R9+p38HBvD2BHGN2y5yzZQMpO33Z IAhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=NlswK+V9C0wvQ6wrVpO+YI+CyE3G1IvAsNAM5/FUTkI=; b=y2yqcw+6ryOUoraLI6ayW5v1fYfnFDp+SdAOL/igAt7LT6VR5JrCMb8L1hXaBaczkM G+boLimjXKGh96pdaf1RDYwqBIXzZ9B7Z9rIt9l+E8seSvdnnaarpudgRrjBiaSrsIWI GwzxyIe9Elhgblok6dH1DQ26omd575KIPr/wlDVv19AK4+3HM4fzah6EzuL2H+Al0rlQ nVGa9fmWBx+yZk+ChwovoVKjyYE8eLn6QpMNKl7zF19bMuhiqfh7BNH8U+zgwJn+uXWK aOmuUesT6wtmZjysvcq1lu1cEMAV7OgkDuWXFBm7/Et20rxVpBsdje6HGUlqRBSYc0rB uoWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 7si1474280ilz.34.2021.06.18.01.36.14; Fri, 18 Jun 2021 01:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233869AbhFRGVY (ORCPT + 99 others); Fri, 18 Jun 2021 02:21:24 -0400 Received: from mga18.intel.com ([134.134.136.126]:4815 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233227AbhFRGSO (ORCPT ); Fri, 18 Jun 2021 02:18:14 -0400 IronPort-SDR: TEIirjPT2lVfnhfI6Oe4S+eSPbLwsv1FTmNmuoSJiKwEiFu1HiNkWGyKAH5mngFwMDCc8xq7R1 zv25ZwaZHURw== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193815217" X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="193815217" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 23:16:05 -0700 IronPort-SDR: Tsnx0Ge7sp4sdJLwb8pmYdtHwANin74FJyHckWAl5UNJQ7Vn3uJcH/SnuGsAJGQVHT5RZHvhR3 COBTqSqGnkiQ== X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="485573590" Received: from mzhou6-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl1.ccr.corp.intel.com) ([10.254.212.155]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 23:16:01 -0700 From: Huang Ying To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Dave Hansen , yang.shi@linux.alibaba.com, rientjes@google.com, ying.huang@intel.com, dan.j.williams@intel.com, david@redhat.com, osalvador@suse.de, weixugc@google.com, Michal Hocko , Yang Shi Subject: [PATCH -V8 00/10] Migrate Pages in lieu of discard Date: Fri, 18 Jun 2021 14:15:27 +0800 Message-Id: <20210618061537.434999-1-ying.huang@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The full series is also available here: https://github.com/hying-caritas/linux/tree/automigrate-20210618 The changes since the last post are as follows, * Change the page allocation flags per Michal's comments. * Change the user interface to enable the feature. -- We're starting to see systems with more and more kinds of memory such as Intel's implementation of persistent memory. Let's say you have a system with some DRAM and some persistent memory. Today, once DRAM fills up, reclaim will start and some of the DRAM contents will be thrown out. Allocations will, at some point, start falling over to the slower persistent memory. That has two nasty properties. First, the newer allocations can end up in the slower persistent memory. Second, reclaimed data in DRAM are just discarded even if there are gobs of space in persistent memory that could be used. This set implements a solution to these problems. At the end of the reclaim process in shrink_page_list() just before the last page refcount is dropped, the page is migrated to persistent memory instead of being dropped. While I've talked about a DRAM/PMEM pairing, this approach would function in any environment where memory tiers exist. This is not perfect. It "strands" pages in slower memory and never brings them back to fast DRAM. Huang Ying has follow-on work which repurposes autonuma to promote hot pages back to DRAM. This is also all based on an upstream mechanism that allows persistent memory to be onlined and used as if it were volatile: http://lkml.kernel.org/r/20190124231441.37A4A305@viggo.jf.intel.com We have tested the patchset with the postgresql and pgbench. On a 2-socket server machine with DRAM and PMEM, the kernel with the patchset can improve the score of pgbench up to 22.1% compared with that of the DRAM only + disk case. This comes from the reduced disk read throughput (which reduces up to 70.8%). == Open Issues == * Memory policies and cpusets that, for instance, restrict allocations to DRAM can be demoted to PMEM whenever they opt in to this new mechanism. A cgroup-level API to opt-in or opt-out of these migrations will likely be required as a follow-on. * Could be more aggressive about where anon LRU scanning occurs since it no longer necessarily involves I/O. get_scan_count() for instance says: "If we have no swap space, do not bother scanning anon pages" -- Changes since (automigrate-20210331): * Change the page allocation flags per Michal's comments. * Change the user interface to enable the feature. Changes since (automigrate-20210304): * Add ack/review tags * Remove duplicate synchronize_rcu() call Changes since (automigrate-20210122): * move from GFP_HIGHUSER -> GFP_HIGHUSER_MOVABLE since pages *are* movable. * Separate out helpers that check for being able to relaim anonymous pages versus being able to meaningfully scan the anon LRU. Changes since (automigrate-20200818): * Fall back to normal reclaim when demotion fails * Fix some compile issues, when page migration and NUMA are off Changes since (automigrate-20201007): * separate out checks for "can scan anon LRU" from "can actually swap anon pages right now". Previous series conflated them and may have been overly aggressive scanning LRU * add MR_DEMOTION to tracepoint header * remove unnecessary hugetlb page check Changes since (https://lwn.net/Articles/824830/): * Use higher-level migrate_pages() API approach from Yang Shi's earlier patches. * made sure to actually check node_reclaim_mode's new bit * disabled migration entirely before introducing RECLAIM_MIGRATE * Replace GFP_NOWAIT with explicit __GFP_KSWAPD_RECLAIM and comment why we want that. * Comment on effects of that keep multiple source nodes from sharing target nodes Cc: Dave Hansen Cc: Michal Hocko Cc: Yang Shi Cc: David Rientjes Cc: Dan Williams Cc: David Hildenbrand Cc: osalvador Cc: Wei Xu