From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.111 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796023697; b=gmzhtjQVkDE9ZixocIcWhb3MSNFHpJuby0Pz9cIk5aXsfwml17VWYahikg1Typi7IrnH iy1qh7tXPYAQyV4Y10vvay2cIrHMuFookxH5sKG4XV72RLemj2OTiYboD7DEo9Z8BzN6k w1eG8TiBp04iQrkzWON9cKD2cGWvsWGqZW3Y7jIK49AYH6qlqJ7b063eSixuRk5Lvdp1/ JEP/wRkPqyqfVgIw+8fX7mFTEmcczHMPw9js/jvS33+qTMLKkATx0ANPjqgIlO4bUhL+k 99c+phMwlA1EHavm5T+7Lnx9DMgElzsecgRRtdXvho4KIugYsugrzQsAjVsm2Qpz6KQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796023697; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=XZkP+HmvPG7aOlSBATRE9LFQsRR27lb1fEN2GJrVoaM=; b=oWfkdMluo1gFsDsa0maC+g46yhFTiF3ARJDmgMaT9w7jOhQIfciH1y/LxTSW0VdcMe4B YXPRtOZThxQ69WHEZPogKzFI9NjutU6UpBhPXeEPz7k0XfPPzYgP8omnwUVfdVUlrnUzR Pu50Bc/sng/wv3P519qEsRZNwrEPMOwsh9d6EZTutxrkHpXo8ZEzrtwIyrMLOve1Nq+gq 57edSMrVdUqQsR09UOsPeRb0WdR5rAwBfH41/tTyXhCUFG4afrli5wisjVkSLnIZCu7e4 CTese/OVANx1yZ0aEGe+ES2mGs27XevMlQa8fVi9aPSDPpEtJJKnwHoucvKIDmMwadw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=ATzcPzyq; arc=none smtp.remote-ip=115.124.30.111 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BDCF606A31C; Mon, 30 Nov 2026 07:28:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0BDCF606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=ATzcPzyq DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796023690; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=XZkP+HmvPG7aOlSBATRE9LFQsRR27lb1fEN2GJrVoaM=; b=ATzcPzyqkyjZYbsS3nrUMrit6TVyKQ0HBJfQFM0UfgwXEB5IoFxYFk+avhOtRgSrjg6xsEa8GxTUmIxAVYwfB0W/46cUSRcxhiwWuXi2W98SUvDvOy13jieNy9c7oIRto/nj6zopnQnW21VNOWePiD3PJlNBl0RL+eAjGbmyqkA= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam011083073210;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=26;SR=0;TI=SMTPD_---0XFh3uEd_1796023687; Received: from 30.74.144.138(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XFh3uEd_1796023687 cluster:ay36) by smtp.aliyun-inc.com; Mon, 30 Nov 2026 15:28:08 +0800 Message-ID: Date: Mon, 30 Nov 2026 15:28:06 +0800 X-Mailing-List: linux-fsdevel@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 v2 3/3] mm/memory: don't allocate in finish_fault() with the folio locked To: "Jose A. Perez de Azpillaga" , David Hildenbrand , Zi Yan , Andrew Morton , Zach O'Keefe , Hugh Dickins , Lorenzo Stoakes , Kiryl Shutsemau , Dev Jain Cc: "Liam R. Howlett" , Nico Pache , Ryan Roberts , Barry Song , Lance Yang , Usama Arif , Vlastimil Babka , Mike Rapoport , Michal Hocko , linux-mm@kvack.org, Matthew Wilcox , Jan Kara , Johannes Weiner , Rik van Riel , Song Liu , linux-fsdevel@vger.kernel.org, stable@vger.kernel.org References: <20261127091344.113688-1-azpijr@gmail.com> <20261127091344.113688-4-azpijr@gmail.com> From: Baolin Wang In-Reply-To: <20261127091344.113688-4-azpijr@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/27/26 5:12 PM, Jose A. Perez de Azpillaga wrote: > __do_fault() preallocates a page table only when the PMD is empty, so > that finish_fault() does not have to allocate one with the folio locked. > > Since retract_page_tables() no longer takes the mmap and VMA locks, the > page table can be removed while the fault waits in ->fault(). > finish_fault() then finds an empty PMD without a preallocated table, and > calls pte_alloc() with the folio locked. > > Allocating with __GFP_FS while holding a folio lock can deadlock in > reclaim, for example the memcg reclaim deadlock on cgroup v1 described > in commit 63f3655f9501 ("mm, memcg: fix reclaim deadlock with > writeback"). > > If the folio can't be mapped with a PMD, return VM_FAULT_NOPAGE instead, > as we already do when pte_offset_map_lock() fails. The retried fault > preallocates the page table before locking the folio. > > Fixes: 1d65b771bc08 ("mm/khugepaged: retract_page_tables() without mmap or vma lock") > Cc: stable@vger.kernel.org > Signed-off-by: Jose A. Perez de Azpillaga > --- LGTM. Reviewed-by: Baolin Wang