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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 1FA9EC433E0 for ; Thu, 9 Jul 2020 07:03:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D30172065D for ; Thu, 9 Jul 2020 07:03:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V5sjXUDz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D30172065D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 51BFD6B0005; Thu, 9 Jul 2020 03:03:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CD2E6B0007; Thu, 9 Jul 2020 03:03:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BA5F6B0010; Thu, 9 Jul 2020 03:03:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 2367A6B0005 for ; Thu, 9 Jul 2020 03:03:40 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C0EAB180AD82F for ; Thu, 9 Jul 2020 07:03:39 +0000 (UTC) X-FDA: 77017646958.17.gate92_610c78526ec3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id CE2D9180D01B8 for ; Thu, 9 Jul 2020 07:03:29 +0000 (UTC) X-HE-Tag: gate92_610c78526ec3 X-Filterd-Recvd-Size: 6538 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Jul 2020 07:03:29 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id ed14so527410qvb.2 for ; Thu, 09 Jul 2020 00:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YrXb+PwDrzRj61WwzuMsF1SQ3qopodp/CgTQXPhCgl8=; b=V5sjXUDzQudR96ZAfOfACopDQJ9o/MmPoWTqGfULqp/vTddHWzEIZ1UIDkcu7IJ7VM mQOuzlm1NdLOSM6JCtegh0GVdCdLHA3wFuAnz/y+lp2jbtjaSIQ6mwHH8fvYsMwsSWge k2tJ6CRYjrGnffV9DUqfYnhPMUR3SXUfe1rqAI6WypoIX8AD5yCAdv0q5TLKMTHPs80n WtrwJv5yJHopgEx99pbPbRAgK78oHNV4ki2vJCYgBah1CuUBV1EpghGYBGhaGOXYvFyv R4h5DRlr67+Mc7BDiJKe88WWK80wx7sbEALbLjQ5u5dYt1eglbbC727RwjpdKAK+IkYW ++3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YrXb+PwDrzRj61WwzuMsF1SQ3qopodp/CgTQXPhCgl8=; b=oym8z+pf1D6Ievu5Ln6oOBZAbU/tlguhZ93v03SKa8zb0owicMTcNBscbUTRSZz0f9 W6LTYezbpJnLW3sbzYfwG2J3pexC4GdUlBXDllBHMNfiBI3GTDcDFN898r8UXwvGV46T TkbEMz0MC7l4h3NwVtGXepe7Q7eXWsr0H0behE//u0CsFMbVv3Z5jtdPiO6g4YT6u3+w jc+EbSOEZ1l8J3viOk0V2wYXenVxVd3T5Slf2a2ttZu9D4D7htNJ39QzK5F3qGt4x4ab KICU2Y+LM4e3wyxez43PBAgoJShrZaqxi9GEYuD1lclyWpVMiVybKlt+zgz84zBCF0ZD zBEg== X-Gm-Message-State: AOAM532g93J4teIayQlHB1YrYXeIoXBciEXg1/VTpvz0gNK1J3QfXkUU RKyz4420zUJBeD7wCnQCi50pAhAF32jpT0OU7ew= X-Google-Smtp-Source: ABdhPJwnBP30L2pcgjXTXouFKiroyJmxdrQWyS+nPsnu928YAHeRkSL5ytc9qnPd6EF8LzPDkPxsKo3g9wyiowPIyXo= X-Received: by 2002:ad4:4732:: with SMTP id l18mr58589404qvz.208.1594278208659; Thu, 09 Jul 2020 00:03:28 -0700 (PDT) MIME-Version: 1.0 References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> <1594107889-32228-5-git-send-email-iamjoonsoo.kim@lge.com> <20200708071602.GB16543@js1304-desktop> <20200708074103.GD7271@dhcp22.suse.cz> <20200709064340.GB19160@dhcp22.suse.cz> In-Reply-To: <20200709064340.GB19160@dhcp22.suse.cz> From: Joonsoo Kim Date: Thu, 9 Jul 2020 16:03:27 +0900 Message-ID: Subject: Re: [PATCH v4 04/11] mm/hugetlb: make hugetlb migration callback CMA aware To: Michal Hocko Cc: Vlastimil Babka , Andrew Morton , Linux Memory Management List , LKML , kernel-team@lge.com, Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: CE2D9180D01B8 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: 2020=EB=85=84 7=EC=9B=94 9=EC=9D=BC (=EB=AA=A9) =EC=98=A4=ED=9B=84 3:43, Mi= chal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Wed 08-07-20 09:41:06, Michal Hocko wrote: > > On Wed 08-07-20 16:16:02, Joonsoo Kim wrote: > > > On Tue, Jul 07, 2020 at 01:22:31PM +0200, Vlastimil Babka wrote: > > > > 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 targe= t 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 q= ueue, > > > > > 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 control= led until > > > > > now, so, new_non_cma_page() skips dequeing completely. It is a s= uboptimal > > > > > since new_non_cma_page() cannot utilize hugetlb pages on the queu= e 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 tes= t the PF_ > > > > flag and avoid adding bool skip_cma everywhere? > > > > > > Okay! Please check following patch. > > > > > > > > I think that's what Michal suggested [1] except he said "the code a= lready does > > > > by memalloc_nocma_{save,restore} API". It needs extending a bit tho= ugh, AFAICS. > > > > __gup_longterm_locked() indeed does the save/restore, but restore c= omes 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 c= alls > > > > __get_user_pages_locked(), and that call not being between nocma sa= ve and > > > > restore is thus also a correctness issue? > > > > > > Simply, I call memalloc_nocma_{save,restore} in new_non_cma_page(). I= t > > > would not cause any problem. > > > > I believe a proper fix is the following. The scope is really defined fo= r > > FOLL_LONGTERM pins and pushing it inside check_and_migrate_cma_pages > > will solve the problem as well but it imho makes more sense to do it in > > the caller the same way we do for any others. > > > > Fixes: 9a4e9f3b2d73 ("mm: update get_user_pages_longterm to migrate pag= es allocated from CMA region") > > > > I am not sure this is worth backporting to stable yet. > > Should I post it as a separate patch do you plan to include this into you= r next version? It's better to include it on my next version since this patch would cause a conflict with the next tree that includes my v3 of this patchset. Thanks.