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 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,URIBL_BLOCKED,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 EB3EBC433B4 for ; Tue, 13 Apr 2021 21:24:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6242B611F2 for ; Tue, 13 Apr 2021 21:24:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6242B611F2 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 D87CA6B0072; Tue, 13 Apr 2021 17:24:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D361A6B0073; Tue, 13 Apr 2021 17:24:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B892B6B0074; Tue, 13 Apr 2021 17:24:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 995F76B0072 for ; Tue, 13 Apr 2021 17:24:30 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4E55B1802EAC3 for ; Tue, 13 Apr 2021 21:24:30 +0000 (UTC) X-FDA: 78028622700.18.79CEBA9 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf28.hostedemail.com (Postfix) with ESMTP id 30D682000261 for ; Tue, 13 Apr 2021 21:24:31 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id p16so4982478plf.12 for ; Tue, 13 Apr 2021 14:24:29 -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=TjUgcmFgfVUvxEgmX1mTT6tYY/s/MxXmpJtENaIxR0Y=; b=WHt03bHYh693At+HejleiJT5QnmfyIMK2f+Fr/QYvCch1IguEoJKhBNalXI7wTWcDJ aj2guXQUN6nRHP5aqfoctgDCZRcU+9RCwIoaziahPsOXBLZf/XPQNBw0bAaPEAWO2PVG 36elbT/Ehn2HWNBDwpsTwHQfvWWyUkoGRYn/Zh8cwKZAe9BBGo1syrC8NpmvFT4/pkxr MXWh+8fl0+1d15nluwkLe9XR+GnGyxwkeG1TEsFG6HEZ1OwF+ogITKKjeIAa37OE44tF DSSx4zTujy+rU5Ee6laP+1H3wvLRqAqkThDA+u1QlR8fwVsmxE8dSbGUaZyljZkYQaiK rjwQ== 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=TjUgcmFgfVUvxEgmX1mTT6tYY/s/MxXmpJtENaIxR0Y=; b=ju6rj2heY7hozIBHbFuetVOb6LSs6UaL2FcsEjMglLlpNNLiMjX1JM2QS54hyqa1mY AXjSHcTA1XvJytBoUTmhtLEBKrzgW/OHsqXOgJ+02Rlvov3t2Lg4unpTRTJ2eqh4fKh3 gcjRANLA9qPGdy0DZXAk5bVn9vAr8LV9ezGyFKBbrE/EFybUS1saLQIQ1yRvHemRA2oj EQRikHYT7GTLbIFY2p+lS4eR9SLY/sE0/gA3/jsPBWgqVWjvzlgl0fhRv4OP1gayHd2P DQZ9TcJAwKARCH92PA+cp8fxNDKNshT5L4nc5/p88IWw3LTKuJzXrH2C+C/bxZ8+wWf9 a4jw== X-Gm-Message-State: AOAM5330wgUZvpaYrpmPHx3ESkq9OckG9zMtCvhUTdGcsNVX7J6xST9q LKokh3Znvg7++D991QTX6mQ= X-Google-Smtp-Source: ABdhPJwG+h4Eaee+6xKwhiomhLOrGif7IjgvEYV2eR4WT8U78sOVrCpxXeFTL0gfL/O99D7EdyfIcg== X-Received: by 2002:a17:90a:5884:: with SMTP id j4mr2183180pji.33.1618349068996; Tue, 13 Apr 2021 14:24:28 -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 fw24sm3069345pjb.21.2021.04.13.14.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 14:24:28 -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, gerald.schaefer@linux.ibm.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: [v2 RFC PATCH 0/7] mm: thp: use generic THP migration for NUMA hinting fault Date: Tue, 13 Apr 2021 14:24:09 -0700 Message-Id: <20210413212416.3273-1-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 30D682000261 X-Stat-Signature: k3qb8sjad5okd5ap9w7whcnwj8ue6md7 X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mail-pl1-f170.google.com; client-ip=209.85.214.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618349071-695676 Content-Transfer-Encoding: quoted-printable 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: Changelog: v1 --> v2: * Adopted the suggestion from Gerald Schaefer to skip huge PMD for S3= 90 for now. * Used PageTransHuge to distinguish base page or THP instead of a new parameter for migrate_misplaced_page() per Huang Ying. * Restored PMD lazily to avoid unnecessary TLB shootdown per Huang Yi= ng. * Skipped shared THP. * Updated counters correctly. * Rebased to linux-next (next-20210412). 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. Sinc= e v4.14 THP migration has been supported so it doesn't make too much sense to sti= ll keep another THP migration implementation rather than using the generic migrat= ion code. It is definitely a maintenance burden to keep two THP migration implementation for different code paths and it is more error prone. Usin= g 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 S3= 90. 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. Per the discussion with Gerald Schaefer in v1 it is acceptible to skip hu= ge PMD for S390 for now. I saw there were some hacks about gup from git history, but I didn't figu= re out if they have been removed or not since I just found FOLL_NUMA code in the= current gup implementation and they seems useful. I'm trying to keep the behavior as consistent as possible between before = and after. But there is still some minor disparity. For example, file THP won't get migrated at all in old implementation due to the anon_vma check, but the new implementation doesn't need acquire anon_vma lock anymore, so file THP might get migrated. Not sure if this behavior needs to be kept. Patch #1 ~ #2 are preparation patches. Patch #3 is the real meat. Patch #4 ~ #6 keep consistent counters and behaviors with before. Patch #7 skips change huge PMD to prot_none if thp migration is not suppo= rted. Yang Shi (7): mm: memory: add orig_pmd to struct vm_fault mm: memory: make numa_migrate_prep() non-static mm: thp: refactor NUMA fault handling mm: migrate: account THP NUMA migration counters correctly mm: migrate: don't split THP for misplaced NUMA page mm: migrate: check mapcount for THP instead of ref count mm: thp: skip make PMD PROT_NONE if THP migration is not supported include/linux/huge_mm.h | 9 ++--- include/linux/migrate.h | 23 ----------- include/linux/mm.h | 3 ++ mm/huge_memory.c | 156 +++++++++++++++++++++++++-----------------= ------------------------------ mm/internal.h | 21 ++-------- mm/memory.c | 31 +++++++-------- mm/migrate.c | 204 +++++++++++++++++++++---------------------= ----------------------------------------------------- 7 files changed, 123 insertions(+), 324 deletions(-)