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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02421C433EF for ; Mon, 2 May 2022 18:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386806AbiEBSGJ (ORCPT ); Mon, 2 May 2022 14:06:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386791AbiEBSGG (ORCPT ); Mon, 2 May 2022 14:06:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8C211113D for ; Mon, 2 May 2022 11:02:37 -0700 (PDT) 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-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-462-2KcjjT-CP-edNLHnJrQCCw-1; Mon, 02 May 2022 14:02:35 -0400 X-MC-Unique: 2KcjjT-CP-edNLHnJrQCCw-1 Received: by mail-pf1-f200.google.com with SMTP id y141-20020a626493000000b0050d8c0745a3so7514678pfb.21 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=5CLuIsE2hcHJJovUZ6TDdo4WMYnl/PuX119IPwrrgIK0Ro8h5VgWnuXlv6YvlGjPpX Cve7ctO3G6ld3yNhCE7L8ZpfTDlxK/LKaqiTkF2MLMPb9m4mBfdNxTAdyyGqaSSDW2gq H2f6AmxFPWnS5Q0YE4QizNvCr3ri72KiTx3PJ3+jWsyeGDGJT0136UDRMxD8P47y4UkC plS6LdDT6/+0Iyu6D/psRi0Ei6j3Guyc/sEZwNHOJCXE3LMb0dQuthplQcLL7m/F8V7V ETDUFxe6q5ivoc0oZCkF988H1Nn7Ywrk7ybsaPdtoGiTYrVp9k+FycpL53BKBKuc+jbd Y+kQ== X-Gm-Message-State: AOAM5321IqKRfgWUNmySqfH/0o0/DkYMdxCzVm/yg0LIMFtCFQ1Zb9dc QVa+NIXC4AbpPUhQ/SipYSpFvGBs0LarVC2R8Xby60d9rmHFJck9Ik/9dSY8dpKAs15wujAAV// ck59IiBz3rGXgtSXKe1wKnyyO X-Received: by 2002:a63:8442:0:b0:3ab:2451:5239 with SMTP id k63-20020a638442000000b003ab24515239mr10519518pgd.75.1651514554314; 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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