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 98DFFC433FE for ; Thu, 20 Oct 2022 08:16:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 112766B0071; Thu, 20 Oct 2022 04:16:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C2FA6B007B; Thu, 20 Oct 2022 04:16:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF38D8E0001; Thu, 20 Oct 2022 04:16:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E0AD16B0071 for ; Thu, 20 Oct 2022 04:16:01 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AAB84120E1D for ; Thu, 20 Oct 2022 08:16:01 +0000 (UTC) X-FDA: 80040619722.14.97382A1 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf24.hostedemail.com (Postfix) with ESMTP id EFEF718003C for ; Thu, 20 Oct 2022 08:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666253761; x=1697789761; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=RKaKnazpa+pjHWVnMNe0+2wGDtva+lQgFSovg78wKSU=; b=LJ6GhFqLbdh3qLkIFLW4CVN5oG1XWQ5u5zknpjc+Nth9FsiCjiLs1+ur tNKf7rS0v6K7KtbwaegrQGSjZ9LWi0VlcbWt3qOApruPD9kK80DbLoBr8 l4WwPo2S3WBOorGDGNSOqwsx0xqIibZwcOUg1hsE9yaQ3mit5YQiya7cg I8ziaZ4kyOsEI2KpiJ/gsUy9t4hOUGQuFikHhybB1elQefAD3yoTcq3kQ aoaO0Ey+m0/m8LQHYkzyYRKWnLcCo+zNFSutpoDhF9OcUpqVpZfYVleQM ZNtdCSQGg8CfIq7DXgi/Ir0kVhr5My/9T7PybcxX0JcnIITD5fU9wxaod A==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="307745446" X-IronPort-AV: E=Sophos;i="5.95,198,1661842800"; d="scan'208";a="307745446" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 01:15:59 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="624548834" X-IronPort-AV: E=Sophos;i="5.95,198,1661842800"; d="scan'208";a="624548834" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 01:15:56 -0700 From: "Huang, Ying" To: Baolin Wang Cc: , , , , , , Subject: Re: [PATCH 1/2] mm: gup: Re-pin pages in case of trying several times to migrate References: Date: Thu, 20 Oct 2022 16:15:16 +0800 In-Reply-To: (Baolin Wang's message of "Thu, 20 Oct 2022 15:49:00 +0800") Message-ID: <87r0z2nc6j.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=LJ6GhFqL; spf=pass (imf24.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666253761; a=rsa-sha256; cv=none; b=gQUnwrM0cZ6ENSL1gqUaEQVkauv2QKSCuuubw/+mtKQexjygQIY1Kvn0qY/9EUQl5z7D2j CkVoGfscKeOGb3PL02/j0XSH47w3/z1k9GIloALvj6lHKL031lDgpvQFMbPkY3IxhT5bV/ eyd8l2nErW7egfW4H0ZawbKsLUOjun8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666253761; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HjIokR1LXZ5kIWH+owo+kfl4JCrrsEWyOLBQm2z57es=; b=x8jHuanmnailhbBa9H3Kvc7FYTK6p7s31OhLNxhCtMVbLftZqVIwJE2J7p+SPo0Ni+/3dy bdDvO90kui796WuvARWTmwJZWdyAT/eYO+NtOo4Ur49UvDByNuq8cQn9M7cTERsEzCkrL4 q2VVn8kGpKbnZMGlwwK6SDunKReG/RQ= Authentication-Results: imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=LJ6GhFqL; spf=pass (imf24.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: ajz9wff6fjg5f3w6uniufa6fx31q8n4z X-Rspamd-Queue-Id: EFEF718003C X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666253760-552167 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: Baolin Wang writes: > 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. If my understanding were correct, if pages are migrated successfully after several times re-tries, the return value will be 0. There's one possibility for migrate_pages() to return non-zero but all pages are migrated. That is, when THP is split and all subpages are migrated successfully. > 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. Another choice is to use a special return value for split THP + success migration. But I'm fine to use list_empty(return_pages). > 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)) { It seems that !list_empty() is sufficient here. > ret = -ENOMEM; Why change the error code? I don't think it's a good idea to do that. > goto err; > } Best Regards, Huang, Ying