Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1890488ybh; Fri, 17 Jul 2020 04:09:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR5xHoAUbrrBhAM083xelD2K/8oUs5yB+2wUHfDHfK4GAvZu+tzy30iyYeBDddon8cXvi0 X-Received: by 2002:a17:906:a449:: with SMTP id cb9mr7809284ejb.115.1594984147512; Fri, 17 Jul 2020 04:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594984147; cv=none; d=google.com; s=arc-20160816; b=XNbZe+pX72bvNLS2O4jFJg6htD1pD/E4HtwQt5bLrK6hWEvCQoJ1tkZvmsALugmXtv l1neuT8x1/IkB1VdsFM/7Dbk9gYOHP6fCzR4svH2bQAbKtnlFesQIwm9zq1BKD56KfUA ys4OytBmawQ9mcFoK64i40R2RvoFLGo5zTuD7rDdbahnyG6A96ylhh8liD64/RaBdE/m OBzVRtjNiW+J+db05onKl/iQtRvQgwIB0ylFKyHD9s3InzHuN/HmjFExO10T69jwxpLo NdhlUj4/dPUSVQ5PQujbcXpdq01TY4Svoxpj3wJMXiMFKbEYGUjpCgmNHB5sZgnPGTQj VThA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=sW5ATIAUVqe473Xw/kpcZ/C6jQAJpg7NFPCXiZkdips=; b=LcKrBLpeeuBY1h3HvsLg7PUd1dLBiuV2yYHLt82Zm9cubNyPdRrBzFwicaRdg/njBF TVbAXQj3J58XEwLD5rn/sXMOeZGUdDmIUklLMT1w65Q2d+MV+EqAFT9LYWS7/gfSg4nK zo2TOq8yrZ0JT3Y5nDyXiaR4tXviY5AtqyQYM1XaVVomISdN/XGuN0mwMoDxdNH2Xw4a Iym0f5wUDMKllpbk7DH5BpEpSgj9IJG8vYFG/H+jVX2BxUIhQPt0n75kxF49cIrKKanQ QB++OxFsSMoj2ITsx+hNPWPgqcWOypc/gsntNpAlXuXjSCAAtpxjFZY6/BqRcOchm9Ir N8dA== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si5401344edj.296.2020.07.17.04.08.32; Fri, 17 Jul 2020 04:09:07 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbgGQLIL (ORCPT + 99 others); Fri, 17 Jul 2020 07:08:11 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35916 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgGQLIK (ORCPT ); Fri, 17 Jul 2020 07:08:10 -0400 Received: by mail-wm1-f66.google.com with SMTP id 17so16435263wmo.1 for ; Fri, 17 Jul 2020 04:08:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=sW5ATIAUVqe473Xw/kpcZ/C6jQAJpg7NFPCXiZkdips=; b=rVwileN4DCzsRHqat1EdQFS3EC1ne9glm64dkrG66Oh8gKGevlb4nB2HaU/a74cynl OM5pQsqJGAIvNcEviWODyR84bYbzaHo7XQvT3nmt3sxzd6SSMfKFtxQnn8LAHbMSlHZe ATCpZy/c6b04ZcsMbi9QtM03jMC4H3zwWNp3bgy60USpcV65OfiErXRU67RKTTf7TL1P 8AA3HAA+fa6j6VpN6bU0QGQPPVQwTVhJ0Q8+DvySgxdMWGLBU/5LUd2r0n3bveriMetf ie36i4HQZ2zyKgVygSH6W0G//Rtwn4uylZ8FFpF8wDOCNmXJeMTSc2gzXeB9Zvc62TZz jlEQ== X-Gm-Message-State: AOAM531pO6WvQAr73LY+BUAW/a22o3ixe1EZNx+Ac9qRd3rFxnWK3MaT LgPbi8pA5VupH4pAhP9umKA= X-Received: by 2002:a1c:4d11:: with SMTP id o17mr8569690wmh.134.1594984088723; Fri, 17 Jul 2020 04:08:08 -0700 (PDT) Received: from localhost (ip-37-188-169-187.eurotel.cz. [37.188.169.187]) by smtp.gmail.com with ESMTPSA id w14sm13981638wrt.55.2020.07.17.04.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 04:08:07 -0700 (PDT) Date: Fri, 17 Jul 2020 13:08:06 +0200 From: Michal Hocko To: Joonsoo Kim 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 Subject: Re: [PATCH 2/4] mm/gup: restrict CMA region by using allocation scope API Message-ID: <20200717110806.GI10655@dhcp22.suse.cz> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 17-07-20 18:28:16, Joonsoo Kim wrote: > 2020년 7월 17일 (금) 오후 5:26, Michal Hocko 님이 작성: > > > > On Fri 17-07-20 16:46:38, Joonsoo Kim wrote: > > > 2020년 7월 15일 (수) 오후 5:24, Michal Hocko 님이 작성: > > > > > > > > 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 also > > > > > searched by page allocator. For hugetlb, gfp_mask is redefined since > > > > > it has a regular allocation mask filter for migration target. > > > > > > > > > > Note that this can be considered as a fix for the commit 9a4e9f3b2d73 > > > > > ("mm: update get_user_pages_longterm to migrate pages allocated from > > > > > CMA region"). However, "Fixes" tag isn't added here since it is just > > > > > suboptimal but it doesn't cause any problem. > > > > > > > > But it is breaking the contract that the longterm pins never end up in 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 suboptimal > > > implementation to exclude the CMA area. This is why I don't add the "Fixes"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. Right you are! I have misread gfp_t gfp_mask = GFP_USER | __GFP_NOWARN and didn't realize that it doesn't include MOVABLE flag. Sorry about the noise! The issue is only formal coding style so Fixes tag could indeed cause more confusion than it would help. -- Michal Hocko SUSE Labs