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 9413DC001B0 for ; Tue, 15 Aug 2023 20:41:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0820C94002E; Tue, 15 Aug 2023 16:41:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 031DB8D0001; Tue, 15 Aug 2023 16:41:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3BCC94002E; Tue, 15 Aug 2023 16:41:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D30038D0001 for ; Tue, 15 Aug 2023 16:41:34 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9F3F61602F2 for ; Tue, 15 Aug 2023 20:41:34 +0000 (UTC) X-FDA: 81127509708.15.ED8EFFF Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by imf26.hostedemail.com (Postfix) with ESMTP id 2DE00140019 for ; Tue, 15 Aug 2023 20:41:31 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kiU0cDWv; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf26.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692132092; a=rsa-sha256; cv=none; b=VyYQHoxA2hCab8SPHRq/i53vGqEO+CpEI4dTbfdvHWo2IqVNQEtxbiRZr93gXdUBVZF0Al CdMTsDKVtv+eBDT6PW1hIuvkQSWDKbSRcvdc2B2zzDHI0kvC7nPpiK+sP79ZIjogId+odj 0brB7qDoeO1AamGwc62chyPhuXcOlJU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kiU0cDWv; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf26.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 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=1692132092; 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=9eaRwEU5TTI66SWQdXe+33Iddqm1IugbtK6Mt41gfrU=; b=UQL7JxCj5Tk4W1yBM6EnTrVVapliTdJdTG7zP/fP6HaUupjEuov9ytLKjm5/dPTrlYLt4z QouF2cWLAMm0kbxpiseIWLlGhSwJiGy5nlR+Zlvd5wi/nkoZ6PwKk30h5sjnuxFNNxKDBI wm4Agyml1CadaH3mB14wKsKJt+atUcg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692132092; x=1723668092; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=exbiW8jhthhzTeNaTfGZ9rElvFKsApJ1bUdOpF1JaE8=; b=kiU0cDWvuzd+gGRffw3N9b3I58jHLqaYLJM51ujQ9qwP/CNmfYbbtY1+ cMo+K2DnglVVm8O1fmI+XqOMNFQKXpuN5wFofFKu7qxUV7N/tbfrVY6av yOqP5MUhQ0WVIAzPTdBdtNw4k7u1Kj1Ps/W98t3HsVNpS7lx2ABZjyJHg lUZ3onf4dkx3q+F1IyCbXZwRsYuroWmFbSz5eDa5dWt35iocWXT2UgL8p 0PQg7lQDyrIxLNZyWiH40d94ok4ecWZ3n95CZnqIdd2NC2epIU7f8PpUT mha55JZac8xXIM3aCNNIGVa9of4jwIOb9VsdAuzHzWylQWQTrEBO0VGhv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="375142545" X-IronPort-AV: E=Sophos;i="6.01,175,1684825200"; d="scan'208";a="375142545" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2023 13:41:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="1064574785" X-IronPort-AV: E=Sophos;i="6.01,175,1684825200"; d="scan'208";a="1064574785" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2023 13:41:27 -0700 From: "Huang, Ying" To: Zi Yan Cc: Kefeng Wang , Matthew Wilcox , Andrew Morton , , , David Hildenbrand Subject: Re: [PATCH 1/4] mm: migrate: use a folio in add_page_for_migration() References: <20230802095346.87449-1-wangkefeng.wang@huawei.com> <20230802095346.87449-2-wangkefeng.wang@huawei.com> <001ee9b0-ea25-a896-e3ae-9a9b05a46546@huawei.com> <871qg59cwd.fsf@yhuang6-desk2.ccr.corp.intel.com> <2E8CA295-CEA2-4093-8287-F68C3977A538@nvidia.com> Date: Wed, 16 Aug 2023 04:39:50 +0800 In-Reply-To: <2E8CA295-CEA2-4093-8287-F68C3977A538@nvidia.com> (Zi Yan's message of "Tue, 15 Aug 2023 09:49:06 -0400") Message-ID: <87zg2s6nvt.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2DE00140019 X-Stat-Signature: d6aic5w51mt7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vaQVnq6nfQ7yeTawMGPYVKv25msBu5BB96/dEwyh93jEkPl9s4z3JGscuFe7vyoYsjWj9//oIu1eJalpWVNqisWRwZHYT3jCPVBsa3WWaj3FZL3EstqtZsTGLoMibo+fO4FcPJpkh/C0Ga4dx2LTXMI1L/PdMCPNkFOr4YIl97LKcxxT2MoR/LPDwyhbKFEegwSLk2BSVLx/r8o+MXf/3AJrFzQpkpePAdJ2C6CNtCP8vtBGya3l+9V5/1UPkKSjlfYNo0AuLFCXHZFR2REKdO+V8shi8xL/4= 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: Zi Yan writes: > On 14 Aug 2023, at 23:56, Huang, Ying wrote: > >> 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. > > Are you referring to a comment or the man page? The man page says > -ENOENT means the page is not present. Or you think it also implies > there is no need to migrate? If yes, we probably need to update the man > page. Is it possible that a page isn't present, but we need to migrate it? -- Best Regards, Huang, Ying