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 095A1C27C53 for ; Wed, 12 Jun 2024 06:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F20F6B0153; Wed, 12 Jun 2024 02:21:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A2836B0154; Wed, 12 Jun 2024 02:21:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 269DE6B0155; Wed, 12 Jun 2024 02:21:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 08CAD6B0153 for ; Wed, 12 Jun 2024 02:21:16 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A3A78A1074 for ; Wed, 12 Jun 2024 06:21:15 +0000 (UTC) X-FDA: 82221239310.01.1C4245F Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by imf12.hostedemail.com (Postfix) with ESMTP id 2B7F340004 for ; Wed, 12 Jun 2024 06:21:11 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ETgpPwXQ; spf=pass (imf12.hostedemail.com: domain of ying.huang@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718173273; 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=6LP1dpa8LeqO+Mssey2PIWUlSFZtPccwCvF0gP5HdDo=; b=tmXyjikj7UwRXb0phEF1OMLklvYDJUEZRy1FnRp2+lpQDyhHQuXe+zY//RjLSHRkMBqIug 4gqFrsMRoJc3cFLbDCAcOrTLr2geylSJTKKHtXAv+4YLRsUcKXmeCqeXD7KWXFbW06ZDrI fnh+pIHUiqZl7/jvotT3yDv2sr0FQ4E= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ETgpPwXQ; spf=pass (imf12.hostedemail.com: domain of ying.huang@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718173273; a=rsa-sha256; cv=none; b=syEbmBheUKnz6IYOWt3Dpria3Es0ixZ0G5sNSr9//AzPFcMNpRY1tVVcT1voCLA2rNaXRA gBxstwI5LopNJAyal0KDVOelQ9NL0WqkRgil4K/FRRVCaRJX537wFDM42yGbZNESDJ501y d5zS4b9fMQGCAzIITJRsHz357OHA62M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718173272; x=1749709272; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=htK3JGDzZ50RrcVE9SiM5Fksd2VJ/2WYnYQ5LvzPLBY=; b=ETgpPwXQ4yIywmX1s+lpmuC3HBjHj/0Q5F2gr11OMB7395JRxWKJvthS fQSJnQd72wd6pXPn5wM6GjLsjNyjMDUvdZXNY1gZfIhA8cBUFi0jPsiG5 d8kPW2UtOX0OFnthRg0/yJDy4L8DdNkmORqXeei1hicDd+hwKMXAcMPVY 3fGsJrYFIzashBlnLGcJVCBIWqR1V4rGIOVdRJsxHbt2Qs8/l+aXFmWSY PjmHrYIqw/KacJ3xBIHH1nanOCQkNRyrpH3o54FJSLBbMZojOTq3onGwP BT8sLR5KONzJUl6xhMqlKDoaiXiy9wGUYD0rIXxySTw+U8Rq8ZhFC/jP6 w==; X-CSE-ConnectionGUID: 1S9cS2AjS5uL20x0yLHzlw== X-CSE-MsgGUID: E4mwiprcTICWY6pHFU0d8g== X-IronPort-AV: E=McAfee;i="6600,9927,11100"; a="18699014" X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="18699014" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 23:21:11 -0700 X-CSE-ConnectionGUID: 3x1SUSrQSIGBA4eo9xt7lQ== X-CSE-MsgGUID: hNXSG1BbSwK2yLWSV/Ej9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="40309738" Received: from unknown (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 23:21:08 -0700 From: "Huang, Ying" To: Hugh Dickins Cc: Andrew Morton , Zi Yan , Baolin Wang , David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH hotfix] mm/migrate: fix kernel BUG at mm/compaction.c:2761! In-Reply-To: <46c948b4-4dd8-6e03-4c7b-ce4e81cfa536@google.com> (Hugh Dickins's message of "Tue, 11 Jun 2024 22:06:20 -0700 (PDT)") References: <46c948b4-4dd8-6e03-4c7b-ce4e81cfa536@google.com> Date: Wed, 12 Jun 2024 14:19:17 +0800 Message-ID: <87msnq7key.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 2B7F340004 X-Rspam-User: X-Rspamd-Server: rspam09 X-Stat-Signature: bk4mtrsduuudyn94eft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4PGRQOyncoHglZFe7j9iSf7qrW+gb9rIpDAefSMLKlU6VAFcezmNCB/RzwYSPf3dfYtzNS+cnVbsoeby44AbvFix4W+OGaWTtJ2x571oibs2aLLYn5416NC8nkC3/ciGtLU5EErZG8I/EDqCv+ew+EdWuYs3ftwEQyyLA== 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: List-Subscribe: List-Unsubscribe: Hugh Dickins writes: > I hit the VM_BUG_ON(!list_empty(&cc->migratepages)) in compact_zone(); > and if DEBUG_VM were off, then pages would be lost on a local list. > > Our convention is that if migrate_pages() reports complete success (0), > then the migratepages list will be empty; but if it reports an error or > some pages remaining, then its caller must putback_movable_pages(). > > There's a new case in which migrate_pages() has been reporting complete > success, but returning with pages left on the migratepages list: when > migrate_pages_batch() successfully split a folio on the deferred list, > but then the "Failure isn't counted" call does not dispose of them all. > > Since that block is expecting the large folio to have been counted as 1 > failure already, and since the return code is later adjusted to success > whenever the returned list is found empty, the simple way to fix this > safely is to count splitting the deferred folio as "a failure". > > Fixes: 7262f208ca68 ("mm/migrate: split source folio if it is on deferred split list") > Signed-off-by: Hugh Dickins > --- > A hotfix to 6.10-rc, not needed for stable. > > mm/migrate.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1654,7 +1654,12 @@ static int migrate_pages_batch(struct list_head *from, > > /* > * The rare folio on the deferred split list should > - * be split now. It should not count as a failure. > + * be split now. It should not count as a failure: > + * but increment nr_failed because, without doing so, > + * migrate_pages() may report success with (split but > + * unmigrated) pages still on its fromlist; whereas it > + * always reports success when its fromlist is empty. > + * > * Only check it without removing it from the list. > * Since the folio can be on deferred_split_scan() > * local list and removing it can cause the local list > @@ -1669,6 +1674,7 @@ static int migrate_pages_batch(struct list_head *from, > if (nr_pages > 2 && > !list_empty(&folio->_deferred_list)) { > if (try_split_folio(folio, split_folios) == 0) { > + nr_failed++; It appears better to add stats->nr_thp_failed++; too. Otherwise, if migrate_pages_batch() is called via migrate_pages(, MIGRATE_ASYNC, ), nr_thp_failed will not increase. But if migrate_pages_batch() is called via migrate_pages(, MIGRATE_SYNC*, ), nr_thp_failed will increase in migrate_pages_sync() via stats->nr_thp_failed += astats.nr_thp_split; That is, they are not consistent. The issue exists since commit 7262f208ca68 ("mm/migrate: split source folio if it is on deferred split list"). Otherwise, this looks good to me. Thanks! > stats->nr_thp_split += is_thp; > stats->nr_split++; > continue; -- Best Regards, Huang, Ying