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 CA2DEC433F5 for ; Mon, 2 May 2022 18:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07B666B0072; Mon, 2 May 2022 14:02:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 029F66B0073; Mon, 2 May 2022 14:02:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0C6F6B0074; Mon, 2 May 2022 14:02:37 -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 CEA906B0072 for ; Mon, 2 May 2022 14:02:37 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 9BD7B120EA6 for ; Mon, 2 May 2022 18:02:37 +0000 (UTC) X-FDA: 79421573154.25.4BDFCAD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 6E16580085 for ; Mon, 2 May 2022 18:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651514556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/7hFm9ltFIzBATidA3Ww0iDJkWtpV+O0jI4LMjG86v8=; b=JFTpcd50zgJOki0UH1r7lZxpArDCzT9229Q1bn/TynvU/835HdM6e/P7zbOGTEWMt3S5oc PN25mrztMS0KxwgmKsGqwiXytpeN0O7lR3Szga4FEnnGDenzusDOJibuc0F57ZgHttQnnN Kgz1u6V66WbuyKTDcdSAMIW6A6EguNI= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-haeTmSipPLKSl8Fq6KpRiA-1; Mon, 02 May 2022 14:02:35 -0400 X-MC-Unique: haeTmSipPLKSl8Fq6KpRiA-1 Received: by mail-pj1-f72.google.com with SMTP id r9-20020a17090aa08900b001d8826816e6so8944pjp.4 for ; Mon, 02 May 2022 11:02:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=/7hFm9ltFIzBATidA3Ww0iDJkWtpV+O0jI4LMjG86v8=; b=JZGJ2xzTRqfCGMFwlwBYRfyX4lcj+3JLkrpuWD8yLQU7NmiWNXSNQOJ7sFJreB3zAQ 0ICCD1NbD8G8RVYHdYLPQhW+jSjCyo5SLpR9ESWH9hl0ZkrYnu4G/AM7AHx1Qgm9VNLi HHdQj5DXUFKUhmWpadiInt3q6mjHg0Rz0B/OgyBV7MiDyUJS/mw+DlIIUMHcNpGRyeuj k6oi5ik1az8glyH4wnuPSXjGKrBxKazvv3W2LCldIZB6G0H6qUEbjIzDiDUy/VYucVNZ WGtO+xYPKoQihF7+mkUyt9IXloPIlhO679hpB7RBNdJ+viH2fwdtW648ileGrwQboocr FmgQ== X-Gm-Message-State: AOAM532BecjKdhOo76Hrs4gENXOIaML33hPTBjE3tLLiNkalPs5JSDPI qgqD9ypFV+T5M0NqiaEehWAYuWKtTDW2ag1+tqf6ifILy5UtUW0mYEpyBh/iNTLPMD/U15wXWlE Qv1NSDy7F91c= X-Received: by 2002:a63:8442:0:b0:3ab:2451:5239 with SMTP id k63-20020a638442000000b003ab24515239mr10519516pgd.75.1651514554315; Mon, 02 May 2022 11:02:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSCpzMt2Hf99prkkLKqQDtNuXYmNZP4X35wY6IcPgEq003e4qRkyfeq0V97I2uydXBXWVeWg== X-Received: by 2002:a63:8442:0:b0:3ab:2451:5239 with SMTP id k63-20020a638442000000b003ab24515239mr10519492pgd.75.1651514554007; Mon, 02 May 2022 11:02:34 -0700 (PDT) Received: from [10.10.69.234] ([8.34.116.185]) by smtp.gmail.com with ESMTPSA id x17-20020a17090ab01100b001d97f7fca06sm656pjq.24.2022.05.02.11.02.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 May 2022 11:02:33 -0700 (PDT) Message-ID: <29d0c1c3-a44e-4573-7e7e-32be07544dbe@redhat.com> Date: Mon, 2 May 2022 20:02:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 To: Minchan Kim , Andrew Morton Cc: linux-mm , LKML , John Hubbard , John Dias References: <20220502173558.2510641-1-minchan@kernel.org> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] mm: fix is_pinnable_page against on cma page In-Reply-To: <20220502173558.2510641-1-minchan@kernel.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: or8bsnp7rma7c3i9ky6uedg36k5oe8xh X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6E16580085 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFTpcd50; spf=none (imf30.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-HE-Tag: 1651514545-114709 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 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). 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 there are temporarily unmovable and we fail to migrate. But it would now apply even without ZONE_MOVABLE or MIGRATE_CMA. Hm... -- Thanks, David / dhildenb