Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp589316rdb; Sat, 19 Aug 2023 14:54:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfewax21/xyVCjZ3rfNB2Is7K1Imqef/Bc74Pt5ifedTBedJ9Pkdm9Cq5qwEaRLTH5THgG X-Received: by 2002:a05:6a20:7da2:b0:13e:7439:1449 with SMTP id v34-20020a056a207da200b0013e74391449mr4112862pzj.0.1692482040314; Sat, 19 Aug 2023 14:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692482040; cv=none; d=google.com; s=arc-20160816; b=Mm/j+WZsnANW4694K/YDjaIUeSMY+OPdKAhid5B34jdhydgxIwKKEzKlVpYptdnilY bGwpM8i8XC38efnmOnElS16ZCEs/ViAnLcB6Gji+Z8Ie/7SEc3o+zYtlmv1uu1Cd0Rcb gxzUQ56vrgGa30AHNrAq5vWkLBH11ptKHDPVk0TtagGUnj06RupricErLaPbPyCu7r5i 0yZzRd3nh6IG3E1pCfrHrNIXeb55FwldScy2MfN988FNXc7z4PcxgKzOJj4i7evSIsWa s5B/pImmBpqc1Ts2WLc8tqu6XKv2jA35c9ML7x8eDb4sRwlYQXvR6Ibu7BmFIbNFWG4s K+8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:dkim-signature; bh=l71zRfMiRyapTPa5arbOV6IXFSMIxMN4SCA6KAugbBs=; fh=Vj7edqn+Vv3C7pklByiTuSAypQqys4CrbAthgmsZ3iE=; b=w7/UPpTWc7jX3GKWYj4UL7LTC1PYtc0hqxJ63opG0yA3gxN4a8iHLMi0cWEYREomBc 5etRChH1sS6vbNscx0+9lMfYBK4WaDa49065Wo3zmDwWwrgCozLY8phL2LTBxr8TKl/B lGJK6LXiR8NHc8s8USjj0unouPzhD3HRW1PC6djimNzmneMpVjyfA3IOHfc6qR6tPtsS qAxs/0ZLstIlku/lGdwUupGVsF5Vf2WXbzNGeS9hdB0quBSSNHEdByl17yu5DdbHjU7t CRkScZsAHe+Glqzut8vluoVZHWYup+o7/Mub+4O9FGtAE9ekYwlO0Kao2tgA1Es8SCpX l+Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MOioReEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x190-20020a6386c7000000b00565bef99dbdsi3988148pgd.141.2023.08.19.14.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 14:54:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MOioReEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 30DECF11CD; Sat, 19 Aug 2023 01:48:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234510AbjHOEEu (ORCPT + 99 others); Tue, 15 Aug 2023 00:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234584AbjHOECV (ORCPT ); Tue, 15 Aug 2023 00:02:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2AE12E for ; Mon, 14 Aug 2023 20:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692071895; x=1723607895; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=8r/PGI5sh6lNNSHE6/JhZvUJ9bsJRVvnF4Cb7LyN84M=; b=MOioReEUUVWdoBAa4F2BZjulgezui5ktuJzp2moaciIStnBhyipkA7EA gb/XCcM/b/Ts/puxF8ukjYRvfB4D9qbDEaKbrGirRav3GMspJXFY2Sejq 4d8CdJquigeUsDUY05lugoMEeGa+CDScwUYLI/fK+R43/lc8vlOze4HnA TxR12ZceH6nyCgp/+sBt+eap3R5DU4a2X3HsujlZH1nQpH0gqRTGw0xR9 B8LxiidmWOz4gTTClPkb7hZ4/N5TX7OdzzTZGSw8DzvBc4UKZuHWEPBAg WVXKD8Eq7gfTjCu5L+AfxFCLPEcbJZhjxgZAQk9nLr0d9pW3RKEs0pUF0 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="436093218" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="436093218" 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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