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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D932C433DF for ; Tue, 7 Jul 2020 11:22:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE7EA206CD for ; Tue, 7 Jul 2020 11:22:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE7EA206CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8322B6B0081; Tue, 7 Jul 2020 07:22:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BB7F6B0087; Tue, 7 Jul 2020 07:22:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AAA56B0089; Tue, 7 Jul 2020 07:22:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id 4FFC76B0081 for ; Tue, 7 Jul 2020 07:22:33 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D74F6181AC9CB for ; Tue, 7 Jul 2020 11:22:32 +0000 (UTC) X-FDA: 77011041744.17.board02_101399b26eb4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id A750C180D018B for ; Tue, 7 Jul 2020 11:22:32 +0000 (UTC) X-HE-Tag: board02_101399b26eb4 X-Filterd-Recvd-Size: 3685 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 11:22:32 +0000 (UTC) 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 X-Rspamd-Queue-Id: A750C180D018B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: 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(-) >