From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795982886; b=l+Q/qYfc2uGAavukwC/fpPhxcRb/I6V67HXtlHiD5dC/nDpefYb7C/zgI8s8GP04BgS4 KHzkGNrXpZu5duTWKxziOtxv+IVqSshh/7Uc5aqsCg3D2C4girr8yc4lWB/9tyYpwS0wB LSg5CcU3ySRCyLmr47nIwA5YQNVGJ/8AiB2zKoOqnnONTeyFJdQIRu4uqAW2mnkhdXCE+ VcAwhMHfR3Rsn/LDDkYHQm+ADsDR7tIkdhgdIIhPsvDP+chNm7C2ZiDZYFdD96uRMe1kq +JAYJgQeyYfgsm58o/9Kg3gBwFs1IicWNwUmCPhPQp3f/xs12Hqq5KJgAvWkzFGYWdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795982886; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=pqruVXh732nc6+Xa6iytKD/9EliIfB3xmbLD+UBvbNw=; b=udNufPG4Uyga9FI/Zj937tpkYBgnGCG8Da5UIl3I07V72aSIdrkvafK+IPTI8/d2IYaC Xbvop2Zyd67jKw7B35z9HFIpAR3FVTv+OlBN6whr4CpblVu/KGVSV+gwErYxLHlcpOZtx FpB/9uFNx6GLsIzaL+sycvStO6S51qzaXNmbsFLNDuPTqon4xY3eeNyPZNXh1LejKt8Uu xBlbmHanoYQ709YIKtg31ztRl454kgE6nFR4/L4UmCHhIPu/dCYSjrcNG45KK1dIZe3w4 vbYKZ+9mWeTdxKf0Nqbsdo1H5m5KPKV619Lk5s5gjUCwKShUnV+0HdT0u4Xtdj2PxOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=W5Au+v8z; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7BDC606A323 for ; Sun, 29 Nov 2026 20:08:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7BDC606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=W5Au+v8z Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso120873255e9.1 for ; Sun, 29 Nov 2026 12:08:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795982884; x=1796587684; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pqruVXh732nc6+Xa6iytKD/9EliIfB3xmbLD+UBvbNw=; b=W5Au+v8zPW+75/DdgAjqAGcGDqYnCH/h6uXI+5Rve8PlkL8pzUQH75if2c8TH9QaI1 NYXPpdpEMkUK8+eh13NgkPzlXCjf2+nkmBHd92Iq8YGfphmYn+HrLUhFJw26NZGI1ZpW /OH/aPIw7mMy1SSgBAzAv167/6FDHir61QG9UY9xJENfecWjCcrVKvTvAPyDeKOc/NsN ZW9u6VQqwEKjUaGWAFw9aUaGYC9/C/CkGJ4ZfjUXK5OUWvuK9/lOTU1E2XGKf/k68Boc UW1qNkLa4rwmyDTHjJnIF8tFkXENvls6AlCPQNd5qNrfhnr7F6zU158SQaAGuHVFzYJT 9adQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795982884; x=1796587684; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pqruVXh732nc6+Xa6iytKD/9EliIfB3xmbLD+UBvbNw=; b=EpIE9ngQwaO7RH8PKpzNA8iSGozFxzB8R9BBmnCiB3UtRM0tSn09xRHVW52olKSeAe SCyqTLySleCVj+UPlVzBMfa6KpeOb5o8kpZahICKss+ra82gemtGs+PgP1bimQ+5BUYo 3dSL5qdxPgQlwotNjTuoJ5jDEJkgv2G0troTncYz4Zfz0Pjwt0lDj/LopOP2oOUT/OS0 jtUryJTlCa1iF0rJaSlSBpQciXD2SY1ovruy7zNZN3vvMVKZUEXD3hXSvWDy6HDqASaR CeNZbwWxe2Rm8VudhTqOv4B3dOkAWySZdZrx14tGzmGmPckaFpfofh9HoWxwyckOTvpy tXrg== X-Forwarded-Encrypted: i=1; AL+hErFg18SyC5LKqVcXZj9ExP9KhI2WrPBPuDBiysf42/rDGToywv0uqFtGFVjFEinPfXuh0VyAaVZjDsPMMk0=@vger.kernel.org X-Gm-Message-State: APuU4Z/HrFCa9Jxnl4tDh37MPD1G0zc+1DS6zAhCpfJRgLvo2Rx0t6dy CnNr0JTr8ab0QTcqGsMCzYMQ8h2J/5mQ+145x00ct+ell/+Evan0ISkm X-Gm-Gg: AZFdTZd+Bsoo66xXQ2QNlpyJ/a0vI2vQQiQFRdnxJ0iYlvQzglHlQd5GDjUjoGv64lJ DOqcfhWDKsXgxiXCf56dtc64dPqPDdzW+Utm4ncfSBIAgjbb50F5eFbNjE1kjCipvFSHNPHUJNo qTkX/pGgAkyzXXoweXZh2m7FGyPMnn8MMC66AAALb9LuZMJlwF400319ndbVoUgB6dJj536frJX PJpEi4OVvsUFTOpSGaZQ2F5hQJKYKrvLPW2xG6UBtmVLRyvasmq1Wuv7uDi0DjbLGiCyRlvNN/B peHyTjsMdkuA2v7JyhagxWRO3YCmpPDTvAvfzzG3ZxLaRkxfC1VHzUPiLoic3Gz9vjKziC2Y/kK M1z+w7BkxUWGkdvhg5WsvrLjodImaL15lX0ASnd8VrxDwWbVKKCQWltjNb/ytnQ9sMXXE9GwIRP oQrwAh3pza5p5zcLG5EgoT0YCZintshPoPKSIl5/aQRVC+Ashd0ZMw7iT2SqtUHrTzROyBflaPz fGnfgurAcRLfMHCJwjZ8BT3kma5cX0+XklRGqjQ2U3YJ6NGhT7WGeLQbHBlDIHOOmeAwDPBC/Gi 5Q48bYiPrfTPvRYbLTGKog8rZfur/kFjeKuVMLb+9BSngA== X-Received: by 2002:a05:600c:4755:b0:4bb:7033:de79 with SMTP id 5b1f17b1804b1-4bb8881dd02mr653389555e9.35.1795982884129; Sun, 29 Nov 2026 12:08:04 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853ca452sm835478825e9.15.2026.11.29.12.07.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 12:08:02 -0800 (PST) Message-ID: Date: Sun, 29 Nov 2026 21:07:58 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 09/32] mm/khugepaged: check for uffd outside the i_pages lock To: "David Hildenbrand (Arm)" , Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , stable@vger.kernel.org, Chris Mason References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-9-f66094116801@kernel.org> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261129-fixes_core_3-v1-9-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/29/26 11:06 AM, David Hildenbrand (Arm) wrote: > collapse_file() walks the VMAs mapping a shmem range to check for UFFD > missing registrations before filling holes. It does this with the > i_pages lock held and interrupts disabled. > > Consequently, a large number of mappings can cause excessive interrupt > latency. > > Let's fix it by moving the walk before taking the i_pages lock. Hold > i_mmap_rwsem for read until the retry entries are stored, and take it for > write when registering UFFD missing mode on a file-backed VMA. This > prevents new missing-mode registrations between checking the VMAs and > installing the retry entries. > > Move hole counting and retry-entry insertion into > collapse_file_mark_holes(). > > Also pass end - 1 to mapping_rmap_tree_foreach(), which takes an > inclusive last index. Otherwise, a UFFD missing-mode registration > immediately beyond the collapse range can incorrectly prevent collapse. > > This has medium urgency, as unprivileged users can trigger it. > > Fixes: ac492b9c70ca ("mm/khugepaged: skip shmem with userfaultfd") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) LGTM: Reviewed-by: Jose A. Perez de Azpillaga -- cheers, jose a. p-a