Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1153123ybi; Fri, 31 May 2019 14:55:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUT4yVij+emv6ovLa3YqYT0Q+/3TSbkFeo1GC32ewK4Y/PGfZKLPNNSLn3Zsuyusv/9es0 X-Received: by 2002:a63:4c1c:: with SMTP id z28mr11750009pga.122.1559339710093; Fri, 31 May 2019 14:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559339710; cv=none; d=google.com; s=arc-20160816; b=Ba3LCsRrywMEguCKeYBTvAUwYCr+7RR3wgPNKNsva+nQNmVMChMED5V5+OF1ioAV49 uxXZfIjYV9BE6X/+PJnf4Kmms3KB7yA6OySCQ9G9eSM9cXVzKTnoXOiqw+Sce67R/JkH YpJwU6E+sjsGZYkRYQ5I6xgZ1mo65WyQP2mLVnRbb9hSosLYeNBnsIW2LkmGgoi+9lo/ trTzhZNW+SmfYtMQcsTGC+hWXkBJCPQnVdt4K9HAV3AmMgEmqHzJMD3sf0QOT0aB3x6O 5fCXqdb2JpLtVJpPYm4SSuFBVZ/b3MaLVC+AzpnwqhHusBcSBoxrfG1zItFiXnpvsWH2 nPEg== 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:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=vkQlzDYXQfdlyaR7cXRKh8gwxLwxcbwPkOEJ9vq2Omw=; b=EPsLScC4K4WFbN5o0mBnZdCfk4aAEKDMxJG72L0+3KjK6HIWkV2RpM4Idb1Wkh57+X HulFA8iUuH/mHwOeRpvaiQcqG0vhLMgjvEZva+qH24oHC2IRf6F2RgAA74lLtpP6imbS wZ8AoUZb/dPvMkTyMiL26k9cOXHBU0NrWaTSQl+PkaKQhvJYvFsA4rEFq4Di1W9/hMij g6LEgJC0k5kqStjw6Xbb/IE2S7Q+mXiOM73PTlFxFbrYfKYHyZqopBE3AJqdWlt4KB58 icOZAr6XQwpy0PHlxgNfm+YlMMmXj3sN/G2H8hJYad2mgQ81IrKTNH/N2vXXsljEC16x h1Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="bdjWp/ki"; 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 o4si7289528pgg.49.2019.05.31.14.54.54; Fri, 31 May 2019 14:55:10 -0700 (PDT) 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="bdjWp/ki"; 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 S1726678AbfEaVxj (ORCPT + 99 others); Fri, 31 May 2019 17:53:39 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39237 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbfEaVxj (ORCPT ); Fri, 31 May 2019 17:53:39 -0400 Received: by mail-pl1-f193.google.com with SMTP id g9so4513365plm.6 for ; Fri, 31 May 2019 14:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=vkQlzDYXQfdlyaR7cXRKh8gwxLwxcbwPkOEJ9vq2Omw=; b=bdjWp/kiI8K61vLYJBNVyXD1yeRzAm4c/wU9YQtJWhHmI8leAG9bCnI91R0z7T0tHX GCyr3CgTdhkf4ZV0AY4Sz3NmS/0hXLzi/1oZhKXNyuhgaySUzZBJ1VTJXPTJ18GzFJ30 10nxiGkYjq05vLmbERivCyrBl6cf6LOEvSRM4mgS89cXN3G+3T2kmb1HRnKqpBrWW3A8 GxmWxVsR5GJHVAjmPaZ5Lusg/iJ0NFkK7y8s9yEpN4RcPSUcx9mzJYe3eCdwDY8mPrPH OfnbL46FwfeAzooJcCsROwAT0aHyYJMi3mUNJGP+fFAC9RlPLEj9OKzIbm5ifj39NFyg Qrug== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=vkQlzDYXQfdlyaR7cXRKh8gwxLwxcbwPkOEJ9vq2Omw=; b=f5xMoZ4P7xqD467Ct10LYwraVATrgA/4UDXFMC6j0Hm5ZefFBRuguM2dq1feDBjrmK JYEqhe74Pj8qSSak4Mi7uXUZI8G1bCq5NuEju9OqhiSvFCBDWkP9IzrJS5fiRp48nNFP /PsqIXsUm3bmHf6MkKT0BjPMUHq99eCd9o2a5Jnt4oJwhKTE9vUaJ99OLu/RCLsYTTuX 6j9tCcIXs67VJjVRuce/nIyub0f577kTa0zG1s4O9okfkjjHcEhu4uB5yxIDFKdhCnHT zOd6Vv6MS5SneZ2gKV5GIhZEpNmH2NtSTnrBoBmte+z4VK2bnMkR8EyvJcpZgXuj0+sl Zp+Q== X-Gm-Message-State: APjAAAXEGmbpcpoZtfROBF8iF4jJPzm/5JF9WDIIbW+YnxKdwEMOKfFJ 8RCVxPZfrxV9ylEbUUcKmgZSqw== X-Received: by 2002:a17:902:2ba9:: with SMTP id l38mr5596385plb.300.1559339617730; Fri, 31 May 2019 14:53:37 -0700 (PDT) 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 e123sm6685235pgc.29.2019.05.31.14.53.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 May 2019 14:53:35 -0700 (PDT) Date: Fri, 31 May 2019 14:53:35 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Michal Hocko cc: Andrew Morton , Mel Gorman , Andrea Arcangeli , Vlastimil Babka , Zi Yan , Stefan Priebe - Profihost AG , "Kirill A. Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] Revert "mm, thp: restore node-local hugepage allocations" In-Reply-To: <20190531092236.GM6896@dhcp22.suse.cz> Message-ID: References: <20190503223146.2312-1-aarcange@redhat.com> <20190503223146.2312-3-aarcange@redhat.com> <20190520153621.GL18914@techsingularity.net> <20190523175737.2fb5b997df85b5d117092b5b@linux-foundation.org> <20190531092236.GM6896@dhcp22.suse.cz> 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 On Fri, 31 May 2019, Michal Hocko wrote: > > The problem which this patch addresses has apparently gone unreported for > > 4+ years since > > Can we finaly stop considering the time and focus on the what is the > most reasonable behavior in general case please? Conserving mistakes > based on an argument that we have them for many years is just not > productive. It is very well possible that workloads that suffer from > this simply run on older distribution kernels which are moving towards > newer kernels very slowly. > That's fine, but we also must be mindful of users who have used MADV_HUGEPAGE over the past four years based on its hard-coded behavior that would now regress as a result. > > commit 077fcf116c8c2bd7ee9487b645aa3b50368db7e1 > > Author: Aneesh Kumar K.V > > Date: Wed Feb 11 15:27:12 2015 -0800 > > > > mm/thp: allocate transparent hugepages on local node > > Let me quote the commit message to the full lenght > " > This make sure that we try to allocate hugepages from local node if > allowed by mempolicy. If we can't, we fallback to small page allocation > based on mempolicy. This is based on the observation that allocating > pages on local node is more beneficial than allocating hugepages on remote > node. > > With this patch applied we may find transparent huge page allocation > failures if the current node doesn't have enough freee hugepages. Before > this patch such failures result in us retrying the allocation on other > nodes in the numa node mask. > " > > I do not see any single numbers backing those claims or any mention of a > workload that would benefit from the change. Besides that, we have seen > that THP on a remote (but close) node might be performing better per > Andrea's numbers. So those claims do not apply in general. > I confirm that on every platform I have tested that the access latency to local pages of the native page size has been less than hugepages on any remote node. I think it's generally accepted that NUMA-ness is more important than huge-ness in terms of access latency and this is not the reason why the revert is being proposed. Certainly if the argument is to be made that the default behavior should be what is in the best interest of Linux users in totality, preferring remote hugepages over local pages of the native page size would not be anywhere close. I agree with Aneesh's commit message 100%. > > My goal is to reach a solution that does not cause anybody to incur > > performance penalties as a result of it. > > That is certainly appreciated and I can offer my help there as well. But > I believe we should start with a code base that cannot generate a > swapping storm by a trivial code as demonstrated by Mel. A general idea > on how to approve the situation has been already outlined for a default > case and a new memory policy has been mentioned as well but we need > something to start with and neither of the two is compatible with the > __GFP_THISNODE behavior. > Thus far, I haven't seen anybody engage in discussion on how to address the issue other than proposed reverts that readily acknowledge they cause other users to regress. If all nodes are fragmented, the swap storms that are currently reported for the local node would be made worse by the revert -- if remote hugepages cannot be faulted quickly then it's only compounded the problem. The hugepage aware mempolicy idea is one way that could describe what should be done for these allocations, we could also perhaps consider heuristics that consider the memory pressure of the local node: just as I've never seen a platform where remote hugepages have better access latency than local pages, I've never seen a platform where remote hugepages aren't a win over remote pages. This, however, is more delicate on 4 socket and 8 socket platforms but I think a general rule that a hugepage is better, if readily allocatable, than a page on the same node. (I've seen cross socket latency for hugepages match the latency for pages, so not always a win: better to leave the hugepage available remotely for something running on that node.) If the local node has a workingset that reaches its capacity, then it makes sense to fault a remote hugepage instead because otherwise we are thrashing the local node. That's not a compaction problem, though, it's a reclaim problem. If compaction fails and it's because we can't allocate target pages, it's under memory pressure and it's uncertain if reclaim will help: it may fail after expensive swap, the reclaimed pages could be grabbed by somebody else and we loop, or the compaction freeing scanner can't find it. Worst case is we thrash the local node in a swap storm. So the argument I've made when the removal of __GFP_THISNODE was first proposed is that local hugepage allocation should be the preference including direct compaction for users of MADV_HUGEPAGE (or thp enabled=always) but reclaim should never be done locally. I'd very much like to engage with anybody who would be willing to discuss fixes that work for everybody rather than only propose reverts and leave others to deal with new performance regressions.