Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp952438ybt; Tue, 7 Jul 2020 04:24:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4/ZGGPL+Nxl+IDhJb3KBGzHWgJ371lv/XL6w1YOqD0tROBH0MLWE0Zd/U7/EwqNbYR4ro X-Received: by 2002:aa7:dd05:: with SMTP id i5mr61792573edv.283.1594121072097; Tue, 07 Jul 2020 04:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594121072; cv=none; d=google.com; s=arc-20160816; b=bc91EiqsXp/JnvuSsJimyuQU+ziOEfMlwCyOjg6XUG/aQ+ADysmu+Gb6sVB7IU6blD jMtKPn9BzablUEl0A28KFNPmd+Pjv71PmE5JZfDm01yOywTLBHZpWt3QUZKOZBymd5GW C7hs1D7rzcN/GHlZOoQSAASn2Nm1lENnvDuX/9q2sFpokjBxpvtPE8oCrmGfm51hn256 y4k+wF/ecQiBafQlaGUu+ommO84lXkIqEP3YXnyFGuIKNAosAw5550iQ2tR5pUtlRlJg zw9Zq02Zk8wBfjdR2f37+LkaI9SKm9ZzYps3IgID24WJv9eSK1iKqowZ6ZAKsx3/ehi2 44/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=68tV5iCto5kZ9il/7YfBa1Dn0ZBGwun54F7jTNKFADA=; b=Vv5R2D88UGnSxzkI2LRCYMh+5IHOMFN/XR+qvQv45afyIVqfr/usbKpbh5lHQ1/bCP +RL3f41dIkaUJVtBYbadlKiDzarmu5GOEnrLFzkaIK3HUYbTg6rh3j07+x2bPiKZMsR9 B8ge+A8wcX5MnAekK+fuvejye2p+nJJJeUDko+O79H39dKUrEJAFQrv6DufMOr913Jyi 3deNiZA9kw9iJDwm9PTT7KzzqFEh4NXX94gM8KoSqBW9h7uYr3ZJ+2fGw7298khOlFQr VwtsnyOZXhwN6SUb7r8Vyxt3CwOD9pHCXPLWulavS62iSvWQwQLQXgQELrN4loJi25Tl iBMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si14081441ejt.753.2020.07.07.04.24.08; Tue, 07 Jul 2020 04:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728336AbgGGLWc (ORCPT + 99 others); Tue, 7 Jul 2020 07:22:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:34258 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbgGGLWc (ORCPT ); Tue, 7 Jul 2020 07:22:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DCDAFAD81; Tue, 7 Jul 2020 11:22:30 +0000 (UTC) Subject: Re: [PATCH v4 04/11] mm/hugetlb: make hugetlb migration callback CMA aware To: js1304@gmail.com, Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Michal Hocko , Joonsoo Kim References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> <1594107889-32228-5-git-send-email-iamjoonsoo.kim@lge.com> From: Vlastimil Babka Message-ID: Date: Tue, 7 Jul 2020 13:22:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <1594107889-32228-5-git-send-email-iamjoonsoo.kim@lge.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/7/20 9:44 AM, js1304@gmail.com wrote: > From: Joonsoo Kim > > new_non_cma_page() in gup.c which try to allocate migration target page > requires to allocate the new page that is not on the CMA area. > new_non_cma_page() implements it by removing __GFP_MOVABLE flag. This way > works well for THP page or normal page but not for hugetlb page. > > hugetlb page allocation process consists of two steps. First is dequeing > from the pool. Second is, if there is no available page on the queue, > allocating from the page allocator. > > new_non_cma_page() can control allocation from the page allocator by > specifying correct gfp flag. However, dequeing cannot be controlled until > now, so, new_non_cma_page() skips dequeing completely. It is a suboptimal > since new_non_cma_page() cannot utilize hugetlb pages on the queue so this > patch tries to fix this situation. > > This patch makes the deque function on hugetlb CMA aware and skip CMA > pages if newly added skip_cma argument is passed as true. Hmm, can't you instead change dequeue_huge_page_node_exact() to test the PF_ flag and avoid adding bool skip_cma everywhere? I think that's what Michal suggested [1] except he said "the code already does by memalloc_nocma_{save,restore} API". It needs extending a bit though, AFAICS. __gup_longterm_locked() indeed does the save/restore, but restore comes before check_and_migrate_cma_pages() and thus new_non_cma_page() is called, so an adjustment is needed there, but that's all? Hm the adjustment should be also done because save/restore is done around __get_user_pages_locked(), but check_and_migrate_cma_pages() also calls __get_user_pages_locked(), and that call not being between nocma save and restore is thus also a correctness issue? [1] https://lore.kernel.org/r/20200629075510.GA32461@dhcp22.suse.cz > Acked-by: Mike Kravetz > Signed-off-by: Joonsoo Kim > --- > include/linux/hugetlb.h | 6 ++---- > mm/gup.c | 3 ++- > mm/hugetlb.c | 46 ++++++++++++++++++++++++++++++---------------- > mm/mempolicy.c | 2 +- > mm/migrate.c | 2 +- > 5 files changed, 36 insertions(+), 23 deletions(-) >