Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1836487ybh; Fri, 17 Jul 2020 02:28:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7eYlTjLRZcy3cSgwPtryLX4ds1Q0fXsHOMtmLssagOiR//rxI4xbcvah2bxqnJNPXJ/HQ X-Received: by 2002:a17:906:856:: with SMTP id f22mr7412671ejd.245.1594978139693; Fri, 17 Jul 2020 02:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594978139; cv=none; d=google.com; s=arc-20160816; b=SU3+29lDh5JRz5zYcc5FgYope1ckoJ+3nfLhBOdF34y5CTC5TljNoZYsBCqdEQmPWB uhvBabzoAOXqmmJ9X8Q9IX+qYQEH+CfEVBeLKaUfIJ11EgZUG3NJrG5JcA6fV1cifJKE UvpCNfz16Xq0vDuMdITl6yPebbHlNx0GMLHVzcHdknnnoq5C7v36ZKmoHBSzu4ZH+ybU 4oiYj1epq9iVz2ca9Cog5IhVBIHYCk8/06frS53ZcGV86ZW05KoNAOgvYuBJmC8VWZjK E8aY7i/wfWGj1QjHJepxQuWBf21dr5DlwAx9URQtD2N1DqVhm0fGSWihALbwgwMDCtgq C+lQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=awDCkloG136ngoAY6t6Tgi/O0WGV4S/6eBJN9T7WMEY=; b=q6aJwGFE/SrgtPPSAKZ8/VwJfeOsgT5gzAthbnYgn/2UG3ag3sQz0p7X6bRRmHmRxe 4Dlz5/9MQtLIpGl7qyRZkeWUDSSRPVqrColmtZQTvQqldckmR1VlFVatzol7t1kHcmtk 9BaRSi4mfFxd99jDGG/fkO/5n4bPrZHrxV5rfQwL251M1evRdgtIttocc9/mE40ayarB VfeOFSZThR5J29b8i2Xo/UcbsGpSoZNkXAywA5sfQiocnvuJ8I+Gc9NnY8UZrBoJs5ON RVhSf6Ia3gUtGvTW++ltMWjkikb7/GF7dCJq4PC1Ne+Jj2dmcm0wKYtCRKM6sRuT1vwR DYBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l0hUQI3X; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si4911680ejq.495.2020.07.17.02.28.37; Fri, 17 Jul 2020 02:28:59 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l0hUQI3X; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726316AbgGQJ22 (ORCPT + 99 others); Fri, 17 Jul 2020 05:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726113AbgGQJ21 (ORCPT ); Fri, 17 Jul 2020 05:28:27 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1838C061755 for ; Fri, 17 Jul 2020 02:28:27 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id m8so3962419qvk.7 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=jJsdquCsmDtbz7B8oFUj82RsmAMC3cdcdob39bUaRxscmt6uJAthagnPkheg59xYvi Y26WnC30eWQZ5x4hZHYh7w085rCsFWCnE5jm6+/1WBtptllyRjAv9OAe3LKG4CUDiM3J s3sD3aUr50uyKaQUYcPHOohS1rdlcRP2MdzX/gY0OuO5IMDiQ01UqZtK1KIsXlOW7Xoi E/0uL42+ZCV+lXbMNAXM5l7KawvBYEaA/m7Ute+RHWru14bOB5LBatH8SMCyMO0mbnT1 ydaCF00O3RKGHJvTHM6Gj9PK5RQk5SReAqcts37596dbTCFxiqcxoyxvVJMzuOoWW+5h PwHw== X-Gm-Message-State: AOAM530XMXMq3I1WZwHMtNSSnDSE42X7Obc5F6KTqdxu1vAc3WIeUpLq 9jmUXX5P+7nNP26qGoWcYFTTSjI1MjFkISr4N57EDOtA 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.