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 4A24EC001B0 for ; Tue, 15 Aug 2023 03:58:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A66CE900019; Mon, 14 Aug 2023 23:58:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A16CF90000B; Mon, 14 Aug 2023 23:58:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DE8B900019; Mon, 14 Aug 2023 23:58: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 7B5AA90000B for ; Mon, 14 Aug 2023 23:58:18 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4B24F1A0CE5 for ; Tue, 15 Aug 2023 03:58:18 +0000 (UTC) X-FDA: 81124981476.27.05344E6 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by imf07.hostedemail.com (Postfix) with ESMTP id 559D640011 for ; Tue, 15 Aug 2023 03:58:14 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kdzjY6tk; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692071896; 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=l71zRfMiRyapTPa5arbOV6IXFSMIxMN4SCA6KAugbBs=; b=cZG4/0lw0lVEWQbhkC1G2IpEcEJ/6TK5i7AtNP7pwh21QbZcQPNHPJ0Egl0fbUA/RemiEL XJokqFBYjS2cGvxQWlIKgV59dxjI5ci338/ZQXX/8/6fqF9dGBzGXWxldev39sP84I+U1Z 1uYclC8i8EY9luNtVMnGdgTWw5eOEVo= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kdzjY6tk; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692071896; a=rsa-sha256; cv=none; b=lwn3/qaHUWUeFZ/pdavKe3FbOlnDk5YX0+g9ljex1r1T81l1DkwwVMC2KndJN89u+ylNN6 cbx5mfEcOPzhSyRbu1WMcUVb4PbxhzIryhZvZxODdgzHP2f+5G/8OUjOfq3GEi4mB+U2G0 m6WauZ1pEWu3ktsLSDk3ktacDXF8rqE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692071896; x=1723607896; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=8r/PGI5sh6lNNSHE6/JhZvUJ9bsJRVvnF4Cb7LyN84M=; b=kdzjY6tkRnKtlZjYIgD7thPk7H1ztLCt5yzQD9yuxJu7FvZrOsitVc8i HG0kW3+elr8YmX1I49IaHAaKzQBB/6ze3Mmx2mXVZe8Bydu9ClbacAsxC 5R3Xw3lWbsTCaz58+b3HyhFV65iKAITfkiJaWTrco/aXUOGKeRghyKg/A saanrGpk7q5blzYiiaOhleIvHZr6sK8pqbwMvBk27VonyDoAw+RQhLAtF i9zkjPQNGkp6bpn1jJcYPKZGYaKwysTp/lzj/LWb6flFFlHUDkwFi5RoG IQSRNmn2/S6GQ16bN/b6gkrtbqv5Sd2I1qr1h+24w4sZdlrhpPu4/a43l Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="436093219" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="436093219" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 20:58:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="857298440" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="857298440" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 20:58:11 -0700 From: "Huang, Ying" To: Kefeng Wang Cc: Zi Yan , Matthew Wilcox , Andrew Morton , , , "David Hildenbrand" Subject: Re: [PATCH 1/4] mm: migrate: use a folio in add_page_for_migration() In-Reply-To: (Kefeng Wang's message of "Fri, 4 Aug 2023 13:54:12 +0800") References: <20230802095346.87449-1-wangkefeng.wang@huawei.com> <20230802095346.87449-2-wangkefeng.wang@huawei.com> <001ee9b0-ea25-a896-e3ae-9a9b05a46546@huawei.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Tue, 15 Aug 2023 11:56:34 +0800 Message-ID: <871qg59cwd.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 559D640011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4x9zc1x666m4zfmwepz1q3x1jhyrtphk X-HE-Tag: 1692071894-140151 X-HE-Meta: U2FsdGVkX19GiBRgLSAX++dz5u4DYv8eadVGb5UXqtseM/WZCp9/BRtmyxpeMYz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ky9IS6McFZbvb90v7CoqigCyXLGNS1E1eGddyST/tRA3tftPW8a0L6Wtk1zXJMVoaSD8MeWYY6UuAdJ+6Zr/YGwKC5h5jtGAZyC9ex5WYL9Onam+UdsZEbiSD1fbJMc7n+CEhzQqDF6hSfPFyxUWNB2+SDZD4xFgMU66QA== 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: Kefeng Wang writes: > On 2023/8/4 10:42, Zi Yan wrote: >> On 3 Aug 2023, at 21:45, Kefeng Wang wrote: >> >>> On 2023/8/3 20:30, Matthew Wilcox wrote: >>>> On Thu, Aug 03, 2023 at 03:13:21PM +0800, Kefeng Wang wrote: >>>>> >>>>> >>>>> On 2023/8/2 20:21, Matthew Wilcox wrote: >>>>>> On Wed, Aug 02, 2023 at 05:53:43PM +0800, Kefeng Wang wrote: >>>>>>> err = -EACCES; >>>>>>> - if (page_mapcount(page) > 1 && !migrate_all) >>>>>>> - goto out_putpage; >>>>>>> + if (folio_estimated_sharers(folio) > 1 && !migrate_all) >>>>>>> + goto out_putfolio; >>>>>> >>>>>> I do not think this is the correct change. Maybe leave this line >>>>>> alone. >>>>> >>>>> Ok, I am aware of the discussion about this in other mail, will not >>>>> change it(also the next two patch about this function), or wait the >>>>> new work of David. >>>>>> >>>>>>> - if (PageHuge(page)) { >>>>>>> - if (PageHead(page)) { >>>>>>> - isolated = isolate_hugetlb(page_folio(page), pagelist); >>>>>>> + if (folio_test_hugetlb(folio)) { >>>>>>> + if (folio_test_large(folio)) { >>>>>> >>>>>> This makes no sense when you read it. All hugetlb folios are large, >>>>>> by definition. Think about what this code used to do, and what it >>>>>> should be changed to. >>>>> >>>>> hugetlb folio is self large folio, will drop redundant check >>>> >>>> No, that's not the difference. Keep thinking about it. This is not >>>> a mechanical translation! >>> >>> >>> if (PageHuge(page)) // page must be a hugetlb page >>> if (PageHead(page)) // page must be a head page, not tail >>> isolate_hugetlb() // isolate the hugetlb page if head >>> >>> After using folio, >>> >>> if (folio_test_hugetlb(folio)) // only check folio is hugetlb or not >>> >>> I don't check the page is head or not, since the follow_page could >>> return a sub-page, so the check PageHead need be retained, right? >> Right. It will prevent the kernel from trying to isolate the same >> hugetlb page >> twice when two pages are in the same hugetlb folio. But looking at the >> code, if you try to isolate an already-isolated hugetlb folio, isolate_hugetlb() >> would return false, no error would show up. But it changes err value >> from -EACCES to -EBUSY and user will see a different page status than before. > > > When check man[1], the current -EACCES is not right, -EBUSY is not > precise but more suitable for this scenario, > > -EACCES > The page is mapped by multiple processes and can be moved > only if MPOL_MF_MOVE_ALL is specified. > > -EBUSY The page is currently busy and cannot be moved. Try again > later. This occurs if a page is undergoing I/O or another > kernel subsystem is holding a reference to the page. > -ENOENT > The page is not present. > >> I wonder why we do not have follow_folio() and returns -ENOENT error >> pointer >> when addr points to a non head page. It would make this patch more folio if >> follow_folio() can be used in place of follow_page(). One caveat is that >> user will see -ENOENT instead of -EACCES after this change. >> > > -ENOENT is ok, but maybe the man need to be updated too. > > > > [1] https://man7.org/linux/man-pages/man2/move_pages.2.html > I don't think -ENOENT is appropriate. IIUC, -ENOENT means no need to migrate. Which isn't the case here apparently. -- Best Regards, Huang, Ying