Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp151198ybi; Thu, 13 Jun 2019 13:18:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGPBRI/vbtZRtYCKo956Ws4cRNBC9Rj/QdwqfYYnAxkdsfpGE4ny+abtSGiacRlRorWDqY X-Received: by 2002:a65:568d:: with SMTP id v13mr9415669pgs.144.1560457095604; Thu, 13 Jun 2019 13:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560457095; cv=none; d=google.com; s=arc-20160816; b=0PWv3towFyjFefKckp/S5GXbw1OupQgT4CHDdMjEeIuJGM6uqBOMTNjOV1nN3ednw6 KHeSaU6jT/e87ZHCJi7WVQQl65yBpzxgk1UaA2Si6He2KrZcDgCpHzilRuaIrOB0SOKx 7NHXFexE8hA8xi8mxk0WN5cdcyXj1K6vWUr0sU6YizenHZDAi6bbffcWVlJ4o8ylKm3j 4iUSpxGYsT7dibjhaVmGmDy/aw4AZMZiAsdIDObRIJ37nQz7ymjz0mMm8UfEcznuMwSe UMJZwRwJLf5eGCHFNrEM6LAreXtc1TEy3ygPq0feA7NwGi53wzXh/p94mxmlZAM1JE9S 1+Zw== 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=spF/72Oj0CgnTQoBgUPZDCot9zEM78k4CGq0SIEdWm0=; b=j7plzwjYgH4/aT2uAiBEkPur5XQx/nOpzW+NWZ7zAxNSIY1xDI5s0h+xe0QXQPyKCi chA18BTUx0VGcMUKvp1H+1C7DjeaZtOcJ2gl7BtK2fQ5MnyjktDKN02QzfhyNGK++8D+ Bhp5xUcvRc1pTsSUTiCiQ8+5kpatdCJpJHzWz+jdl8Tk57nggh2mc2dURovsfo0s2C5z LcxP4kZJ715SOGjw0ZSib0qPSCkYsHJOWO6LPBObqDLyP4KDPMsUDrNmx2Ly1bH/Ko4g r6mwj5Nnmo5Wxu/tZ+GQz3LpxSqUaltWwFRJMi6adhrZf7m3VrwZ52PIE0LCij2zQXry ByXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YLS2bNye; 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 f1si398779pld.78.2019.06.13.13.18.00; Thu, 13 Jun 2019 13:18:15 -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=YLS2bNye; 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 S1728641AbfFMURx (ORCPT + 99 others); Thu, 13 Jun 2019 16:17:53 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44647 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbfFMURw (ORCPT ); Thu, 13 Jun 2019 16:17:52 -0400 Received: by mail-pl1-f194.google.com with SMTP id t7so5983604plr.11 for ; Thu, 13 Jun 2019 13:17:52 -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=spF/72Oj0CgnTQoBgUPZDCot9zEM78k4CGq0SIEdWm0=; b=YLS2bNyeSL2KqBuL4vme/L2RzTwIodYg0cEGB/qrcLWbyYbPp6JNPPYb9eCN5WP09y ++v0/uuo8W94dIgJd9o6qoMxj9zazmylsRaMbQxcPyY7aGPZFFLyLKUh4dfTQhqkwBhA 2yqlwCGqvNpI+5SWRmQuQ1EyhyzuZvwxRJJf46m3XC8DziJOYnVouoYUqi8iw5+mFuFd 2tKyIoePhxNq/kqRbEeFfmSvizdDkjiqEYbuL8RzNmGVi32jjbDj96A9WBdf6Wd1WtbA n8f+HpJskZtd2cNV5s/hWUr+XWxm102xuuY5lBym80PXFFZtNWsn29+bohAarDRwfP25 QJaQ== 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=spF/72Oj0CgnTQoBgUPZDCot9zEM78k4CGq0SIEdWm0=; b=AqCqff/NjU21wO7xrekpB4O4Yh6z3/hfYhNeX6Lavmp4X+ovHI8HEfX/DeocdFViHt Qd1WYKILieBB6aGVbiO6fhY9bc5SFmlbdltS3XBVv5rfZj4L9eIxcPsmRBGczvzR1Seq +BaenhcViGEpAl9GnQ2q6VS/wKxE9zJvugunZrGCu5iFBJGJ8swYVDLAphqloKS0S0vj 3PsGVj1Ihs9aKSHxD9qiZDBFG01oya3ZEXO8IJW6If3jOHWO2nKUNvsNdIjaGWqB9YxX quF89RpN0uz/hFmMiTq+7qJVz+lMv7B5KBnJwTf7PaJ63gzYf8tpJLCiQZxmfhfG67ec fFRw== X-Gm-Message-State: APjAAAW3LNCP88H8iWo4fuz4s2xHkdLqwWgJIsLs79/u7Ah+XC5qFTA6 6MNptzyGaRHfRUv7TgA0IGDJRA== X-Received: by 2002:a17:902:2a69:: with SMTP id i96mr80652449plb.108.1560457071307; Thu, 13 Jun 2019 13:17:51 -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 n7sm546613pff.59.2019.06.13.13.17.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 13:17:49 -0700 (PDT) Date: Thu, 13 Jun 2019 13:17:49 -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: <20190607083255.GA18435@dhcp22.suse.cz> Message-ID: References: <20190503223146.2312-3-aarcange@redhat.com> <20190520153621.GL18914@techsingularity.net> <20190523175737.2fb5b997df85b5d117092b5b@linux-foundation.org> <20190531092236.GM6896@dhcp22.suse.cz> <20190605093257.GC15685@dhcp22.suse.cz> <20190607083255.GA18435@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, 7 Jun 2019, Michal Hocko wrote: > > So my proposed change would be: > > - give the page allocator a consistent indicator that compaction failed > > because we are low on memory (make COMPACT_SKIPPED really mean this), > > - if we get this in the page allocator and we are allocating thp, fail, > > reclaim is unlikely to help here and is much more likely to be > > disruptive > > - we could retry compaction if we haven't scanned all memory and > > were contended, > > - if the hugepage allocation fails, have thp check watermarks for order-0 > > pages without any padding, > > - if watermarks succeed, fail the thp allocation: we can't allocate > > because of fragmentation and it's better to return node local memory, > > Doesn't this lead to the same THP low success rate we have seen with one > of the previous patches though? > From my recollection, the only other patch that was tested involved __GFP_NORETRY and avoiding reclaim entirely for thp allocations when checking for high-order allocations. This in the page allocator: /* * Checks for costly allocations with __GFP_NORETRY, which * includes THP page fault allocations */ if (costly_order && (gfp_mask & __GFP_NORETRY)) { ... if (compact_result == COMPACT_DEFERRED) goto nopage; Yet there is no handling for COMPACT_SKIPPED (or what my plan above defines COMPACT_SKIPPED to be). I don't think anything was tried that tests why compaction failed, i.e. was it because the two scanners met, because hugepage-order memory was found available, because the zone lock was contended or we hit need_resched(), we're failing even order-0 watermarks, etc. I don't think the above plan has been tried, if someone has tried it, please let me know. I haven't seen any objection to disabling reclaim entirely when order-0 watermarks are failing in compaction. We simply can't guarantee that it is useful work with the current implementation of compaction. There are several reasons that I've enumerated why compaction can still fail even after successful reclaim. The point is that removing __GFP_THISNODE is not a fix for this if the remote memory is fragmented as well: it assumes that hugepages are available remotely when they aren't available locally otherwise we seem swap storms both locally and remotely. Relying on that is not in the best interest of any user of transparent hugepages. > Let me remind you of the previous semantic I was proposing > http://lkml.kernel.org/r/20181206091405.GD1286@dhcp22.suse.cz and that > didn't get shot down. Linus had some follow up ideas on how exactly > the fallback order should look like and that is fine. We should just > measure differences between local node cheep base page vs. remote THP on > _real_ workloads. Any microbenchmark which just measures a latency is > inherently misleading. > I think both seek to add the possibility of allocating hugepages remotely in certain circumstances and that can be influenced by MADV_HUGEPAGE. I don't think we need to try hugepage specific mempolicies unless it is shown to be absolutely necessary although a usecase for this could be made separate to this discussion. There's a benefit to faulting remote hugepages over remote pages for everybody involved. My argument is that we can determine the need for that based on failed order-0 watermark checks in compaction: if the node would require reclaim to even fault a page, it is likely better over the long term to fault a remote hugepage. I think this can be made to work and is not even difficult to do. If anybody has any objection please let me know.