Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp244482lqp; Tue, 11 Jun 2024 23:21:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzVIK/N/W9dstJTrSqrC6JErSS4XoBQzsWVp7jepNTUJT9h0HBJLzYm1lIAhaKkyPfj5q6MhAx5+84s1El2YqnJpA3C0S0izOYWZph1Q== X-Google-Smtp-Source: AGHT+IEgnAb8vDqxbOGLBpcNjD8g014XjI43a3GPxMJMcr/fmUYkJxC3Q1kjgrayIQKENmWiTtLo X-Received: by 2002:a05:6359:5f8a:b0:19f:3355:d300 with SMTP id e5c5f4694b2df-19f69d88c02mr118260155d.25.1718173280605; Tue, 11 Jun 2024 23:21:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718173280; cv=pass; d=google.com; s=arc-20160816; b=UiO3M628J1XWKj33e1TJ0vp7qhPYkAGof0LUtImo5qWm72MRu9plhtFCfqU71L/RlQ te6Oe2Vgmv1LBOJF30gUqbTrN6LhC/KBI5Y+MZ+KZwWHiNqWQpowlGJi5vc94pejScGx 3iExvHKS96cWArxz3v+khF/B3083JfIzkbxCqnyn2vG5UYZ1VHronYepxaggoSBM6V/4 CzeGvf8AmL2vgcxp+IvocPCOMHEQnZ3ojAHpQeZy3+4EPZ7aQRHkDvdkcp/IvCfakkLf X9+rhPjs9d5YfUOcpp3xGqKt2gNDR2JqmNvRySMa4ce1enMt0GUc3PSNHrlkdLKxvwCq Uo5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=6LP1dpa8LeqO+Mssey2PIWUlSFZtPccwCvF0gP5HdDo=; fh=ZP67tLX2c/Y0yCvApKiLHPUKxc+MCwV+y41JcYasBR4=; b=ypsrct7SMT6EwHK1i5bR/FrV3AgIFPXJupHNlDfGDM5Z78MpG+9ltYykw1kP4OpbJn fJQ28E1HrM510nk2cdfTPO/MtJycwVsouzd+epjqinVarK2FMo4CBetGfe/PBQPPGdi9 r4qr1IQfRvXZoCK760dnEFesxjySpxSTIoCRVx1O8sPM//e2KOAysrq/dk5+rKS0oKa2 yqtPStsIWsyphDtbPRxv/cxrB7VYEjQfXyDbDbiwR3++6dqIdOCZ7w38Cpuwjp8TvUFU VrHOYcBfZ/r2Wc92KWYC+SpsQrtsW0LwdJBaONof5szQqa94RwHJf7a956RgENX+xOfb HYqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kLncFwkN; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-210971-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210971-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6f0c54ef644si4874317a12.595.2024.06.11.23.21.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 23:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210971-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kLncFwkN; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-210971-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210971-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2F491285271 for ; Wed, 12 Jun 2024 06:21:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16AFF167D8E; Wed, 12 Jun 2024 06:21:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kLncFwkN" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A34913CAA7 for ; Wed, 12 Jun 2024 06:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718173273; cv=none; b=Sm3dJ5QAHMxAVSBNHMQGCMY2Z7deRMqhe1oE99mKwXMnaY5p8wTgw2+BAPJzvBcEGORgv5pnFke8qj8uXvq1HYYWBnZyaYToM0EVkQru3zpBKzcMzM336Xi/IxrkyeBigsJr+N6qVUAK5Mcl2sLM9XYlcfC4ZsH5KinhwnsuX5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718173273; c=relaxed/simple; bh=htK3JGDzZ50RrcVE9SiM5Fksd2VJ/2WYnYQ5LvzPLBY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=sdqqO5w2DO6GA8v3ThxbyMvTG0ij0UZ6XKxAGogjbYtNWyVEMJvrpjTlHWcfZkrvDmW31hkBBNL6OVOJNTPKv8EdWQpX8e7ucoIMHTfntIi+BjtsJvHvdFnr//wA+2yIwvo2gPcWMO2+9GSmXkEEWRWEyJqKvdNAgF/2xj5sclk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kLncFwkN; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718173271; x=1749709271; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=htK3JGDzZ50RrcVE9SiM5Fksd2VJ/2WYnYQ5LvzPLBY=; b=kLncFwkNMl35aqXeCr+1JpYz9QEHENNWCpZLJUmSo145BvSbGvImc0kK COMJqDUie5JDgyJkRGn3l9aR/9sN21/EXhIdTSzba+uT7TgI4019FP2lD IE+gsz+uWc3f7Xsu4VNwolw6v0w9JiApSHe9kgwjcuG4twJbf+MHBqa/j gsGHcKLsPtRdoFIigPeySHx5JiOk82H73FhgtROZVrTg/7bojYFHQ5DJh BjaI2ESq0aYB5A3CMtOxaYSK+o+ZmSs5fDLmZh7kwFepqivr8xoIcQiLI j4YS3u1/g++l3I2ajgCUS6SukGVhrLgqtPvXrqh7iZQXi78wx5zZkCw1H w==; X-CSE-ConnectionGUID: TWKm0amRQde7OHOnmPZdLw== X-CSE-MsgGUID: Me833cOrTFCgzBwD1UquDA== X-IronPort-AV: E=McAfee;i="6600,9927,11100"; a="18699012" X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="18699012" 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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