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 ABCB0C433FE for ; Thu, 20 Oct 2022 07:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbiJTHtW (ORCPT ); Thu, 20 Oct 2022 03:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbiJTHtR (ORCPT ); Thu, 20 Oct 2022 03:49:17 -0400 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E6CC1757B3 for ; Thu, 20 Oct 2022 00:49:15 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VSeILu6_1666252152; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VSeILu6_1666252152) by smtp.aliyun-inc.com; Thu, 20 Oct 2022 15:49:13 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: david@redhat.com, ying.huang@intel.com, ziy@nvidia.com, shy828301@gmail.com, baolin.wang@linux.alibaba.com, jingshan@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: gup: Re-pin pages in case of trying several times to migrate Date: Thu, 20 Oct 2022 15:49:00 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The migrate_pages() will return the number of {normal page, THP, hugetlb} that were not migrated, or an error code. That means it can still return the number of failure count, though the pages have been migrated successfully with several times re-try. So we should not use the return value of migrate_pages() to determin if there are pages are failed to migrate. Instead we can validate the 'movable_page_list' to see if there are pages remained in the list, which are failed to migrate. That can mitigate the failure of longterm pinning. Signed-off-by: Baolin Wang --- mm/gup.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 5182aba..bd8cfcd 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1914,9 +1914,10 @@ static int migrate_longterm_unpinnable_pages( .gfp_mask = GFP_USER | __GFP_NOWARN, }; - if (migrate_pages(movable_page_list, alloc_migration_target, - NULL, (unsigned long)&mtc, MIGRATE_SYNC, - MR_LONGTERM_PIN, NULL)) { + ret = migrate_pages(movable_page_list, alloc_migration_target, + NULL, (unsigned long)&mtc, MIGRATE_SYNC, + MR_LONGTERM_PIN, NULL); + if (ret < 0 || !list_empty(movable_page_list)) { ret = -ENOMEM; goto err; } -- 1.8.3.1