From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5287EC48286 for ; Fri, 2 Feb 2024 01:35:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2BAA6B0074; Thu, 1 Feb 2024 20:35:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADB436B0078; Thu, 1 Feb 2024 20:35:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CA486B007B; Thu, 1 Feb 2024 20:35:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8C5FC6B0074 for ; Thu, 1 Feb 2024 20:35:46 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5D08440C6A for ; Fri, 2 Feb 2024 01:35:46 +0000 (UTC) X-FDA: 81745147092.06.FB94C8C Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf15.hostedemail.com (Postfix) with ESMTP id 6AB1FA0008 for ; Fri, 2 Feb 2024 01:35:43 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=ur2X3BqM; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf15.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706837744; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=K/ZwJLmczXG17maGF/I5cgBZNRxSQmwfPe60uv2e8mY=; b=c7fukjSMHIrauPFbxQF+ga/uinyfmrfx1LCQuwFSSU7VRSRcn6FbJyNeiO7KFSXK4jCxzz +2dA+p/wWBym+rlNZ3IW/yQwymuyJnIoJC4KKghdZj3lNL3/y1bNClFoH/W1CskiF6sXg6 Psh7P+edBOAh7J76kPpVRmukhDMuGE8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=ur2X3BqM; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf15.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706837744; a=rsa-sha256; cv=none; b=wdpHnK+OFNdBVJMPWUWrawISRHlteWtgnJKO/r2BwAamG/2QaK1H1wOQY4+wNrqH1SbczG p19jK75hsTLarxGlrI4A0y7rCF8cQeLgoXwYfhQHg1MquU/9ic5FcSH6lAB/wlDtcZzTSl ueanqMRGQ46H9kOsA6MjS8PfsSRXki4= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1706837740; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=K/ZwJLmczXG17maGF/I5cgBZNRxSQmwfPe60uv2e8mY=; b=ur2X3BqM89C+m/pVM0arfF46SljowHYDNN7TTNt/aKlZUSEUlTEVMyUq7zQeG7pvCr8NLvsLVOaB++PVTjVQeP2tcI/SmQHXWuOup/mXL3FOZepCZysIFYSCDCGrXqWFZtVdHbDC4jm9svtvslBXpH1qh0k9C5ttdtkPSe4pyKs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0W.v4q.H_1706837738; Received: from 30.97.56.44(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W.v4q.H_1706837738) by smtp.aliyun-inc.com; Fri, 02 Feb 2024 09:35:39 +0800 Message-ID: <3f31cd89-f349-4f9e-bc29-35f29f489633@linux.alibaba.com> Date: Fri, 2 Feb 2024 09:35:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] mm: hugetlb: remove __GFP_THISNODE flag when dissolving the old hugetlb To: Michal Hocko Cc: akpm@linux-foundation.org, muchun.song@linux.dev, osalvador@suse.de, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <6f26ce22d2fcd523418a085f2c588fe0776d46e7.1706794035.git.baolin.wang@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 6AB1FA0008 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fwj4j7yg6xgj6depz5adm5x9b5gaseis X-HE-Tag: 1706837743-878006 X-HE-Meta: U2FsdGVkX1/S4XQcMyT02kW5s/FVuUDVXrajeoj49koS65R/fzrxLCVXKOE1d34tgfm8x8BaInHneNjOr0Uu9bmuJDkOJ6F72NR2KeYIAsXzMRRp403Y9KaWI/ln8kdoE12U3ZRn/d3deLofUZuMrDVsGEj2Aa04XGgVCsz25lGMnB8gDHvbA8GgvP7YnVtbw0iUMzJxFtxwPtXCfNX3wAKdt1kOvdN/zpneTcpuuCue+eXcGrQ5e8mH88yOLXakJKih6WGqZv/ObG2FDDqP8u9OY1uvruTOmFYf2ylD+F36Ed9twu4WhqOpgW4g1DCKenYoHq7kcczr7UY17AgSbJHiBKIwwlamsS1OR11Lu3Z0kxstd2jaZXeUlj9JHr7ItScPrR77zj0TX35JWVGdltVl4IR38SL42wfVlheI9hoN3WFGqgIcxloeXcijccTeJYHNI+yrwmcydzFVNDWun51JmNQM9tlRhmbSqpStQxiMNfcshwbD++wP0ZDA//7KnYfwqR812jIjxWddKQmqqoCB700egbV9wI7drLNXtIA12AWWoYY+9MQgWStuWQDHcUADqmzUm8H3Mt0ECJSMAtJTgzOmHiAQ9HAhfYicuA8iN8zodybDLlZyZqVpPq8meKmKnu1nU6hY38GfT+gINvGNldGPvQXGvQANlArLXSrWKHnqi89SL7UN/ywTxEi9EuG7pQxgWedpE/4Xcp9EUCgzupdeSpAhbEVM1haYL93sy/1Vt7nvJZhrmourofPzstEzaZLb3mSyBsITWI7OVcxQk/rOJHJ4AmD/KWkO3fJw618t/3Sp4o2U1bAFwSBmh2qKRwpz5Z6Kyl8fkLOImvEnK55iRIcNFng3ODERTax8yzx9uCGA3gibNdHWcTH+vTGVvEaSyJy91IvqO4Jbr6o1t4pgLmqNXnkfxBU6LsxCbeGGBcb+7y0LX1BVwlqqg7ZrSsGTxxo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2/1/2024 11:27 PM, Michal Hocko wrote: > On Thu 01-02-24 21:31:13, Baolin Wang wrote: >> Since commit 369fa227c219 ("mm: make alloc_contig_range handle free >> hugetlb pages"), the alloc_contig_range() can handle free hugetlb pages >> by allocating a new fresh hugepage, and replacing the old one in the >> free hugepage pool. >> >> However, our customers can still see the failure of alloc_contig_range() >> when seeing a free hugetlb page. The reason is that, there are few memory >> on the old hugetlb page's node, and it can not allocate a fresh hugetlb >> page on the old hugetlb page's node in isolate_or_dissolve_huge_page() with >> setting __GFP_THISNODE flag. This makes sense to some degree. >> >> Later, the commit ae37c7ff79f1 (" mm: make alloc_contig_range handle >> in-use hugetlb pages") handles the in-use hugetlb pages by isolating it >> and doing migration in __alloc_contig_migrate_range(), but it can allow >> fallbacking to other numa node when allocating a new hugetlb in >> alloc_migration_target(). >> >> This introduces inconsistency to handling free and in-use hugetlb. >> Considering the CMA allocation and memory hotplug relying on the >> alloc_contig_range() are important in some scenarios, as well as keeping >> the consistent hugetlb handling, we should remove the __GFP_THISNODE flag >> in isolate_or_dissolve_huge_page() to allow fallbacking to other numa node, >> which can solve the failure of alloc_contig_range() in our case. > > I do agree that the inconsistency is not really good but I am not sure > dropping __GFP_THISNODE is the right way forward. Breaking pre-allocated > per-node pools might result in unexpected failures when node bound > workloads doesn't get what is asssumed available. Keep in mind that our > user APIs allow to pre-allocate per-node pools separately. Yes, I agree, that is also what I concered. But sometimes users don't care about the distribution of per-node hugetlb, instead they are more concerned about the success of cma allocation or memory hotplug. > The in-use hugetlb is a very similar case. While having a temporarily > misplaced page doesn't really look terrible once that hugetlb page is > released back into the pool we are back to the case above. Either we > make sure that the node affinity is restored later on or it shouldn't be > migrated to a different node at all. Agree. So how about below changing? (1) disallow fallbacking to other nodes when handing in-use hugetlb, which can ensure consistent behavior in handling hugetlb. (2) introduce a new sysctl (may be named as "hugetlb_allow_fallback_nodes") for users to control to allow fallbacking, that can solve the CMA or memory hotplug failures that users are more concerned about.