Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp221027lqp; Tue, 11 Jun 2024 22:06:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUuuK4+hahfoZdxj9788xItR5gofI1nStfYQOP0pwTdwvVlQrBJ+fA4TVVNeg675iyh1KTF6sm70a4R2zFCxcmLBhde25/YMOqVKceSlA== X-Google-Smtp-Source: AGHT+IFjN6/YKgiT1/qGtqh2PGTMnVmRXeUC8QdPXc9lNSWah8BTRQJxm1zx/dCKihsJBu1tj30P X-Received: by 2002:a05:620a:199f:b0:795:4988:79e0 with SMTP id af79cd13be357-797f60d9595mr81483585a.50.1718168806345; Tue, 11 Jun 2024 22:06:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718168806; cv=pass; d=google.com; s=arc-20160816; b=yyRCEvAdoEtQoU8dDgn5QIEvM9NY7wIopfLcosu4LPRx6nWuT7teQ9WDM+AhSZw8qN 2uYOhLrZckLIo3ivAUnGy/z3rvpAmWRuskb/E4JXs3FgXAeNjvbqhrd4aOhRitlDNYbp AeBoT9CXb3jfpgrPh+ws7v1uYRSj6KOOSw7MtNuvJGCXmVAJEicRPMfOByAd9NViXJxL vMiHfdoN7IpPeG4Hlee0mAX5uEdMzfEx3/gksocmFfWpPWXDWHX6YkZd7/Z09eJu5wwq mYWi0E4Jdrqrcg56fGmZZ/SOnV1HOWpOd3gsfzAtr4MmkfuALeIHBYCqMGa14GREq0m+ wIIg== 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 :message-id:subject:cc:to:from:date:dkim-signature; bh=AZZ7VrGQ5YNuXnqr8Kq8rpi6ACseFS2im/RkA+OveFs=; fh=VGjvMXGeL10uKWRSYssKDYPEIA2T2WoEsUq9qQXHQXM=; b=Ng65IpYu+SQ8jVdnWjeHSLQNDj5L0aR7LsaB28YFlzIb8aC9huxX75R+dnWXx0bQA6 m6+s92rlPqKhXZY0iLmPimH5WB14ZzIzpWnp7Ny/dQdB6DS+UUOyVob1tcTFcfkU3Z0/ Dcs9c4unsAyWekOMVsDvkEwzXzrO9Xe4LXTjcQIsYtx5T9GINRvPxATY8FsPvodeQ+/b ifeUAiY6Uap6FWwZUE0Vmg+C21BsEfrnnlvoPSCa62VVNV2F77/sUfqaT0DQ50+qRvjm cQp6NcAChVtwWL/EJRO6cPswsodGpdgslqk8fnc+skYGE1xxv3B9Brp9AEe2FMZT/EIZ Go9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VK6KZBJZ; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-210931-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44057324bc8si94049741cf.95.2024.06.11.22.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 22:06:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210931-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VK6KZBJZ; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-210931-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 132341C21D04 for ; Wed, 12 Jun 2024 05:06:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 981612D60C; Wed, 12 Jun 2024 05:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VK6KZBJZ" Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CC262BAE3 for ; Wed, 12 Jun 2024 05:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718168799; cv=none; b=rY1Y8yFViN5rK+5M8bmeAI5AzOT+oAcAhfoP8XI2FBnRizkkiXLG9tziI7FUUw8t2AhsnlRYFVPv8I2nAWidJFHmJ5q/8dsz9nVgTjM8he341pcgSKJG5Rz9RViZEpYvJZjKWFtjFCt9uTNAXMEHslMVZ8kLp+pAuY/d7kZnYN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718168799; c=relaxed/simple; bh=Vm+nM0PHiki+y35zCKm3VLSuncQiDq60EnZ8SU66lm0=; h=Date:From:To:cc:Subject:Message-ID:MIME-Version:Content-Type; b=Xl5yD98hQHlzXO1SGTO6MgnNX9zAJbG5MFqNpJbIrqnuI4wpIMuP2sBckZ7XmbsEMQUoiM0a5cy0FcYKj0CeEUQX2k7IuDffACsG44JS8PYK2SHuTQstK/t6Wa1xg7qQE+KMWTnopXuB0O0iM7Vx9Ifng1yKFji84ACIEmbWla4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VK6KZBJZ; arc=none smtp.client-ip=209.85.167.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3d23db75f5cso218975b6e.0 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=vger.kernel.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=VK6KZBJZkRRojZRYc0+G8TUj3gch4W4utQMWZMW9UlEIqwLGAC8ai9DZ1jJIKWhtLB 0+UII+bf8WNMu3QX8lYWCm0n1SsIbXFmujMWBy+E5QYcbQMJ0T6w5+L8mWV+bHbCZ1Ef YRJcxfjBZXnpZezhSEPMlQAB59lLbRKKBXEEZedKlhIPzbgZyyP31uTKjWO7egoRXrgA s4sRpItwLTnbto5HnadBPMoh4M0A78ojGMxKcIN10xuTkxME5dQCRz4Lgl9t6wf/Z215 19KRveLaw8/mLhr0/Ky7f/aZCsDVtWMtg/AhgBJaO6CZfu/O+whY8JoY31ewL9xPROeT ThAQ== 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=RxmypTPG5JrEVbbr/wR8BQlb7KeLz0b6wv0PmFzZLY5qQ7YUnb6gkP8qcViMoW6bbJ JjUAhx7cwk4E7lZaWojLl1/HMgIxmlL6vicm88qmzD518ISEmSnTqjud8nAWWdw+Kign LRhg4T01lcxDCfaOkge6efJBv8QgAR2+nqeYFi22DyH0OzfFTu8MwKBIpQhD1RGlcu2U rnJCLwoqgcgumyJUBYWJc2Uae18dRAI0NYEGOePvCUjdRFGPo5RqXKJ35R8uVsrqq5JA mxgNf1Ame1SlDJ4YIeTSTW100euWBeSyzu3/ELAVdC+z0OeLJMz9NXIdVfRYEtES+LCK czLw== X-Forwarded-Encrypted: i=1; AJvYcCUi+JtJVZNtdNGeFKcuBe0xcE8lrHo6nNxS7oIXbXtN6E2Iys/UsZ7VpH+fK3PbOFsfioQ7T1+ZpcvNho0oZfTXJ5W/pwJq1h+cXR4G X-Gm-Message-State: AOJu0Yx/ZX2rEv05eyrLA5d48g8oqwyh34Aqq4t98piR6lJ+zZISBFu9 /nNcAXC87sqtj+Y2s7pL552jiCIt/I3Gc7YZRn74EUai9TJ0dtloV5KaWLLTKw== 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> 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=US-ASCII 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; -- 2.35.3