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 A7CDAC7EE23 for ; Wed, 10 May 2023 01:49:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1AEB6B0071; Tue, 9 May 2023 21:49:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CAB46B0072; Tue, 9 May 2023 21:49:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 893026B0074; Tue, 9 May 2023 21:49:53 -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 7A4236B0071 for ; Tue, 9 May 2023 21:49:53 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AAAFD140508 for ; Wed, 10 May 2023 01:49:52 +0000 (UTC) X-FDA: 80772664224.20.1691C2E Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by imf01.hostedemail.com (Postfix) with ESMTP id A5D2A4000E for ; Wed, 10 May 2023 01:49:49 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf01.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683683391; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7LCTiwZgEhrlDXk+dHmZf082j/5TFbOE6aKC7MlFzxw=; b=ofkExbVTuijx2c8GS4wVYjmi0B6lz+lOvpRJglBHsLyrLjrccrF1gFHANnTXQG1uXh7Aj2 wPMTnEYySzOR0CThIFZkKUC6N0cC+tOV37UQdbdG7By0bfVrM+0hv+kPqiELMEaQWMbXIY zEmkbSdz9+jebHJ0FOAwm7Vq7kU1HL8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf01.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683683391; a=rsa-sha256; cv=none; b=GYvtqBw4k/+McshPVO0s53mxia2iWX89FPcwVkVEtXk60cB0xXckX0a9vFO1m+yxvsAZHS 8tT0A7c6khPO9xktt9RSxCP/gTRwCm2RdMtu/4JQ1MkdTjLPlgLpxeqTrcvcZ9T5y3W9UT /aghRXUFC+1B4hdz4tuAfZXtVxGAIww= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R701e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0ViDRxzG_1683683383; Received: from 30.240.106.49(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0ViDRxzG_1683683383) by smtp.aliyun-inc.com; Wed, 10 May 2023 09:49:45 +0800 Message-ID: <432c0505-301f-9abb-6e99-0dc216913122@linux.alibaba.com> Date: Wed, 10 May 2023 09:49:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 1/2] migrate_pages_batch: simplify retrying and failure counting of large folios To: Huang Ying , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador , Alistair Popple References: <20230509022014.380493-1-ying.huang@intel.com> From: haoxin In-Reply-To: <20230509022014.380493-1-ying.huang@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: c4iqtniuxw8dti6kwbzewi88pkwuzxos X-Rspam-User: X-Rspamd-Queue-Id: A5D2A4000E X-Rspamd-Server: rspam07 X-HE-Tag: 1683683389-805822 X-HE-Meta: U2FsdGVkX188JBYU7EzvCoI61acl9NDjnnJN/FvKw7X6LZGx+fZivgdRB+ENerkt4/a6BGMC4y3xsm/AEf/qR1qvo4L23+9ycHtx/3JKzR1np4ayOGeihngXXUuUy9dm8kHgIAdZbVnpWlhI6snJfkxaUdQUu9CbaVLOCWJZHrIL2CMB7Hzp8C1MnrSyLcF1ueOziMZu+OjRUqNPc4mLMp4DvibZDkmDgITgm4bPpYV1pepttPEcpXqkPhwWNJE2NaKEhy/JdqkvnTtZ7jBwDUPT/njxqlTQOyxfjJeKDx2EARxeK5AvoHRG+23PPcqxA4xrCKX/R+ofEH0f1eaD03FWfL1oU4zWtMf3meieRZBsXrBqmuQjimWIYXasAdsyo1zoBqyOvVlpfJH01J76O77ZFat4m/shbV7SS1hA1aL6JEx+6EaSF4Z/HhclMiVdgPqDIwl210iM12V+jaH6cr9QCF/BgSMmIleChhDEEDUlUY5Qd8geC0h8TgXDKlT5CrVeBIFRrzJ9QIbg/OSpO9juH7CHRRjdvrt32wcCUjZTxiRB2nfaJMxzVtKlhtQOiRVF11vmEzV6kxYkp+0CVw5k6aKtpod+lf3xooDQCnLoy0Ym37SFe++GfrO/ep8yvlojNXDgTdt7C8PNFCYn54XnGkJyJenEsn5Xvg+IQ1Sxahfvny4Vov3QkSt2WH+2P9BgRSh9/PJn0yAnusjVA5q36QmxBVe6xyJbL0Rah+lWB6PEAkjVM8I6CKVZd/ZOG5UcH8+Uq/cPbC30NKnV4kABwZ81YIP+UtVxHtPiq1CwVXvYKA6QGdk4cAVC2MhwDRdMrTlZOnwwB6hsxhGQNhEtvTXBckDJvMJjzbryDZ1pVJpNEEQwP99iqV8UJn+8FHpS5B94whi/77s6yM37F5C3QasfcYkTnIGItalMNoy2c+1jyfkUDoR9Pm/URvVwdn7oAd8Lr24NbOeQeKB FhpITU0m gblVDthxd/XjPm2fFkLcMRn/De+793tVjtZG8l7ZZ4IFsxcJvuWA2Yygyz2fI9V8vE1Fz6FW2bjJgSQmrmp4A+hD3PmjL4WlxSzFQIdzFs8G6xVHU/4MEq8GCZNP5jgkQc9SMHkCXghNV7PLoa+ygWXLYzDodiz2fs5K9AdmkHGvliJASoIKD7AHkEiN/VeLhX5pkROXr6rAqACTNfnN6NIMcPSgGb18lMiG3 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: 在 2023/5/9 上午10:20, Huang Ying 写道: > After recent changes to the retrying and failure counting in > migrate_pages_batch(), it was found that it's unnecessary to count > retrying and failure for normal, large, and THP folios separately. > Because we don't use retrying and failure number of large folios > directly. So, in this patch, we simplified retrying and failure > counting of large folios via counting retrying and failure of normal > and large folios together. This results in the reduced line number. > > This is just code cleanup, no functionality changes are expected. > > Signed-off-by: "Huang, Ying" > Cc: Xin Hao > Cc: Zi Yan > Cc: Yang Shi > Cc: Baolin Wang > Cc: Oscar Salvador > Cc: Alistair Popple > --- > mm/migrate.c | 103 +++++++++++++++++---------------------------------- > 1 file changed, 35 insertions(+), 68 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 01cac26a3127..10709aed76d3 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1614,11 +1614,9 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > int nr_pass) > { > int retry = 1; > - int large_retry = 1; > int thp_retry = 1; > int nr_failed = 0; > int nr_retry_pages = 0; > - int nr_large_failed = 0; > int pass = 0; > bool is_large = false; > bool is_thp = false; > @@ -1631,9 +1629,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > VM_WARN_ON_ONCE(mode != MIGRATE_ASYNC && > !list_empty(from) && !list_is_singular(from)); > > - for (pass = 0; pass < nr_pass && (retry || large_retry); pass++) { > + for (pass = 0; pass < nr_pass && retry; pass++) { > retry = 0; > - large_retry = 0; > thp_retry = 0; > nr_retry_pages = 0; > > @@ -1660,7 +1657,7 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > * list is processed. > */ > if (!thp_migration_supported() && is_thp) { > - nr_large_failed++; > + nr_failed++; > stats->nr_thp_failed++; > if (!try_split_folio(folio, split_folios)) { > stats->nr_thp_split++; > @@ -1688,38 +1685,33 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > * When memory is low, don't bother to try to migrate > * other folios, move unmapped folios, then exit. > */ > - if (is_large) { > - nr_large_failed++; > - stats->nr_thp_failed += is_thp; > - /* Large folio NUMA faulting doesn't split to retry. */ > - if (!nosplit) { > - int ret = try_split_folio(folio, split_folios); > - > - if (!ret) { > - stats->nr_thp_split += is_thp; > - break; > - } else if (reason == MR_LONGTERM_PIN && > - ret == -EAGAIN) { > - /* > - * Try again to split large folio to > - * mitigate the failure of longterm pinning. > - */ > - large_retry++; > - thp_retry += is_thp; > - nr_retry_pages += nr_pages; > - /* Undo duplicated failure counting. */ > - nr_large_failed--; > - stats->nr_thp_failed -= is_thp; > - break; > - } > + nr_failed++; > + stats->nr_thp_failed += is_thp; > + /* Large folio NUMA faulting doesn't split to retry. */ > + if (is_large && !nosplit) { > + int ret = try_split_folio(folio, split_folios); > + > + if (!ret) { > + stats->nr_thp_split += is_thp; > + break; > + } else if (reason == MR_LONGTERM_PIN && > + ret == -EAGAIN) { > + /* > + * Try again to split large folio to > + * mitigate the failure of longterm pinning. > + */ > + retry++; > + thp_retry += is_thp; > + nr_retry_pages += nr_pages; > + /* Undo duplicated failure counting. */ > + nr_failed--; > + stats->nr_thp_failed -= is_thp; > + break; > } > - } else { > - nr_failed++; > } > > stats->nr_failed_pages += nr_pages + nr_retry_pages; > /* nr_failed isn't updated for not used */ > - nr_large_failed += large_retry; > stats->nr_thp_failed += thp_retry; > rc_saved = rc; > if (list_empty(&unmap_folios)) > @@ -1727,12 +1719,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > else > goto move; > case -EAGAIN: > - if (is_large) { > - large_retry++; > - thp_retry += is_thp; > - } else { > - retry++; > - } > + retry++; > + thp_retry += is_thp; > nr_retry_pages += nr_pages; > break; > case MIGRATEPAGE_SUCCESS: > @@ -1750,20 +1738,14 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > * removed from migration folio list and not > * retried in the next outer loop. > */ > - if (is_large) { > - nr_large_failed++; > - stats->nr_thp_failed += is_thp; > - } else { > - nr_failed++; > - } > - > + nr_failed++; > + stats->nr_thp_failed += is_thp; > stats->nr_failed_pages += nr_pages; > break; > } > } > } > nr_failed += retry; > - nr_large_failed += large_retry; > stats->nr_thp_failed += thp_retry; > stats->nr_failed_pages += nr_retry_pages; > move: > @@ -1771,17 +1753,15 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > try_to_unmap_flush(); > > retry = 1; > - for (pass = 0; pass < nr_pass && (retry || large_retry); pass++) { > + for (pass = 0; pass < nr_pass && retry; pass++) { > retry = 0; > - large_retry = 0; > thp_retry = 0; > nr_retry_pages = 0; > > dst = list_first_entry(&dst_folios, struct folio, lru); > dst2 = list_next_entry(dst, lru); > list_for_each_entry_safe(folio, folio2, &unmap_folios, lru) { > - is_large = folio_test_large(folio); > - is_thp = is_large && folio_test_pmd_mappable(folio); > + is_thp = folio_test_large(folio) && folio_test_pmd_mappable(folio); > nr_pages = folio_nr_pages(folio); > > cond_resched(); > @@ -1797,12 +1777,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > */ > switch(rc) { > case -EAGAIN: > - if (is_large) { > - large_retry++; > - thp_retry += is_thp; > - } else { > - retry++; > - } > + retry++; > + thp_retry += is_thp; > nr_retry_pages += nr_pages; > break; > case MIGRATEPAGE_SUCCESS: > @@ -1810,13 +1786,8 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > stats->nr_thp_succeeded += is_thp; > break; > default: > - if (is_large) { > - nr_large_failed++; > - stats->nr_thp_failed += is_thp; > - } else { > - nr_failed++; > - } > - > + nr_failed++; > + stats->nr_thp_failed += is_thp; > stats->nr_failed_pages += nr_pages; > break; > } > @@ -1825,14 +1796,10 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page, > } > } > nr_failed += retry; > - nr_large_failed += large_retry; > stats->nr_thp_failed += thp_retry; > stats->nr_failed_pages += nr_retry_pages; > > - if (rc_saved) > - rc = rc_saved; > - else > - rc = nr_failed + nr_large_failed; > + rc = rc_saved ? : nr_failed; > out: > /* Cleanup remaining folios */ > dst = list_first_entry(&dst_folios, struct folio, lru); LGTM. Reviewed-by: Xin Hao