From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 678B0371884 for ; Thu, 19 Mar 2026 23:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773963057; cv=none; b=NVaoV6fvLndITkyuZ9oXVFtH8Xw55bPAHs31pp3VvxQtrYsUIqmOBaZuEdK5Z6a1m4XFGTpHdFxFyA0uH5CpdiAN3Q7k5aAvDJ3fsnZ6Xmb0olqjhSIYnLoCZhxHDtkxfozCGeBnHBmjMQp5t1zTh8tM19PSezFcjTmzy6INzRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773963057; c=relaxed/simple; bh=CZuA2q2lMteTu44UK74Tv+Gl9XkYvploUKv+Q7AJ1Us=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=tEagMigcKYu3qW51SgXIj8J0JrPlCgfJCrC2LoMaFG12EunA2TAHg7ouwy/XKbNx8rKWb7tNUocPlCptCjWgNgbfm+5vzOBzHQ0NOwXddVW7CZK11SGrdTWRhL3V/r2EGUjtoYRy//VSQ0RkIhQRWDTNwbNihFmi2r+VlsBNtPM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wyihan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fXoUcC8I; arc=none smtp.client-ip=209.85.216.73 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=flex--wyihan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fXoUcC8I" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-35a032cdd78so7692059a91.1 for ; Thu, 19 Mar 2026 16:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773963055; x=1774567855; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=yCIxwFZ47k6gWbx57q3bhruGtmGGBP4Tv/5VwuBdu0A=; b=fXoUcC8I/hiFAgr6fSop0cQgjdk7Rey95UBBUww3AiT25mdU38z/k52uDG/LLKJVQ6 l6hFwDM6Ieyb13cuYlSkRO6hrkvzO4d6EDgta3ANhPAVlid6BUMHkZslQwBt80Xfb0UR lf6YNkVTtNlk8Ortasz1eKqZwpgNxAe76BYjwqskyyTSV88M+K8AcQsB2UAdhUv7Uopc bxyu1DJcyygIoEojg00JdDhepp4nba8hGoLJBHVKKCd0C+8ilItpRSCiy3CV61PeUhhN CvqWAhJUKlv0oiG2TKsUb2K9lK2ktg79oAbFWcENI1152824k/FXR5eCfLf7tlW7yPgP +7FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773963055; x=1774567855; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yCIxwFZ47k6gWbx57q3bhruGtmGGBP4Tv/5VwuBdu0A=; b=a4UPD7QzlP4oO1Ylk9esO1THju+f99ruAESRzya4AqzY2SGoLGC+RwONtEa0lySZ/O g8Yd6x2JNM2DGHbgnKDpgWx/rVvVvJhFMGIZqwsFx7hccwflwYn33eeMRiXuvqKg3+fl ImbxgjJtvQimbZsAoKTnLvUKiYV5GiZqykaPLl2l0Nef9cuNY3VFgIJp4lznrAitcxcJ vHxl0xNNrYhcpTjxIWHb2C+Ugev9yX6b4f+mYg3RrRSoqUeasjJiyKZCEJRvrt6vnbT6 NIUbsJEuFxFLaGIkIqNCqO9e7pssmrrmygC+40qFv7KBoogZ31WoVg8+PJx2KT0mssNI I3hA== X-Forwarded-Encrypted: i=1; AJvYcCV9IAIianu5lrZccR13kVBvNmxObFfZfI9PJDsGgEXUr0T6BnH24P6hBlOczayMcMo9uR1JDdTMtBNFNUY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw72YQWmwod18UZI3uKN+nMzWv32My0IL8T0QOx6n8tcf+f3VwL Iovf8lB7lKtOPCWajCDbpIKAKTHAMK/Oj+t47oXNWAd+ZrE5FXkYa6gDwoxMuS7oppZFeDQgdrk kVdbPPQ== X-Received: from pgww9-n1.prod.google.com ([2002:a05:6a02:2c89:10b0:c74:42:8993]) (user=wyihan job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:3d05:b0:398:a6d4:dbf7 with SMTP id adf61e73a8af0-39bcec2990dmr884293637.55.1773963054511; Thu, 19 Mar 2026 16:30:54 -0700 (PDT) Date: Thu, 19 Mar 2026 23:30:27 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIABOHvGkC/x2NQQqDMBBFryKz7oBJqaXdCj1At6WLYH50wKhMq FTEu3fo8vF5/+1UoIJC92onxSpF5snAnyrqhjD1YInG5Gvf1Gd344w868YpyPhRcE4cMYYNkZN 8WVPHq+cL4FxswtUksqtFYes/86Lno6X3cfwAHAkyQXsAAAA= X-Change-Id: 20260319-memory-failure-mf-delayed-fix-rfc-v2-5ee11d6a7260 X-Developer-Key: i=wyihan@google.com; a=ed25519; pk=cRi0fKzS5BMxlHyHY2pJv3w/1zcgfYKr6EYGYppdMYc= X-Developer-Signature: v=1; a=ed25519-sha256; t=1773963053; l=2186; i=wyihan@google.com; s=20260319; h=from:subject:message-id; bh=mpcY4kRf+nPP5p5eWgT3Y1evjSbcjRoF+f54tj5v7pY=; b=mWnFvQ5ui3ggdbSI/gbCZaSWpVcU5hlhGvSATXtAyXZwDfjEUhF4BWK5E7B5/5PQNCDI5xSiU xIX5xLfd+SSA0zwnDrFuPU+talg1mimDxNRWM7dNEzT6Wnry6w6Sa0M X-Mailer: b4 0.14.3 Message-ID: <20260319-memory-failure-mf-delayed-fix-rfc-v2-v2-0-92c596402a7a@google.com> Subject: [PATCH RFC v2 0/7] mm: Fix MF_DELAYED handling on memory failure From: Lisa Wang To: Miaohe Lin , Naoya Horiguchi , Andrew Morton , Paolo Bonzini , Shuah Khan , Hugh Dickins , Baolin Wang , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: rientjes@google.com, seanjc@google.com, ackerleytng@google.com, vannapurve@google.com, michael.roth@amd.com, jiaqiyan@google.com, tabba@google.com, dave.hansen@linux.intel.com, Lisa Wang Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Here's a second revision to fix MF_DELAYED handling on memory failure. This patch series addresses an issue in the memory failure handling path where MF_DELAYED is incorrectly treated as an error. This issue was discovered while testing memory failure handling for guest_memfd. The proposed solution involves - 1. Clarifying the definition of MF_DELAYED to mean that memory failure handling is only partially completed, and that the metadata for the memory that failed (as in struct page/folio) is still referenced. 2. Updating shmem=E2=80=99s handling to align with the clarified definition= . 3. Updating how the result of .error_remove_folio() is interpreted. RFC v2 is a more complete solution that includes parts 1 and 2 above to address David=E2=80=99s comment [1]. Selftests are included for all the abo= ve. + RFC v1: https://lore.kernel.org/all/cover.1760551864.git.wyihan@google.co= m/ [1]: https://lore.kernel.org/all/91dbea57-d5b0-49b7-8920-3a2d252c46b0@redha= t.com/ Signed-off-by: Lisa Wang --- Lisa Wang (7): mm: memory_failure: Clarify the MF_DELAYED definition mm: memory_failure: Allow truncate_error_folio to return MF_DELAYED mm: shmem: Update shmem handler to the MF_DELAYED definition mm: memory_failure: Generalize extra_pins handling to all MF_DELAYED = cases mm: selftests: Add shmem memory failure test KVM: selftests: Add memory failure tests in guest_memfd_test KVM: selftests: Test guest_memfd behavior with respect to stage 2 pag= e tables mm/memory-failure.c | 17 +- mm/shmem.c | 2 +- tools/testing/selftests/kvm/guest_memfd_test.c | 233 +++++++++++++++++= ++++ tools/testing/selftests/mm/Makefile | 3 + tools/testing/selftests/mm/run_vmtests.sh | 1 + .../selftests/mm/shmem_memory_failure_test.c | 98 +++++++++ 6 files changed, 344 insertions(+), 10 deletions(-) --- base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681 change-id: 20260319-memory-failure-mf-delayed-fix-rfc-v2-5ee11d6a7260 Best regards, --=20 Lisa Wang