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 BCFAFC43217 for ; Fri, 21 Oct 2022 00:29:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11D8D8E0002; Thu, 20 Oct 2022 20:29:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CE158E0001; Thu, 20 Oct 2022 20:29:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB03D8E0002; Thu, 20 Oct 2022 20:29:26 -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 D79DA8E0001 for ; Thu, 20 Oct 2022 20:29:26 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A8F54C095B for ; Fri, 21 Oct 2022 00:29:26 +0000 (UTC) X-FDA: 80043072732.15.6E98298 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf24.hostedemail.com (Postfix) with ESMTP id 08EFC18002D for ; Fri, 21 Oct 2022 00:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666312166; x=1697848166; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=v2dE9M9t9yvuMjl71gpN7mNk/imF/OKQN0QqVm+fcfU=; b=ns7TxiElNfwyjzf/30p9RblCdsQ1Zg2l6T33Eo2VlACV4057OAAMHpEs rxjFiI3BOLeJ6hUHe9CSf05uDbikDZfTZp3TkpX2y93Ogojx2BPU8jakS /oaMt6EW0I+s7Uh6M2J+j0eYey8zHKLDoHL6Cyt2pHQvy2O2BZ1zuZBXs YW7UJSaOnlzzUxLEPEADgzbrKUfRq2DfPnVCIS4zI5cK2l+NmM1CyyxhR fP23e1hr77/579mrweJgbwVatVNGDOIN0n9odIU1gQMbsSejRw8W2lVNT DoBdxUSYK1ySSDb8I3wjDVzZ/0AVTtITEYBZpVF2T4tKLJ5awl6qGeffY g==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="286593283" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="286593283" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 17:29:24 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="693349171" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="693349171" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 17:29:22 -0700 From: "Huang, Ying" To: Baolin Wang , Alistair Popple Cc: , , , , , , Subject: Re: [PATCH 1/2] mm: gup: Re-pin pages in case of trying several times to migrate References: <87r0z2nc6j.fsf@yhuang6-desk2.ccr.corp.intel.com> <87o7u6soip.fsf@nvidia.com> Date: Fri, 21 Oct 2022 08:28:43 +0800 In-Reply-To: <87o7u6soip.fsf@nvidia.com> (Alistair Popple's message of "Thu, 20 Oct 2022 22:43:39 +1100") Message-ID: <87edv2m344.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666312166; 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=BRSxv9tCef1qT8jK5vAippvF//d+IQ7YX7VYg+XSyRY=; b=5IOgONaL/V+qOzBxUUaOuVpdMNV//x8BEt5SX5qOQWmWNp6QQBfoG7uSallD7z3IEmFABv LFlw+V2+CQKHtlLkwsmtXHMQmpHFjrDRpQKukQMp22wvQksVRZAgR6CRFwUcAXUUhZw9a8 J719JFZnRMbhf8VihTFwpBE9lMrRqcg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=ns7TxiEl; spf=pass (imf24.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.136 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=1666312166; a=rsa-sha256; cv=none; b=vQIh3AgQeAO+fyw1c+xt7a+9kZJEQ2B3q7vOgWnr9g8J2jU1GcJpbThERr0vUx8lBXD35W BSEY7D02D/tRMJ3Gq39/Mht6E2zxq1kUQkGMgx/qUeZzPfJFT9pFkgrch/nO/DqSPqV4xq EAdAFixZBEUEzZPFtcEOH2PFCeKq5dQ= X-Rspamd-Server: rspam12 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=ns7TxiEl; spf=pass (imf24.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: 9x3bi1o6ijuiiquuqy8ipqcnpu4mmn9f X-Rspamd-Queue-Id: 08EFC18002D X-HE-Tag: 1666312165-781763 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: Alistair Popple writes: > Baolin Wang writes: > >> On 10/20/2022 4:15 PM, Huang, Ying wrote: >>> 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. >> >> Yeah, that's the case I tested. Thanks for pointing out. I'll re-write my >> incorrect commit message next time. > > This is confusing to me. So users of move_page() will see an > unsuccessful migration even when all subpages were migrated? Seems like > we should fix the return code of migrate_pages() for this case where all > subpages were successfully migrated. > >>> >>>> 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). >> >> OK. Using list_empty(return_pages) looks more simple. >> >>> >>>> 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. >> >> OK. Drop the 'ret < 0' >> >>>> ret = -ENOMEM; >>> Why change the error code? I don't think it's a good idea to do that. >> >> The GUP need a -errno for failure or partial success when migration, and we can >> not return the number of pages failed to migrate. So returning -ENOMEM seems >> suitable for both cases? > > Seem reasonable to me. migrate_pages() might return -EAGAIN which would > cause everything to be re-pinned and tried again which is not what you > want here. See the comment at the start of > check_and_migrate_movable_pages(). Yes. You are right. The error code of migrate_pages() isn't good for caller here. Best Regards, Huang, Ying