From patchwork Thu Oct 20 07:49:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13012763 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 2718DC433FE for ; Thu, 20 Oct 2022 07:49:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F3436B0071; Thu, 20 Oct 2022 03:49:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A3C66B0073; Thu, 20 Oct 2022 03:49:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 592576B0074; Thu, 20 Oct 2022 03:49:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 494B96B0071 for ; Thu, 20 Oct 2022 03:49:18 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1F6D912033A for ; Thu, 20 Oct 2022 07:49:18 +0000 (UTC) X-FDA: 80040552396.24.FF11777 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf14.hostedemail.com (Postfix) with ESMTP id 67468100012 for ; Thu, 20 Oct 2022 07:49:16 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666252157; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=NESju3q1gAbH3qzt3XpNCw/tm1i7c3v5l8OQbViFb0M=; b=B+Mi13nVnG3Kd64Soy90+ZACkLnYEFsiwHpBJKkaAJWbai9Jojabp6zks72mwXuZ40dvjd 6MDYzuiyCnn5wB+Y7ddXXMh4o5QqFsq3Q0pQtODQ8OvfNhMIrwCuV+PGLXw+VCJbTkcmat 0TlclYifi7rhb7IG0F64DnihtUAooXw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf14.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666252157; a=rsa-sha256; cv=none; b=egY1MN76jeg/H43QnD7AYMqYy50mBSdiYZzhEzeBdmzGuYgDuuNoTFjcyY2+J/WKi3H3oZ wsrNIDLEqDjk9osdDFzRZWktNMZIH2gHZy/7xsKUF0R+mbjBQ6B9lO+LuU1BMywbpb+YDd KsXDmUgDoaVBNbG+I6ZkbpALJoxt3Hg= Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf14.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Stat-Signature: 1tn63y94n6q8ickx69m5gcjxmxgu38ht X-Rspamd-Queue-Id: 67468100012 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1666252155-809095 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }