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=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 70116C433E1 for ; Fri, 17 Jul 2020 09:28:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 254D22063A for ; Fri, 17 Jul 2020 09:28:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l0hUQI3X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 254D22063A 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 B11B08D002B; Fri, 17 Jul 2020 05:28:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A99F08D0028; Fri, 17 Jul 2020 05:28:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9623F8D002B; Fri, 17 Jul 2020 05:28:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id 7A3598D0028 for ; Fri, 17 Jul 2020 05:28:43 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E7F091F050 for ; Fri, 17 Jul 2020 09:28:42 +0000 (UTC) X-FDA: 77047042884.17.act18_3f0144726f09 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 2DBAF18037D3E for ; Fri, 17 Jul 2020 09:28:28 +0000 (UTC) X-HE-Tag: act18_3f0144726f09 X-Filterd-Recvd-Size: 5702 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Jul 2020 09:28:27 +0000 (UTC) Received: by mail-qv1-f66.google.com with SMTP id e3so3948228qvo.10 for ; Fri, 17 Jul 2020 02:28:27 -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=awDCkloG136ngoAY6t6Tgi/O0WGV4S/6eBJN9T7WMEY=; b=l0hUQI3XV0gslNHGSq5AKN6IYRqZfhlv9Nm03N05QQ+9CagB9bvYUo6+GUdgIeKWkf C7qCHNY6iM+yqoIBhtBbvZzbavtMqBtD6rS0j1c1Kk1yvT1ntf2nYTTTIiCCve0lWZYl QaZy/pAvSUTHyT/5AYCUgzw3wY9Th+EtEoWdJb07K9nnWHLLjJPnBPNR+GZzlpvI97/U toPO0env+PKcWHWxDimClWn/PzwqyBuB6mRtz0U2nkQqFExkSrxGRTooBRjRQnNUbTwp b+7INOcRYwdRyt3SRXi4MW82W4CTr7dgjekTASZ4LRliHiQkwkl9dtBXhnMBytzM50AF kSPg== 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=awDCkloG136ngoAY6t6Tgi/O0WGV4S/6eBJN9T7WMEY=; b=WGE3LwV2sR2s/NghvXksNTQleRAyV+Yw0Fo1Q3b4s0zWunOXwJWIAN6UiIpYQUA5f/ lYza+8SSqNwja04kqz1kgknknu7XvoJzg9bw56bA9vCL1W71AkHDUUj2TsGyjyI36foN kUCpke53rscO7QImS+Qzis2SvuS7SjfdyND/RPlWNUPvLFQ8dDD4XW4EoVitH6J0qp7N em8wR3iuzL3plinhaHCpimiCocLUWfV4Vh2OPuoI0SFgWr9AnToACiCWqrlPGktDtJmV BiEhDVP2pq56CKBi0A7KWl1S2t+crsFbFjK7tWANS8/8pSu6656vJVNdfQvnncVgU45P 57Vw== X-Gm-Message-State: AOAM533dy93MlEuxv6dllNFYX8WvbmKrtgytzv4hL+zyMY45gDCb8hUw 3LKXTjkG2ZwofcsrW0pnoCnnm511DrzTNlTODo8= X-Google-Smtp-Source: ABdhPJzW1Wi2+rlgq8/ZJIdhcEGp++KysgPh+vgxSR17+0KfgljD8vSzD3618McEr63Wkpqk5XipvRvSqPLfQHNMyrI= X-Received: by 2002:a0c:a306:: with SMTP id u6mr8198298qvu.88.1594978107071; Fri, 17 Jul 2020 02:28:27 -0700 (PDT) MIME-Version: 1.0 References: <1594789529-6206-1-git-send-email-iamjoonsoo.kim@lge.com> <1594789529-6206-2-git-send-email-iamjoonsoo.kim@lge.com> <20200715082401.GC5451@dhcp22.suse.cz> <20200717082643.GC10655@dhcp22.suse.cz> In-Reply-To: <20200717082643.GC10655@dhcp22.suse.cz> From: Joonsoo Kim Date: Fri, 17 Jul 2020 18:28:16 +0900 Message-ID: Subject: Re: [PATCH 2/4] mm/gup: restrict CMA region by using allocation scope API To: Michal Hocko Cc: Andrew Morton , Linux Memory Management List , LKML , kernel-team@lge.com, Vlastimil Babka , Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , "Aneesh Kumar K . V" , Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 2DBAF18037D3E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 17=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 5:26, M= ichal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Fri 17-07-20 16:46:38, Joonsoo Kim wrote: > > 2020=EB=85=84 7=EC=9B=94 15=EC=9D=BC (=EC=88=98) =EC=98=A4=ED=9B=84 5:2= 4, Michal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > > > > > On Wed 15-07-20 14:05:27, Joonsoo Kim wrote: > > > > From: Joonsoo Kim > > > > > > > > We have well defined scope API to exclude CMA region. > > > > Use it rather than manipulating gfp_mask manually. With this change= , > > > > we can now use __GFP_MOVABLE for gfp_mask and the ZONE_MOVABLE is a= lso > > > > searched by page allocator. For hugetlb, gfp_mask is redefined sinc= e > > > > it has a regular allocation mask filter for migration target. > > > > > > > > Note that this can be considered as a fix for the commit 9a4e9f3b2d= 73 > > > > ("mm: update get_user_pages_longterm to migrate pages allocated fro= m > > > > CMA region"). However, "Fixes" tag isn't added here since it is jus= t > > > > suboptimal but it doesn't cause any problem. > > > > > > But it is breaking the contract that the longterm pins never end up i= n a > > > cma managed memory. So I think Fixes tag is really due. I am not sure > > > about stable backport. If the patch was the trivial move of > > > > Previous implementation is correct since longterm pins never end up in = a CMA > > managed memory with that implementation. It's just a different and subo= ptimal > > implementation to exclude the CMA area. This is why I don't add the "Fi= xes"A > > tag on the patch. > > But the current implementation calls memalloc_nocma_restore too early so > __gu_longterm_locked will migrate pages possibly to CMA ranges as there > is no GFP_MOVABLE restriction in place. Or am I missing something? IIUC, calling memalloc_nocma_restore() too early doesn't cause the actual problem. Final check is done by check_and_migrate_cma_pages() which is outside of scope API. If we find a CMA page in between the gup range here, the page is migrated to the migration target page and this target page is allocated by new_non_cma_page(). new_non_cma_page() try to allocate the page without __GFP_MOVABLE so returned page will not be CMA area memory. Therefore, even if memalloc_nocma_restore() is called early, there is no actual problem. Thanks.