On Wed 29-05-19 14:24:33, David Rientjes wrote: > On Thu, 23 May 2019, Andrew Morton wrote: > > > > We are going in circles, *yes* there is a problem for potential swap > > > storms today because of the poor interaction between memory compaction and > > > directed reclaim but this is a result of a poor API that does not allow > > > userspace to specify that its workload really will span multiple sockets > > > so faulting remotely is the best course of action. The fix is not to > > > cause regressions for others who have implemented a userspace stack that > > > is based on the past 3+ years of long standing behavior or for specialized > > > workloads where it is known that it spans multiple sockets so we want some > > > kind of different behavior. We need to provide a clear and stable API to > > > define these terms for the page allocator that is independent of any > > > global setting of thp enabled, defrag, zone_reclaim_mode, etc. It's > > > workload dependent. > > > > um, who is going to do this work? > > > > Implementing a new API doesn't help existing userspace which is hurting > > from the problem which this patch addresses. > > > > 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. > commit 077fcf116c8c2bd7ee9487b645aa3b50368db7e1 > Author: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx> > 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. This is a general problem when making decisions on heuristics which are not a clear cut. AFAICS there have been pretty good argments given that _real_ workloads suffer from this change while a demonstration of a _real_ workload that is benefiting is still missing. > 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. [...] > The easiest solution would be to define the MADV_HUGEPAGE behavior > explicitly in sysfs: local or remote. Defaut to local as the behavior > from the past four years and allow users to specify remote if their > workloads will span multiple sockets. This is somewhat coarse but no more > than the thp defrag setting in sysfs today that defines defrag behavior > for everybody on the system. This just makes the THP tunning even muddier. Really, can we start with a code that doesn't blow up trivially and build on top? In other words start with a less specialized usecase being covered and help more specialized usecases to get what they need. -- Michal Hocko SUSE Labs