From patchwork Wed Jun 12 05:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13694422 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 8DA19C27C53 for ; Wed, 12 Jun 2024 05:06:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1A7D6B0141; Wed, 12 Jun 2024 01:06:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCB526B0142; Wed, 12 Jun 2024 01:06:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C92376B0143; Wed, 12 Jun 2024 01:06:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AAB046B0141 for ; Wed, 12 Jun 2024 01:06:40 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 252A6140FEA for ; Wed, 12 Jun 2024 05:06:40 +0000 (UTC) X-FDA: 82221051360.26.4D97A30 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf22.hostedemail.com (Postfix) with ESMTP id 713B4C0014 for ; Wed, 12 Jun 2024 05:06:38 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3hskcSpj; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718168798; 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: references:dkim-signature; bh=AZZ7VrGQ5YNuXnqr8Kq8rpi6ACseFS2im/RkA+OveFs=; b=Msz6M62/sfqqxTYKxks2oo1rWtyvhVWE+/IBhs8zDQeV1Fu7jEiNw47/jjn5qZH0bOeojQ QiKnnijrB1r35ZW7S6aAvidVKcKbf1nTEpsqYrx3WxhWwXHfq0GSiZ5QFeZbSnyN92EGi7 uH/hCljN8DyPgJUZ29qo6adKRBJxo3w= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3hskcSpj; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718168798; a=rsa-sha256; cv=none; b=iHVSnNkky1ahD5CQf3fXRcZtWzgvQR04UoEZIJRKp2NanIruX9Oa6eLTz/YXKKvPCMvj3M pAXR/ok0RhYX0olPr3MGp/YdfEVeb4jjjf0w1pNT0pBC1EUsj/sy6UoBLtjEyELDTNDqht sxF8nKkGzrbMSyPq1UeGacZ8FVyklRA= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3d23a0a32afso573180b6e.3 for ; Tue, 11 Jun 2024 22:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718168797; x=1718773597; darn=kvack.org; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=AZZ7VrGQ5YNuXnqr8Kq8rpi6ACseFS2im/RkA+OveFs=; b=3hskcSpjijBmOf6yek8Sa7byXR7cjj3cpdx7aBeo+jc77hqdDhma62+VQgI+t6d+fj pi2CD6a4ex5VGUlr2npsJ9As5Ds+oaxHgS3+4Q9rvGuycpyNc1S8ekQzD9MAQdJSHAcX avIZEtVzrvLcBwZR27EmL7ProJJNml6X+psAoB9Irm2Qv6Y70Bxja+x2G/ruas+d5Ras Z+WYUG2zHk4raQIevP+fQcsLB8KCq+eR2QlblxObf1UggKQSAgFqLLbyC8P7IBY86fXL RATm/aux1zF4l6Z2gIm4wYaYxeWzeCowySqN/yaQSy0jOVbE4WzSjK92PZ7sH3QPP71i kHkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718168797; x=1718773597; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AZZ7VrGQ5YNuXnqr8Kq8rpi6ACseFS2im/RkA+OveFs=; b=LHHMvAx9E4TlaV/dbaDbsSfZ78g1IJ9D6MWlNyttqF18EBVzwMKS29xO8mwxyWCVyZ xpevwUJKKuFqDwn9n0dmgl6S4vpNKOo2T8ocUaZcmH1TB1eHakSKww0E6xVH1H8flXAj Vmc4f0m4p+EnRWE8cp3BN8D2z7MC55YI1iUeJ7VbjS8eQ4jJxX2mXmZrRVeyeImSES9i //73vvHJrtRI0zScHt14frxUqhy74EAXz+6gHgHvjLlmp9U/8fi+p0K0FcSJsxj/G3Ms Ioyj3cGVGvcFFyLQ8/+/FR10g+AxEgjbnrda5f3kbhFb9dfDFrVbYlqoWNiBgDlHnHTD OXpg== X-Forwarded-Encrypted: i=1; AJvYcCU+SYUbt+F2nb2+ykZQTrrUz01NL33ZoQEqJYACPVAbqpVc+JbmLG5HdYm11c292vz+MA/rUIBDwOqURooqbdEb0iA= X-Gm-Message-State: AOJu0YxSS/Id/nBxwTzPpKgBY0mT4cjPFw+BSzLrsZC6mnWZrJtGS7bZ yayYtraV87kez/dfWC/3iGq5nmaW7GhGwn2qCaDkIJRjKswa9fC+yz3bHcKSQg== X-Google-Smtp-Source: AGHT+IFMUaZ7yMvSMqeufNtIAUmrLen16Bxl7XyolcQW+Gd83s4MP2Pt4VowYhFv9QB0nNaBqVxjCw== X-Received: by 2002:a05:6808:198c:b0:3d2:23b6:de9e with SMTP id 5614622812f47-3d23e0f4805mr925698b6e.58.1718168797097; Tue, 11 Jun 2024 22:06:37 -0700 (PDT) Received: from darker.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3d23e9f1625sm90319b6e.15.2024.06.11.22.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 22:06:35 -0700 (PDT) Date: Tue, 11 Jun 2024 22:06:20 -0700 (PDT) From: Hugh Dickins To: Andrew Morton cc: Zi Yan , Baolin Wang , Huang Ying , David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH hotfix] mm/migrate: fix kernel BUG at mm/compaction.c:2761! Message-ID: <46c948b4-4dd8-6e03-4c7b-ce4e81cfa536@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 713B4C0014 X-Rspamd-Server: rspam01 X-Stat-Signature: s3qorhigsqcrebm4iqxgn6cd3aeots4p X-HE-Tag: 1718168798-421650 X-HE-Meta: U2FsdGVkX18anHMHOWH+NdfgyMhUU+O9Y+kCliQYjX68c5IuoVNc7s1WXH+MDXA1e566a0CnDG3pPEhJGaOT3SrQx4VBZvoktb1JrIKQA4pZtJqM/8xRbU5yDkQXYwlBRbHmOrltrwhwgTUJReRR2CRCM44nK83gFm1SZfM0K+zEnDi7YQiWiHTmudV0XlqArv1+U5GRIcw3gn9rNQZUmPu5IyJLkI1b+mA46Y7zFnH20XSQT7dSUKf4DBQRyJkKKQuuiBkizkDevbUJqzSxr4k5uSuvWMkGUfqbEZVgDrIjiHjw9CAVoPGVLwCY0YbgQiLHQC+MzYmjbtgjSYKM1wm18cbMt7KX5c74Csng/FqzMsLfksX+LzTljU2/1agOoHoPP9KcoU/Sjfzh8TEf+HrbeGu7LUtNNS5yBaVU+YRMSK8P09g9tABTzPOYDY98PI3/voJy/+fL4LAC7Qscd257ag7jlYH8DMHn2SXq/M2dxSW0UmvjElrR2cc3zzb0Wla/YbI5tjNhTEXQ7toBKoUi7XFra7a2lLSRQsei4iRCynR5lsNaNSQp9caKUKADC/zBlsnsQBDIZmJkkPqnkjNQAQOMyBKl/cOb8pfldsHOXYmYVhkKd3QXLr1RfeOVC34prCtDYVt4lB1ln2TbK+yj7++LGbcslIDYsihFOIQwWf4coyZNx4nq24Zbcy1yQqrXhn3J1QvT+zYKu4KVsqjmeoID7Ccs1j+GF3IHJ+K8wVm47vWbsqNhEZUxOf1cL/Fn0grbiBUqzcp7lci8b1avZeTtuurGCRHjvDo6M1+ukiiAw1n7BT+b6GkpEBnEohEF3e1hne+NYKvzXzBFKl1+7qi8HSlptP2EqN0QBlo3fzGAKy2BsKuGdfgvy14fyA+xfZLz/WSVqobq6qdzQjYeWY4R6pUmUnjGwE26ntup4NnABxsYGfg8aUyPkjVVntN+Dc5rAsReRsWLogA 29di5+hS Wj+C7TLZk7amIpWRWVNDRjoZ64yIF+PyTfu2ZSnYQeE9Sa6s9aHyIlQjyp4B1opBVCg0MjbOKtxo4qx6+ph/Kd0+UaydsPrTwhsxEdOpRplsydCtyVS7R/8ZAaRsMobimP51x12tK4a7v0eORCv68jStMOjeGzH4LBmxKelVE5UcvvCWxDnP6gXy7UO9S4KD7wmaXjeBSUhY6vz5+iWLE5l7zisrb8PWCbEyFKqNfqrosdy9zKeahfD6SzF45fbe/WjkHxewyiG5uaw8QGAn79qTGnJwCuXeWAeieprUEmHFD2094bZ8JASRWTb73Cfu0kkmOYhZ4QNg9dPQqcQ0JWTZCfg== 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: 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++; stats->nr_thp_split += is_thp; stats->nr_split++; continue;