Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7598299imu; Mon, 3 Dec 2018 15:52:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQVfsehYhgLH3+GgxqYOzmToiVM+XNJKW+4EexOUuno51uYUsDbByuaxogeIgXgFkB83UH X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr17352957plv.94.1543881139451; Mon, 03 Dec 2018 15:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543881139; cv=none; d=google.com; s=arc-20160816; b=wdVZW4fup4QCQ2w6tuhgNE65J1ZkI7x8znIL2hN2NIQllUcyU2fLVTRFAKaT3TM/Sk Y67Dg4q6KjyAWIe8on5BTz5Vn1ur5UHwXqGD7F8esf55YBJpRb3oapzQVqrAUVonL0fP UirJvbRxna5NvP7ZVFHexJeBkEmjKMY9sAZ99iebDPpLxzhhpVWLMSxSJIRlwnfnMLuF sd4h8K1oiODK0+keHeYnKkvDWPaJUMM0FCcbnOwuW4Wnh5nHiChno/z6868V3yJsT5EL MoXIgT5AjzSFP7fJ7uBs5mYt+z9kWEJgePu1w5fkzyN6fbZZoUIJiBmuRbNATvHGBr0r oYqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=s73rrbIqaGFAevBl97sdq7eBRxeTo50uEC9Ji1MJ3AI=; b=lS4hCb4twSTxOYfNHHOo2I2dWfVSHL2oPfzqraLnG/IAPeb7fb99WRpe4UmwItF8tP QKVUDidQBvxkaJXXwV+eljcCxAss3hV0GkJoYUc8pYvBvftiZNyyPK42KRi2sbNWsHZI F5FXsMlx0iC8+qSOeYxPh5Ug58ptoCXy4KXSw9OpphvlsbWzYwla6r5rQHiVj1fczL3V U5coo02oQvfz80mPsIchNtEsR7SM7a8S4j0MSazVz/shObotdsS+GAq+u9lMqFM9wm3f wihCrxKS97TO5zY8pL/1O3bDlTvsb0O9h0mqZSV/6mrejtcQDisxeULKMLw75BybyX4J q9eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BZzTAZOw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q32si14162325pgm.410.2018.12.03.15.52.04; Mon, 03 Dec 2018 15:52:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BZzTAZOw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726020AbeLCXuV (ORCPT + 99 others); Mon, 3 Dec 2018 18:50:21 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35356 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbeLCXuV (ORCPT ); Mon, 3 Dec 2018 18:50:21 -0500 Received: by mail-pl1-f194.google.com with SMTP id p8so7300293plo.2 for ; Mon, 03 Dec 2018 15:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=s73rrbIqaGFAevBl97sdq7eBRxeTo50uEC9Ji1MJ3AI=; b=BZzTAZOwijagSpqR2Ov38mgVq1VJf/q0Vv7qsZXJ+dvf//UAxWEK4DV4Ai18C2Xn/H invB9kwL7MK8rltZR4g6G6RA3SwM5lKlOHxY+lV/+YTw7tmlIwxJGlyXSv+4gN3HLlsN x5SNvEtRhQIvU3icI1sdGcuT/MAUzQrNonr+RHLMZjKpgxXAtJA4SMUgh2hv2JY1WEU0 uK/nOWjSQrQfsK9BUp7pZ9cbsx9JYnAKmbdekGc/ZSd8Bzo1hP1tLzj/W92GqbCW0/i9 3H9nQGBV3zFY0pHrT3e6PSN7bs7w9mKUbhNS2jNPnfE9Fkmk8RjAlP0sYv4v2GcdIkcg 0ChQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=s73rrbIqaGFAevBl97sdq7eBRxeTo50uEC9Ji1MJ3AI=; b=SAYrJeKSDZEmGhI+0o/ILl8Qfz57jQuznwlSAhByBX2d9NWQaUuWQVKet7ZAXTML9r raZvHhpP8KE7ASQljTj3Eyi3WQ77RILLdkosmYPoIF/O+ldJq8JxigsDUgPBi1gfMhZd Fd09Tc2S2eGxInv1L4B6Pr/ySwNCp92xYhmC8vHpVn0lO4mfSp1dHaydngi7F52Y5rbZ YqsmzotOeYRw7mIJKiH32UgLAW8yJlgo2Bq2sGb3HzBpIPuYJmX2Uj/i25A0dfmJcVtg Vii96aFkce+Viy6UqLsubMXd0TVglqEN/us1M9bTPLtOzcT/AYW8IkGk0EfV7/yQh4ML elNw== X-Gm-Message-State: AA+aEWZAgObSxu7oofGfXXzQLRIA6O1D/3EVnYAhFPGzb7DMLpGb8I3b Vlp4IfLHDA/I0rUI/GBjtPpHUg== X-Received: by 2002:a17:902:6b46:: with SMTP id g6mr17961735plt.21.1543881020481; Mon, 03 Dec 2018 15:50:20 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id n70sm20485960pfi.185.2018.12.03.15.50.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 15:50:19 -0800 (PST) Date: Mon, 3 Dec 2018 15:50:18 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Linus Torvalds , Andrea Arcangeli cc: ying.huang@intel.com, Michal Hocko , s.priebe@profihost.ag, mgorman@techsingularity.net, Linux List Kernel Mailing , alex.williamson@redhat.com, lkp@01.org, kirill@shutemov.name, Andrew Morton , zi.yan@cs.rutgers.edu, Vlastimil Babka Subject: [patch 0/2 for-4.20] mm, thp: fix remote access and allocation regressions Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes a 13.9% of remote memory access regression and 40% remote memory allocation regression on Haswell when the local node is fragmented for hugepage sized pages and memory is being faulted with either the thp defrag setting of "always" or has been madvised with MADV_HUGEPAGE. The usecase that initially identified this issue were binaries that mremap their .text segment to be backed by transparent hugepages on startup. They do mmap(), madvise(MADV_HUGEPAGE), memcpy(), and mremap(). This requires a full revert and partial revert of commits merged during the 4.20 rc cycle. The full revert, of ac5b2c18911f ("mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings"), was anticipated to fix large amounts of swap activity on the local zone when faulting hugepages by falling back to remote memory. This remote allocation causes the access regression and, if fragmented, the allocation regression. This patchset also fixes that issue by not attempting direct reclaim at all when compaction fails to free a hugepage. Note that if remote memory was also low or fragmented that ac5b2c18911f ("mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings") would only have compounded the problem it attempts to address by now thrashing all nodes instead of only the local node. The reverts for the stable trees will be different: just a straight revert of commit ac5b2c18911f ("mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings") is likely needed. Cross compiled for architectures with thp support and thp enabled: arc (with ISA_ARCV2), arm (with ARM_LPAE), arm64, i386, mips64, powerpc, s390, sparc, x86_64. Andrea, is this acceptable? --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 8 +++--- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 -- include/linux/gfp.h | 3 +- include/linux/mempolicy.h | 2 - mm/huge_memory.c | 41 +++++++++++-------------------- mm/mempolicy.c | 7 +++-- mm/page_alloc.c | 16 ++++++++++++ 7 files changed, 42 insertions(+), 38 deletions(-)