From patchwork Tue Jan 28 06:34:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sooraj X-Patchwork-Id: 13951691 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 EE7BDC02188 for ; Mon, 27 Jan 2025 20:04:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BC582801A3; Mon, 27 Jan 2025 15:04:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76C26280191; Mon, 27 Jan 2025 15:04:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6337A2801A3; Mon, 27 Jan 2025 15:04:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 44B08280191 for ; Mon, 27 Jan 2025 15:04:12 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C50868064E for ; Mon, 27 Jan 2025 20:04:11 +0000 (UTC) X-FDA: 83054308302.29.E75600C Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf04.hostedemail.com (Postfix) with ESMTP id E8FE440015 for ; Mon, 27 Jan 2025 20:04:09 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aimIDEug; spf=pass (imf04.hostedemail.com: domain of sooraj20636@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=sooraj20636@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738008250; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=mpUBksx+Od4rjGlM5vVhLtN/e7bh755xf45LIMhHf28=; b=cdj1V2i5EBhJ6Cv8yzY1CKZcR8E7gNZthzkOgIK2L2KDxuPtFQIgY4bC0TjkXrL2zQgPY3 /Z3loT0Ss+PmrEzdKfXWfT2BRzzZ/gDuDSqa/HnI9qiJ1wffF4ywKnH+IOhGpMHmRitGYt KAK5m4oH1Mzjh0KC+DQJUSlsqBj7t1w= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aimIDEug; spf=pass (imf04.hostedemail.com: domain of sooraj20636@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=sooraj20636@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738008250; a=rsa-sha256; cv=none; b=y2ICmRuovTvsfzTCiB7cKgYsqw7riFj+qXEC0tQqZaeSe6ctJxWbn3tiq+hFgz+L6RxgtF FZwWW96EBrymTuaifgWZ4G1YILxVT/Tx5++hEaVaQjyaAN80MAhU0lIEWswOJYO5Vd0FzY Do6TkH6D5HFRVTngNVSxrN3H2kZkVAw= Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21649a7bcdcso81626515ad.1 for ; Mon, 27 Jan 2025 12:04:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738008248; x=1738613048; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mpUBksx+Od4rjGlM5vVhLtN/e7bh755xf45LIMhHf28=; b=aimIDEugxqK7VjTs+5n40vzwpm3QhPTRbWHwlWJGxJamIQ+kPc4FMB7x8GmxNHEY60 H5cr6zRaG3zlFYayVbI/KZNv3okD8UkUmhWu9AluGXGufJGZ/JE4AcGpPOzJurPXHtzy pimv/81PzZc1XNsE11QLSifpiHe+b4ZhbmYOgosTt9w4ow9ExUlAd+/DCVvAdhf6DX7r 0IqTQCaRORUtx00KIZghl3GSmyReImRzkH71SLN1NV6T1Lrs5vUPgT/p37WqeYAF6k3c oTuStr8VbYYkzP9sH0RB7FkUeueeb7GBuUbSBhNq2xCd0hrGS0d9cAlDkOfxyqJhPg6Q 6Avg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738008248; x=1738613048; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mpUBksx+Od4rjGlM5vVhLtN/e7bh755xf45LIMhHf28=; b=cpPu0Md0mJbigaAHa7x98af188eTKSRGY7aDgqZLb7yQIBwDPjdc+CMWFuzjMWKPPf gd5j0YWHxxyuNs34dhjJbyDY88pbxu0K5SQwyyv5QwiEotBkwAAikJHU4plv/6hvl5hG Qv0bnC5h3PVcGQ5XA2ZuUNMAV3BUspVsbVszaAFmJTu5FQioM+IJ/llx4ga3NcHABYCs WQSo/5a4OhqNp2maEDf2N/P7Xc1E4KX1GXoY0Wcai3HhfIoCCTmQA88aZiYSRJziN8V3 CI1IYYgi1IMzkPR/id1QqbQTT+aGC2afAMvPg9FbKPeCYXwRCw+Xe5TAUpcJKADB9QMx DjtA== X-Gm-Message-State: AOJu0Yy8e2xNaclPoARY00T+fOCI9YMh66vWu8Udz+4ChO8H3CupfdL+ SePCqQ6+vZgZbINCUIhgjr/aO9RriEuIhLcajBRIdblOlDvF3ZBBGeKZfg== X-Gm-Gg: ASbGnctjAlvK8IFV2+ylaHy4bz2bSAIsk3y2iBAKL2FAkSbyPz+rLr++GQQ9GQelua4 onBdCZreZZH04a68egV1beby8PYqvWYRUhdqM+l8Ot3buuRP9qyRuxn/QfbKmECGzfAP4WEjIEp o2AUZF1TkyAH2BjNqxQy0WWhMgCv8/bdRxH6t6IAurTHiAfKBfPhoLaxRdFuLOieH390aWQ1f0m GAjwgdXMa2p3ek9n25XFYllXfkoiuyfiE2iVa/if3Y20/CVgZ5w2q/c/iZqn8ldzaP9ry9HHQ8i 3iGM X-Google-Smtp-Source: AGHT+IGWB9c0H06NcxwDvFahGogdB6uc59KKDKmpGSIgoHuwFcDzulvC2WTY4zibgx3A9Sk7kazp/Q== X-Received: by 2002:a05:6a00:1954:b0:724:f86e:e3d9 with SMTP id d2e1a72fcca58-72daf99ed20mr55099507b3a.14.1738008248149; Mon, 27 Jan 2025 12:04:08 -0800 (PST) Received: from localhost ([112.133.252.44]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a760b1bsm7846106b3a.95.2025.01.27.12.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 12:04:07 -0800 (PST) From: sooraj To: linux-mm@kvack.org Cc: sooraj Subject: [PATCH] mm/hmm: Prevent infinite loop in hmm_range_fault during EBUSY retries Date: Tue, 28 Jan 2025 01:34:22 -0500 Message-ID: <20250128063422.7604-1-sooraj20636@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: E8FE440015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: zh997j9hag6sutwqeon6dcmok4n5xian X-HE-Tag: 1738008249-386400 X-HE-Meta: U2FsdGVkX1/2szBGfyrF1cNv5MEXrEvpAo/Ov4gxxFIYgWMwoiO8QPALT9TUoL0EGSnflh8UTotN44xgnV0YwStdo5seHVGwgOiNH6aXWgeEKubhFiVhGuhe1sr4MO69Txsh3m8ghcG0ExjM6PqHUYxZDGKC0vVRnbNl4RwfkWe5E5BdSwWeUin7joIV1yipbUzfZhaqO13+vgpgj3JMxbfwjL+gpB7Ozh1ab0cTLCQVkkcwHnKaziulCbrSobe2021UdB+JgjbO/C+rfEwdRsUd+k0in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YkAo7uqZaQW2ur0GzQ1rgnZ9jZCIPmysqc7l3sB0rAIHxCdPehDUnvoVus2mugKM5ERaaqNln2rKCdtPFxMCMm1PEk9nmRGBJQ/Ij/+Ys7dmjkuEcSPhcVX2lV4Nxpd9hoLkkI3kxUBSaWV4cflfdbjAbn8X5YW28HCPF/+Yuw7A0VS6GbLGHsQaqx4VqeNtfaY8sYaadto+GydcJG6+bsKF7ivw2O2/fZJSiKxK0cn6RpsDPHlXP01zLs+MLwQZlHbo+TuKWI9KAM+GR15cHsScF4s/AUmsWQ0srXweLU8y5rh843EbhMJcPdEaC/h2kpwinA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.100785, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When hmm_vma_walk_test() skips a VMA (e.g., unsupported VM_IO/PFNMAP range), it must update hmm_vma_walk->last to the end of the skipped VMA. Failing to do so causes hmm_range_fault() to restart from the same address during -EBUSY retries, reprocessing the skipped VMA indefinitely. This results in an infinite loop if the VMA remains non-processable. Update hmm_vma_walk->last to the VMA's end address in hmm_vma_walk_test() when skipping the range. This ensures subsequent iterations resume correctly after the skipped VMA, preventing infinite retry loops. Signed-off-by: sooraj --- mm/hmm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/hmm.c b/mm/hmm.c index 7e0229ae4a5a..29e3678fede5 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -547,6 +547,8 @@ static int hmm_vma_walk_test(unsigned long start, unsigned long end, hmm_pfns_fill(start, end, range, HMM_PFN_ERROR); + /* Update last to the end of the skipped VMA to prevent reprocessing */ + hmm_vma_walk->last = end; /* Skip this vma and continue processing the next vma. */ return 1; }