From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795982886; b=ec07zfBf/yPesLGKUU05kI5IJQqQ07eTLPNt+mobx8V7I/2QkRE3K0gNdrGAvRB0JYQm e6pqoW4CJ4CIn7Gr6G6TRhkKcM6XDxGMnXZ0bZtkRdYyn1PsxmfYMvbZaIQhcgcj50hYM dsfx1bEv/1FydhJjtrN4pl1jWa2dodOUpuv9MCDyHTPudJalmR/adgwI3GqRyivXKdfn1 cIJPJ6tg6TunusBrKghd7zbJzB6rXBmwQ7IGr+PDCjBCgq64f1rGe/2wMKKbY2SRWfeHR RF+uQei5PBu5DxK85I4ttwIiLNtqeWyRhC7C287uaxQLKDyOzRnKxv7Y9b23I5UTOkQ== 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=GXsXpRsQDNMZv0WIOpCdbXy5X756H3dojjZiPWxgD+j9lKT5wu1cAxx8owURjQkS8aEz Kcn6+26h07X5UqAodFr1QUCjf910M2bcOGfjhq7XyOr1jlwcj9JAyLhTaVGfUzn86Qe3h vCJQZ8q+2eIkdkaotWctl/cFt3AQPaGtgwePTNFNnr2xCRz5oY8aNnzDbkhZeTGetFAc0 Sj5yqlO2EBrQZvEH/xC7DCH5ZZ+eLwSrvNSfL6/xaxOI2I8RXLWtoNWtxWxSiYpYFFCGz Vm1yDB3nuVVn0oGFzk5NKpW5uuh4a/uHr/yPZs7vB3X4rgdBi7LMLRHRAPBByrqCdgQ== 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.50 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 F2034606A329 for ; Sun, 29 Nov 2026 20:08:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F2034606A329 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-f50.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso120873365e9.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=lOBMiAjcBXaus0ZX2L7LRMZZlk7ME0BFZJc5hqzZ0sYdPlrVV6Kg6uLuIw+PDPTSz+ OimZbkgh8e9/wqWeZyIyHdRAABmYnAHqaTA5EdFee7Fyxb6KOkFc2NV0nZ/pCmvdIU+N dIufvWkQud0nCDCrojoB4RemAjaO/yHp6i1EBgDce56PhqGq//yEZk6CGfMcy9dGb2i4 No1je7fr4abt6U8zb1eJLV2fyiWRUn1q8eWhm4Zenv3QBWrMZm4H1YTuui3uhVa6ipN3 bensbMLO1I9EO6KYhpli/a3EMPLiDVnZxoSRVSR+0E9R7/zrU1Tc2XWl07Xg61FyyLtP EA0Q== X-Forwarded-Encrypted: i=1; AL+hErEF/RXp6SxCL8hMVTiksvxXH/gfgWRfKyBo4kE9GNrHx/eRCHiCTqrspdgSnDQfdNg1KVfgLySb7wk=@vger.kernel.org X-Gm-Message-State: APuU4Z8fItTD4hENRq6jAEDXuGcNKqJerFpTZpw6Uk7iSFbHu3aqOFdX YfnmEEDAUcEzMCE9+J+3i0vyLpEcX8wLoTRUZLnxpBOFzAZpYGl8k4mq X-Gm-Gg: AZFdTZfmuwX3GF0s/cSRdQFQDMdbdxA0GtpM33m9h7V6fia5R75YyVEJi5rittzwq7D 0plMERNAp1A4hO//9bCLJKaXES/sFW0rD7jLEc+zwQ/qGB+8JWKoTREVBpHfb0omMYcX84zMPgy OEMoqnO4AI6G7aydqnYwZCN+tWIJpj+716BjgwbQwU51ImH2TlHumYRzGnsFv60QhpXncXwRdyo //MeWLO+iDwUtx4EbQaoPscHnkER9gko3PDJSOk+llEXFH5d+/JPY/6XJ12SN6LaMdJKaRAIQfJ 6CX7lppzERUccphMlouq9rcNxRgY2nSKxOZlJKJcpJgN4B/Y0cqowoL24cBFXNz0Pgi3YNTnsPz Uy5Zt6nE458bukIE9u4ow6tQTBx3nwyVqghcSYDdo/JwGIbwpRHAT2dSdCGnFRTTM78yXwtDD0n quXiFMtS2V7ILdkJEtlzD84fORRFOOX0rIwaZ0S3DhU7OPgffeeQ0FBx/i4q1Eds+oK0H0ZP6HY FQhjuR801pQMcTCR6VX3lyBEHLZKB2eEL6WHymAGrHo44aUT1I/j4flVnPzvVxXTXAeecZs+ks9 /3RS5GPJ3ai2/EmO73FUNb/Sza6kcp3LN3/KOmsYV4esuw== 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-cxl@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