Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5827788rwl; Sun, 8 Jan 2023 23:43:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXsy5iSj3wKF9BjZ7Ea/StDjTq1hlRf9FgCV8S++IBrqXIpNg+ShwbVbPdfaYqnsHabbDEq7 X-Received: by 2002:a17:907:209c:b0:7c1:41bb:70ac with SMTP id pv28-20020a170907209c00b007c141bb70acmr54818187ejb.64.1673250208600; Sun, 08 Jan 2023 23:43:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673250208; cv=none; d=google.com; s=arc-20160816; b=x86lsi3j3AC8lmSmTkk9yn8KlPXKES6GcF5CrE0KjgIMeJHHAOUepezVJECpzmEW49 42U8mjgh4UcoGzd7ukhbq5B8JIZ/Sm1gtCoaWz0PnC+qzdV4PUBfEUHezRd+gNVW2Qiz PCeUgBKTdG2qOFa1UWBsdG2sX458QtekzcTr0pRjjDOzzsBOhRXNBjde91m2BnF2dKXj OQaoPExmsvgZ5uOXjxAzyQ/DFbXM4yWw57kEkpI/sWaYi7QOgOz87IutlMHd9tr+cQIL vNlURrcNB1pAWTLYvaMoEmaB82tOFDYxHDz6uY5iMcVml4TICuovqTXuDm9iwtjL3hDf WJkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=MZRz+d7HIA7dRS5jxwks2fSMYKByALVKr7ZjzVqQFYY=; b=gBioFEkaQktY0YV9EWwhjWjoN5c8Dy0t/UNj0UY4yhcyDBIKpbFii9yEZUxvoEN/00 EpZXyn4QInY2m55DLd646Pa13w3ZcweocwyvdQpszZ/rkaSujMGIq/NWikKRzep5+IN3 KvYxK4yYKzaZiPGNSUFxdj0VIuEhqGuvEJkLDJAUBuaZy1+X41br31iNrpFcvDMCr6lV AlYAnq6ksTJ7vcpNAGIlCinASzkV1LVKtXaM/rL6bQP2t+sl0K9pVaQ2kIhmCARvuxf3 x5tStHyKfR3g8hmGfq6lWnouNQ2vVMqrADB2qCMRLZHHA0LRqIVL1SPwE/fu4UWf7bUQ /tww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AOJtAEf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xc2-20020a170907074200b0084bbb86a74fsi9544044ejb.540.2023.01.08.23.43.15; Sun, 08 Jan 2023 23:43:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AOJtAEf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234027AbjAIHYU (ORCPT + 56 others); Mon, 9 Jan 2023 02:24:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236369AbjAIHYS (ORCPT ); Mon, 9 Jan 2023 02:24:18 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CDD1260F for ; Sun, 8 Jan 2023 23:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673249057; x=1704785057; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=7IuvSph9kr4u0JaBkExjjY/5PCAEw1jXvnA0UpXIL2Y=; b=AOJtAEf9nOdyA0BAGR4/zK+x+F7yxnlw3K/VgeE/fTk4B7LwC/WWtRtG ay6PNr0Ohl3P5C2t13eFpIPB+jg5R2NTIethToT9VnnD09D2pfRADqCGG 7V1J52/WTmxRMc3P5ruYbXMkMG+XVOM5gqjxEG9OQwN6GDNBjUd3lgx/r HF71NhjHGvNFmxPKzqA22Qz5E0ZpNHfdp1Hj2Sn0QDNfoKbHGRZqn+qSS lj10WNTqTAqiExxrnJfoPg/jWtvMUUEpmeVvgFdl22/gmXLiKfttT42/L UZyahAytgdAC3+g71mwAQsFt9YtEG5fG7qfYg0YnFCssOAqImZ7vZkpEr g==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="350023791" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="350023791" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 23:24:16 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="725072753" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="725072753" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 23:24:13 -0800 From: "Huang, Ying" To: Alistair Popple Cc: Andrew Morton , , , Zi Yan , Yang Shi , Baolin Wang , "Oscar Salvador" , Matthew Wilcox , "Bharata B Rao" , haoxin Subject: Re: [PATCH 2/8] migrate_pages: separate hugetlb folios migration References: <20221227002859.27740-1-ying.huang@intel.com> <20221227002859.27740-3-ying.huang@intel.com> <87pmbttxmj.fsf@nvidia.com> <87pmbtedfp.fsf@yhuang6-desk2.ccr.corp.intel.com> <877cy1scg5.fsf@nvidia.com> <87k021bfpj.fsf@yhuang6-desk2.ccr.corp.intel.com> <87y1qhqv5k.fsf@nvidia.com> Date: Mon, 09 Jan 2023 15:23:03 +0800 In-Reply-To: <87y1qhqv5k.fsf@nvidia.com> (Alistair Popple's message of "Thu, 05 Jan 2023 18:39:59 +1100") Message-ID: <87fsck5fzc.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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 Alistair Popple writes: > "Huang, Ying" writes: > >> [snip] >> >>> >>>>>> @@ -1462,30 +1549,28 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, >>>>>> nr_retry_pages = 0; >>>>>> >>>>>> list_for_each_entry_safe(folio, folio2, from, lru) { >>>>>> + if (folio_test_hugetlb(folio)) { >>>>> >>>>> How do we hit this case? Shouldn't migrate_hugetlbs() have already moved >>>>> any hugetlb folios off the from list? >>>> >>>> Retried hugetlb folios will be kept in from list. >>> >>> Couldn't migrate_hugetlbs() remove the failing retried pages from the >>> list on the final pass? That seems cleaner to me. >> >> To do that, we need to go through the folio list again to remove all >> hugetlb pages. It could be time-consuming in some cases. So I think >> that it's better to keep this. > > Why? Couldn't we test pass == 9 and remove it from the list if it fails > the final retry in migrate_hugetlbs()? In any case if it's on the list > due to failed retries we have already passed over it 10 times, so the > extra loop hardly seems like a problem. Yes. That's possible. But "test pass == 9" looks more tricky than the current code. Feel free to change the code as you suggested on top this series. If no others object, I'm OK with that. OK? Best Regards, Huang, Ying >> >>>>>> + list_move_tail(&folio->lru, &ret_folios); >>>>>> + continue; >>>>>> + } >>>>>> + >>>>>> /* >>>>>> * Large folio statistics is based on the source large >>>>>> * folio. Capture required information that might get >>>>>> * lost during migration. >>>>>> */ >>>>>> - is_large = folio_test_large(folio) && !folio_test_hugetlb(folio); >>>>>> + is_large = folio_test_large(folio); >>>>>> is_thp = is_large && folio_test_pmd_mappable(folio); >>>>>> nr_pages = folio_nr_pages(folio); >>>>>> + >>>>>> cond_resched(); >>>>>> >>>>>> - if (folio_test_hugetlb(folio)) >>>>>> - rc = unmap_and_move_huge_page(get_new_page, >>>>>> - put_new_page, private, >>>>>> - &folio->page, pass > 2, mode, >>>>>> - reason, >>>>>> - &ret_folios); >>>>>> - else >>>>>> - rc = unmap_and_move(get_new_page, put_new_page, >>>>>> - private, folio, pass > 2, mode, >>>>>> - reason, &ret_folios); >>>>>> + rc = unmap_and_move(get_new_page, put_new_page, >>>>>> + private, folio, pass > 2, mode, >>>>>> + reason, &ret_folios); >>>>>> /* >>>>>> * The rules are: >>>>>> - * Success: non hugetlb folio will be freed, hugetlb >>>>>> - * folio will be put back >>>>>> + * Success: folio will be freed >>>>>> * -EAGAIN: stay on the from list >>>>>> * -ENOMEM: stay on the from list >>>>>> * -ENOSYS: stay on the from list >>>>>> @@ -1512,7 +1597,6 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, >>>>>> stats.nr_thp_split += is_thp; >>>>>> break; >>>>>> } >>>>>> - /* Hugetlb migration is unsupported */ >>>>>> } else if (!no_split_folio_counting) { >>>>>> nr_failed++; >>>>>> }