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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1567BC433F5 for ; Mon, 2 May 2022 18:23:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B3B16B0072; Mon, 2 May 2022 14:23:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93AB46B0073; Mon, 2 May 2022 14:23:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B4746B0074; Mon, 2 May 2022 14:23:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 6578F6B0072 for ; Mon, 2 May 2022 14:23:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3C88C2A75A for ; Mon, 2 May 2022 18:23:13 +0000 (UTC) X-FDA: 79421625066.20.AFAA6B2 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf18.hostedemail.com (Postfix) with ESMTP id CCA8A1C0076 for ; Mon, 2 May 2022 18:23:05 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id v10so12247841pgl.11 for ; Mon, 02 May 2022 11:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=soDrUCknMyVVYvPemA56PqNhiuKbCg1Of1bAYvzc04U=; b=oTUjwX3W6oKX63IESDbFmRou3OK04x5xQm2299xh4kb56hLaAlhHqWKqmHjkQ9s1uO wiIBW9rDjKFSPCo0CnXwM18i658p8tSKW5tASbbgwFbtw/XwhJqm67p8ax+nhqQRLktI yCs9E5sk4JbOzsRXMj1/3iVyPgMTyl074NjUksuM2nG0HM1/Lxn2PPoZ/d3MFnV7Agjs YjUvXkqg3jUazRc72iAh6aUOe842coqldh4mD8I64oZxhGRB5Wm0Tb/jQTQDO+L7e97J YW0Am1f+76DXlBdHTABOv4Q0PU+gClsSUIk9Ax9Olz3XlpA5C4CBTZwRMIYkRa337vJB j7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=soDrUCknMyVVYvPemA56PqNhiuKbCg1Of1bAYvzc04U=; b=PblxftLJNbyPJE79Tn75i8R+MrolqEHKopboQFRIM1dlkY8RIFUDv+UCcI9tTPcPrT ZiNAo/J75BcwGzzW/4Xmixq7fypdQszDSNIMuj1EslKPEZUvIBHQFYl+CDC5qICbHqPE VFy8QB+0mFir7yEoHikHal4jWp+2VJmxfgW7Gdp6BvMa3I8VfxUXL93dLadVWehWJLqR X8/LpmDV7SunEjNzr7Jyi5jCRec4fZfahsHanqaDwnYVfpD0rIkScQXYvcFYBTWhS2+J jmIEp2m8QEJ5oPQLPSomOcpJH8e3wAGN8PqR66YbWrI9eM5vvpKeH7sN4HiNO1AFt7TU VwcA== X-Gm-Message-State: AOAM532R5a3zVhvZ8qNqshohL01HGobOsstQTAxLR1UD+efjdWnDpsmw NLGPFDXN8Q3qB1EUg7mEbCs= X-Google-Smtp-Source: ABdhPJz+9+THi46rJXa+pHftSq0aA4FbZmNR0Ighom5c0vLQg5T7qstU/SjJr8YZj1NwnliWCxVndg== X-Received: by 2002:a05:6a00:890:b0:4f6:686e:a8a9 with SMTP id q16-20020a056a00089000b004f6686ea8a9mr12290094pfj.83.1651515791589; Mon, 02 May 2022 11:23:11 -0700 (PDT) Received: from google.com ([2620:15c:211:201:4d84:d37e:584f:bdbc]) by smtp.gmail.com with ESMTPSA id 12-20020a170902c14c00b0015e8d4eb1ecsm4968964plj.54.2022.05.02.11.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 11:22:49 -0700 (PDT) Date: Mon, 2 May 2022 11:22:33 -0700 From: Minchan Kim To: David Hildenbrand Cc: Andrew Morton , linux-mm , LKML , John Hubbard , John Dias Subject: Re: [PATCH] mm: fix is_pinnable_page against on cma page Message-ID: References: <20220502173558.2510641-1-minchan@kernel.org> <29d0c1c3-a44e-4573-7e7e-32be07544dbe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29d0c1c3-a44e-4573-7e7e-32be07544dbe@redhat.com> X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: CCA8A1C0076 X-Stat-Signature: fx3m1uu1tq4dsxbit9g8cghbect5i5eu Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=oTUjwX3W; spf=pass (imf18.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-HE-Tag: 1651515785-652099 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 Mon, May 02, 2022 at 08:02:31PM +0200, David Hildenbrand wrote: > On 02.05.22 19:35, Minchan Kim wrote: > > Pages on CMA area could have MIGRATE_ISOLATE as well as MIGRATE_CMA > > so current is_pinnable_page could miss CMA pages which has MIGRATE_ > > ISOLATE. It ends up putting CMA pages longterm pinning possible on > > pin_user_pages APIs so CMA allocation fails. > > > > The CMA allocation path protects the migration type change race > > using zone->lock but what GUP path need to know is just whether the > > page is on CMA area or not rather than exact type. Thus, we don't > > need zone->lock but just checks the migratype in either of > > (MIGRATE_ISOLATE and MIGRATE_CMA). > > > > Signed-off-by: Minchan Kim > > --- > > include/linux/mm.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 6acca5cecbc5..f59bbe3296e3 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1625,8 +1625,10 @@ static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma, > > #ifdef CONFIG_MIGRATION > > static inline bool is_pinnable_page(struct page *page) > > { > > - return !(is_zone_movable_page(page) || is_migrate_cma_page(page)) || > > - is_zero_pfn(page_to_pfn(page)); > > + int mt = get_pageblock_migratetype(page); > > + > > + return !(is_zone_movable_page(page) || mt == MIGRATE_CMA || > > + mt == MIGRATE_ISOLATE || is_zero_pfn(page_to_pfn(page))); > > } > > #else > > static inline bool is_pinnable_page(struct page *page) > > That implies that other memory ranges that are currently isolated > (memory offlining, alloc_contig_range()) cannot be pinned. That might > not be a bad thing, however, I think we could end up failing to pin > something that's temporarily unmovable (due to temporary references). Sure. > > However, I assume we have the same issue right now already with > ZONE_MOVABLE and MIGRATE_CMA when trying to pin a page residing on these ZONE_MOVALBE is also changed dynamically? > there are temporarily unmovable and we fail to migrate. But it would now > apply even without ZONE_MOVABLE or MIGRATE_CMA. Hm... Didn't parse your last mention.