Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3235638pxb; Tue, 13 Apr 2021 23:57:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQakgSILj5khBk1gvPlrirEN9dfbFWGrm5fLs+XkrdFhUbYKg1z5gdXzA+t5dgVhJDEBle X-Received: by 2002:a17:906:3952:: with SMTP id g18mr36285498eje.104.1618383477585; Tue, 13 Apr 2021 23:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618383477; cv=none; d=google.com; s=arc-20160816; b=UhQKbbQP5gLWVnL+r0BfMKWQz0C1ei62nReugt6v4mTRQ0EW65rwLQQwlOe/HBEgFC tKzYOqEZE88Cz4RVmL3gAzZjgQ6qdEy18tjjeiex61x9saH4OrMhgk8MaTuHsspNrOa8 nshUxFkGjuhGYT/Q4wx+JmkmVsv4m6uZk/1CKCYaQ8JlMJynd1vrAU8qV1p7Pp6K5/4w 8H5tXMwu0j/Kv/6miU4pXG8mICLxVzgzT2DZccJfept4Mkm3KmpX99bKgFnrg6+wDC22 ikh56JcB1F/D0QgPs9FNxRyNHUwLdkY7e5Aev/DXsCxxZGDdsvA1sUqT7/T4Jz/jwCjJ acIw== 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:dkim-signature; bh=TjUgcmFgfVUvxEgmX1mTT6tYY/s/MxXmpJtENaIxR0Y=; b=0LBOlYY+EXVY9IRJ0H6UKGl7KYJ46/65NrjXGQf4CGEJyVx4h5F+53txmoTmLAfhLd KNQAqwr+gkIF0OUdPoF2Tv3+qQB/06MYy/rL1rMbHcm8fHfE3hb+8dtq5l6hjaLLdy6P d4+GzeJdHzh+87efAkuLfkKN1C6hKbHLNuhjYk6wt3CsfH2OMgWxZNZPmXb2iT2LDWM5 DfFR4Gb4dstDj8gARGMR7ZwH32WHXtmom1zyqKT5Korhst1Kz2vzNoW98bfD7Zwgsdd9 3uRkgqfOLsRoILBHq6qjQnjKLiSJlIZmMy/X5stJdd6H5KEdyVFcUeXE34Jyvz+6UeSy vyMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WHt03bHY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y24si12212386edu.30.2021.04.13.23.57.34; Tue, 13 Apr 2021 23:57:57 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WHt03bHY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232557AbhDMVY4 (ORCPT + 99 others); Tue, 13 Apr 2021 17:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbhDMVYz (ORCPT ); Tue, 13 Apr 2021 17:24:55 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71398C061574; Tue, 13 Apr 2021 14:24:29 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id j7so8947989plx.2; 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=uQI5RSTOexVTJeRA9kkYr1sHh9CHlsNJLA9+gjRSFpjTdeh1iBvk2apdi8OPLmxfnb 0yKMEWkcjW/TncIrGOfZkw9yl6MLNmWz4hdIANaXWGWa4s4d2dLH4qZMXYJgvftTfLAM jBHrnPfcLvgtYOKnV7+MJS0QsF8rtj9Dz4vMaPvuExduR+yZXtJAmWh1HsI+d8Fi1MmY /QZJK7Qah+YzMcbuvEakXNBLTImH8YUO7vGbC53LxnZeAQt2AajlM6SjLuzEqZSAEMih 32XwFfn1m7gZMih1qZbC9sTKd3P919sDzcQ7xhba0KP9qzi9hg1bi+He4cIDg2/zNe8C kzrA== X-Gm-Message-State: AOAM5328PXdfXHVfZyMdHpbJPoewS0DLZY/e1gKcs09/y8qC8i7hAhLG durfDrVe4KP6inHmOBk+VVQ= 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changelog: v1 --> v2: * Adopted the suggestion from Gerald Schaefer to skip huge PMD for S390 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 Ying. * 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. 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. Per the discussion with Gerald Schaefer in v1 it is acceptible to skip huge PMD for S390 for now. 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. 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 supported. 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(-)