From patchwork Wed Nov 24 18:58:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hasan Al Maruf X-Patchwork-Id: 12637455 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 1CCD8C433F5 for ; Wed, 24 Nov 2021 19:01:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFBC56B0080; Wed, 24 Nov 2021 13:58:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BAB726B0081; Wed, 24 Nov 2021 13:58:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A99FD6B0082; Wed, 24 Nov 2021 13:58:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 9C6206B0080 for ; Wed, 24 Nov 2021 13:58:53 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 65C9E1819540A for ; Wed, 24 Nov 2021 18:58:43 +0000 (UTC) X-FDA: 78844735326.14.FAB14E3 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by imf06.hostedemail.com (Postfix) with ESMTP id D39AD801AB26 for ; Wed, 24 Nov 2021 18:58:41 +0000 (UTC) Received: by mail-qt1-f182.google.com with SMTP id n15so3759568qta.0 for ; Wed, 24 Nov 2021 10:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c8O4w4nNPT48Gz0ug3bIri+YOWUNMewgSmQGxvpFnas=; b=LEPblEdbTMxrbKN35oBufL867FsoCNA/nV/tHj4hwBCsprMCXbNk+GtDRAa9UHe/hO CpjryhYp9QjFwcpG2Soe1Ly7qQb1jZGZZxC/3hcEnWihYika6GYh4TjyajuXqRU0noQ0 PFsQn8jexN4t3at883m8Z4moCvw2KMtpvsETu4NnJFlQKJAEcamh/8dOGuIzfpbHyX8w lp9ldPtS678svFM8YQEivq+ksZwGZ76Ft71Ua9HpTheovrv6DTcgpIdh9kcLhJSj0h53 rU4wLOL0EzNopsMtn+aAwSNvsusJbGOq/XySZ8SjwxBH7s7d8PU52IyQiAK4mMfxc1im iSOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c8O4w4nNPT48Gz0ug3bIri+YOWUNMewgSmQGxvpFnas=; b=rqMRFPXWcnrAZUpgVEaO0yhXq90pDUcbEgYeLITyh8qnqzlwLDeJSK+Ef1bBNX18W+ Mbj4Ba6nfzmrnXw7Du3i3JCQ4PZ73fnzuMUfH+/4rljSelCNo3la/JDazwP12RxGrqaQ iMccTOciX1E7Dm4UPB+GwYxXtRKLyP4UnT55Nn0UbXUc6shNEqoIRApEcFYqw0LbIlT5 wE32AQ3Pxci3fIzQcoE/V0ODlB1TMxW5acp+jv+ALMse80diAYhdYnTz/ssY8O0UxYp7 RNTMvt3JS7Py+GMf9Z/jLAleB/BKxdpEnnWDLp65G1nh0fkcqiU5SlxWKEUP9F+V9nGA BW5Q== X-Gm-Message-State: AOAM531bXIpTdfRd35EEnAr51B0z+ibj/T5qW5OiSm/tgSNa1YoqiBI4 GiLjAonNVQCGWng5ZgMvr0K6mfTshwQ= X-Google-Smtp-Source: ABdhPJwi0QsIpPMyyN2YfjBQZcNe66urLapq29ZrTQ6Gar5CnAHDLAYsvG7j8AZiMPs+QWIWUe1LJw== X-Received: by 2002:ac8:588e:: with SMTP id t14mr1267458qta.437.1637780322392; Wed, 24 Nov 2021 10:58:42 -0800 (PST) Received: from hasanalmaruf-mbp.thefacebook.com ([2620:10d:c091:480::1:a1b0]) by smtp.gmail.com with ESMTPSA id r16sm315775qkp.42.2021.11.24.10.58.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 10:58:42 -0800 (PST) From: Hasan Al Maruf X-Google-Original-From: Hasan Al Maruf To: dave.hansen@linux.intel.com, ying.huang@intel.com, yang.shi@linux.alibaba.com, mgorman@techsingularity.net, riel@surriel.com, hannes@cmpxchg.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] active LRU-based promotion to avoid ping-pong Date: Wed, 24 Nov 2021 13:58:30 -0500 Message-Id: <80a0cfd545a01ce0470a727cb961a5e0a1532d48.1637778851.git.hasanalmaruf@fb.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D39AD801AB26 X-Stat-Signature: ijx5gkcbeackykc7roi1fouq6436whiu Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LEPblEdb; spf=pass (imf06.hostedemail.com: domain of hasan3050@gmail.com designates 209.85.160.182 as permitted sender) smtp.mailfrom=hasan3050@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1637780321-290272 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: Whenever a remote hint-fault happens on a page, the default NUMA balancing promotes the page without checking its state. As a result, cold pages with very infrequent accesses, can still be the promotion candidates. Once promoted to the local node, these type of pages may shortly become the demotion candidate if the toptier nodes are always under pressure. Thus, promotion traffics generated from infrequently accessed pages can easily fill up the toptier node's reclaimed free spaces and eventually generate a higher demotion traffic for the non- toptier node. This demotion-promotion ping-pong causes unnecessary traffic over the memory nodes and can negatively impact on the performance of memory bound applications. To solve this ping-pong issue, instead of instant promotion, we check a page's age through its position in the LRU list. If the faulted page is in inactive LRU, then we don't instantly consider the page as the promotion candidate as it might be an infrequently accessed pages. We only consider the faulted pages that are in the active LRUs (either of anon or file active LRU) as the promotion candidate. This approach significantly reduce the promotion traffic and always maintain a satisfactory amount of free memory on the toptier node to support both new allocations and promotion from non-tortier nodes. Signed-off-by: Hasan Al Maruf --- mm/memory.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 314fe3b2f462..1c76f074784a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4202,6 +4202,19 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) last_cpupid = page_cpupid_last(page); page_nid = page_to_nid(page); + + /* Only migrate pages that are active on non-toptier node */ + if (numa_promotion_tiered_enabled && + !node_is_toptier(page_nid) && + !PageActive(page)) { + count_vm_numa_event(NUMA_HINT_FAULTS); + if (page_nid == numa_node_id()) + count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL); + mark_page_accessed(page); + pte_unmap_unlock(vmf->pte, vmf->ptl); + goto out; + } + target_nid = numa_migrate_prep(page, vma, vmf->address, page_nid, &flags); pte_unmap_unlock(vmf->pte, vmf->ptl);