From patchwork Mon Mar 29 18:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12170755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FA12C433DB for ; Mon, 29 Mar 2021 18:33:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32C2860231 for ; Mon, 29 Mar 2021 18:33:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32C2860231 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BD8596B007D; Mon, 29 Mar 2021 14:33:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAEDC6B007E; Mon, 29 Mar 2021 14:33:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A76E16B0080; Mon, 29 Mar 2021 14:33:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id 87A456B007D for ; Mon, 29 Mar 2021 14:33:51 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 50947180AD822 for ; Mon, 29 Mar 2021 18:33:51 +0000 (UTC) X-FDA: 77973760662.33.DF1FBB8 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf01.hostedemail.com (Postfix) with ESMTP id 35D3C5001531 for ; Mon, 29 Mar 2021 18:33:42 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id d8so4821249plh.11 for ; Mon, 29 Mar 2021 11:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=01YFv97u/1C+DtxnTXcB2+iBR0vlWHdf1wN2Z9wyQP0=; b=R+RAYtH5b/2luX6Z/fzVxj5Pf7lBMY6Y0G4BaJZQK3CDPRKsc1tkqC1WxVZTIn4ymQ BZ5D+tFIUymF0DdYXm237HMelyjQgMpgw5NfFzrBS9+zJrCGtmb4f3vlPIs+4xgiomeH tgh+o444gXEiLs5179rBwEKwswafgrCbzbeplus/1ZHk7JmX/T5S4d4Q/302Na6I57ld ltGVZ4sHgR/S7CTbJbx70pyXtGfHV/LVWzb+bNH6cGKnBUrpe7j9cPSPn3yQqLBxJPqi xSa1URtLekNuX8WKwQaBi+Y9RYVQziPRFzd542Nwko7pvFDrDn1kysV+3Z6iQpZ1R92H xBcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=01YFv97u/1C+DtxnTXcB2+iBR0vlWHdf1wN2Z9wyQP0=; b=aei9+cnIigZJz6bpT8LZUuKTAACxnfwznKyvjX4cwQap5k9ommUIZlFpcfAQAGIOkK RKlUHvmdOvEmt563JcFGHme+wbGoCGEZJjY369D2Od7lqMTdi8qLbnDlC112vR36QeEY 5dq8I3pfPnv32XqGh1LIapYqkp1sk8SaNMGUamRgbcfzvdCTvXczmEPiQoBwhZK9DeYR OKZAdJvzHyaCPlNmQL4DsrbA4C96pOcHQS+l2P8DiK5439AQ9FlpOcH6TU0/i1iNSII6 fWDsDpNfoK/X66MepFh3ShT9mVvTzK622IMPlqui/CZ4lhBnJAutP51EPDiteZVHo5Ws j9GA== X-Gm-Message-State: AOAM533yPJO7NNdlkh8gvRaQ1x4nXlAqtC7HLmH87KWZ6k+OnXTtIoKJ srSZd97e08BfpTn/fl8KGyI= X-Google-Smtp-Source: ABdhPJzqbTDMbRyAcrawqKDPJ/vLTMHWAlAj3tjICANCsgQBGOUdEwvo91OavTeI0XLhTjnUiBPlSw== X-Received: by 2002:a17:902:ed84:b029:e7:1f2b:1eb4 with SMTP id e4-20020a170902ed84b02900e71f2b1eb4mr18187086plj.74.1617042820542; Mon, 29 Mar 2021 11:33:40 -0700 (PDT) Received: from localhost.localdomain (c-73-93-239-127.hsd1.ca.comcast.net. [73.93.239.127]) by smtp.gmail.com with ESMTPSA id x11sm1151158pjh.0.2021.03.29.11.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 11:33:39 -0700 (PDT) From: Yang Shi To: mgorman@suse.de, kirill.shutemov@linux.intel.com, ziy@nvidia.com, mhocko@suse.com, ying.huang@intel.com, hughd@google.com, hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/6] mm: thp: use generic THP migration for NUMA hinting fault Date: Mon, 29 Mar 2021 11:33:06 -0700 Message-Id: <20210329183312.178266-1-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 35D3C5001531 X-Stat-Signature: qu4na5cd431irtiad3gbq9emuya783su X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-pl1-f180.google.com; client-ip=209.85.214.180 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617042822-398294 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: When the THP NUMA fault support was added THP migration was not supported yet. So the ad hoc THP migration was implemented in NUMA fault handling. Since v4.14 THP migration has been supported so it doesn't make too much sense to still keep another THP migration implementation rather than using the generic migration code. It is definitely a maintenance burden to keep two THP migration implementation for different code paths and it is more error prone. Using the generic THP migration implementation allows us remove the duplicate code and some hacks needed by the old ad hoc implementation. A quick grep shows x86_64, PowerPC (book3s), ARM64 ans S390 support both THP and NUMA balancing. The most of them support THP migration except for S390. Zi Yan tried to add THP migration support for S390 before but it was not accepted due to the design of S390 PMD. For the discussion, please see: https://lkml.org/lkml/2018/4/27/953. I'm not expert on S390 so not sure if it is feasible to support THP migration for S390 or not. If it is not feasible then the patchset may make THP NUMA balancing not be functional on S390. Not sure if this is a show stopper although the patchset does simplify the code a lot. Anyway it seems worth posting the series to the mailing list to get some feedback. Patch #1 ~ #3 are preparation and clean up patches. Patch #4 is the real meat. Patch #5 keep THP not split if migration is failed for NUMA hinting. Patch #6 removes a hack about page refcount. I saw there were some hacks about gup from git history, but I didn't figure out if they have been removed or not since I just found FOLL_NUMA code in the current gup implementation and they seems useful. Yang Shi (6): mm: memory: add orig_pmd to struct vm_fault mm: memory: make numa_migrate_prep() non-static mm: migrate: teach migrate_misplaced_page() about THP mm: thp: refactor NUMA fault handling mm: migrate: don't split THP for misplaced NUMA page mm: migrate: remove redundant page count check for THP include/linux/huge_mm.h | 9 ++--- include/linux/migrate.h | 29 ++------------- include/linux/mm.h | 1 + mm/huge_memory.c | 141 +++++++++++++++++++--------------------------------------------------- mm/internal.h | 3 ++ mm/memory.c | 33 ++++++++--------- mm/migrate.c | 190 ++++++++++++++--------------------------------------------------------------------------------- 7 files changed, 94 insertions(+), 312 deletions(-)