From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793110244; b=qfCqlTplMs3iMXWm6AEhL12AnXBPcw1qJmRx+DGWosnmlnzj9FxH/AKhu7f9pNmKIMJs 4X6YzIvAD+Xs3nWdFxr8N0NbXrXWr5Ci657r8B3Kk8qBxgakk0iA1UWVxfyG/GyoxsmHq y6CDe9yYwXMleObsmyBqqloQX+1N0CwxsKacCVVmYKM25cxufghQQq2a9Pr692aJRAT4X kb16eiN28MnoAeYJWruPP+itQb7bm0d+e8I1QM8YwTzPxDYzpnSK4r8Vk9rwmCOEz1QFy 6EKjkopit3Lymp1HQNm5TxhZ20x87+NoGxYKDvqOupFopBqtxVIDkSBst9z/egbM5bA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793110244; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=5jxF6/4/W+A1WjrCqJd2E9d0nCbxdlQgcbJ/7pkC9T0=; b=q5IIdHxUIuFE0jKHYao7BzET8Z7/M9RUxRN6FSAOQar8aWqYvg1eo+dotLn72jOAOCck /EagWqFr2CzX/uhx2UDGF60l+y3vRZOYuaEEFH8oHuCd8DQjsxyH0Lbf3aLry38Z6wJhg cYB9Vb5GoXlwz39AcXUHEvsacm2fiqFQs5AtuTslV1TRW8olIwp3FXQDhElktLaLZxDUv IOVgM4LhyMyWCzg7N9KjUppOJKODi41yEfYNFzcXxwNUikyJPVQ13RY5qBCZKkkEVUNem Bd+nM/9c7iGq9OYet/zDW6aMPGRt0Mih0IPgvocqjeNHQFkX/Ol0ZO0uLaSabMjjnHQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; arc=none smtp.remote-ip=209.85.128.180 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 2FC8E606A31B for ; Tue, 27 Oct 2026 14:10:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2FC8E606A31B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-8565d77c277so34902907b3.0 for ; Tue, 27 Oct 2026 07:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1793110237; x=1793715037; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5jxF6/4/W+A1WjrCqJd2E9d0nCbxdlQgcbJ/7pkC9T0=; b=nHbEtXvQuJ/8CywicpheEz5Jdzxi84tcFvyEWo6MXDPh4asHKIihhtID8raFmjk37Z dIOwkrGzjZhxvEZXUJRdwo9NVK3DnFO6vFgVbyFCqM+U4fQ4FG8QNsnimbJIyHqaW5wy zdmb6kGSLSm95ASDlhX+rqMiMzLlf/wpw7XJwPUNNt1wr89Tc/8R+06TYMpR+3qRODJp T0kDcPU38fvugHwlN3DGLvwyBfotlPqRAWV0pwds8WKmv6DVhYWhA/X4VC37TJl2YkFo 5fgiFCeXn8wHRmX8+HCDn3P1/hp1F7XTI6c+hNVNWpzgRnQiAvnJ+DdZz1WeG3Ulo5HG 5tFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793110237; x=1793715037; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5jxF6/4/W+A1WjrCqJd2E9d0nCbxdlQgcbJ/7pkC9T0=; b=ro5SlUyK5mQfM919L07IHaDx5EQ/2r9epcSlujGfINRwTJceVZIAa9XBkrCD4mGsmf kDVTkTOeNW4nuzFytPsB0PL08w+EaQCcyUDLlxryqSD45r0Egwm0TXexo7l5P3hzFY2O lfx9+LpEsNfbF6js7mz+o3yKhqXd4sQlZ6xWERn6XepEsdqjp1RMtiJEZkS7z3tQMfuS TjC17obCDxai699hgxBwYX3ZBXnEM0Ahx+GThy1yABJSl4gmEMi+EyFjxcGy6LR8itxh n4KtpBDSD2jTaGkRDv+U+5zgeZ4YiRrGmCrmdsQV9WhNl59mawtmuaQaSnAkVcOnBeeK IwxA== X-Forwarded-Encrypted: i=1; AKwUvBwcg3dI0v5OfCYbIBnrj1NIUNaHPQZ4VTRy5FdCkPzNKrE44wFYJzLRVcingXl6KDAvvWbXs37clU0=@vger.kernel.org X-Gm-Message-State: AFq9FYJuiIZxatu1sT+byO9ECpl8fMbavsa2TCvEdfvnXC1n91IVVhWO EUsLjYfUW6kRlRYR+EPJVKY72R0khog3f9qHq1+QKTA4359BufuTn+CSqk/6UGf4n8A= X-Gm-Gg: AYBFou3n9kTb+JRUm+DNoQ7ULXTNpIa2TM9qOV+HUOs1mwvxrPKoZKi/mtAHkaIipxd x6FBJLfdxqlxmDcejc9hyMTmA/UuonBVC/sh2gES3r0vGdRh3OpOB7CnwnjxlZWHB8iZ1h+E7tk ptlaxzeB1s1WJWvMtpkEV8Rsi/fD7JxVuz0mqJkQBISxD/OuBgRSpm8pBaOsQ1FBFnBKi3N+J/N V+LmrUMLkNKC2+eCuXuhFMDSHIiWFo1+77yZ7q/uRsWMdysfSTWnsPdadpu4Ta9rGEt7gy11rpH uFndHqdSk7iX+tL2rvATwfk9uFZmCmqVY5CV8wIVi4dDAaot+WtGPRUR8iIltgUDLQPaqxhc4U7 uxjApZ5Kk+a4uFMunt5CG3zHnsxIZ6/O0y9wWMZ5GsBnTeuX5NjRHmM+B23eItd/AJ62GArb3+n m9hQP9l2oB/3bB4TePnLjfywGnSSrSWaAmpgptQVo6hr32K2vihY7wWsQ4rORQCTSYAvTJ2QGe5 mH+s4JZ0zZWdXb0FaxoU3CYDQAiRTGP+IcGhIK6PZm1yTuU0heqpDA= X-Received: by 2002:a05:690e:bcf:b0:678:907b:3014 with SMTP id 956f58d0204a3-67a6b942174mr1866452d50.63.1793110236828; Tue, 27 Oct 2026 07:10:36 -0700 (PDT) Received: from localhost ([2605:8600:200:14e3:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67a7a07daf6sm127367d50.7.2026.10.27.07.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2026 07:10:36 -0700 (PDT) Date: Tue, 27 Oct 2026 10:10:35 -0400 From: Johannes Weiner To: "David Hildenbrand (Arm)" Cc: Andrew Morton , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Harry Yoo , Alistair Popple , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Kiryl Shutsemau , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Muchun Song , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, stable@vger.kernel.org, Josef Bacik Subject: Re: [PATCH 10/46] mm/huge_memory: fix list corruption when deferred_split_scan() races with deferred_split_folio() Message-ID: References: <20261027-fixes_core-v1-0-6f74bec9a5bb@kernel.org> <20261027-fixes_core-v1-10-6f74bec9a5bb@kernel.org> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261027-fixes_core-v1-10-6f74bec9a5bb@kernel.org> On Tue, Oct 27, 2026 at 12:17:30AM +0100, David Hildenbrand (Arm) wrote: > Since the deferred split queue became a list_lru, the isolate callback > moves the folios it took a reference on to an on-stack list, linked > through folio->_deferred_list, and deferred_split_scan() takes them off > that list with list_del_init() without holding the list_lru lock. > > deferred_split_folio() does not know about the on-stack list. It only > holds the list_lru lock when it looks at the same list_head, and it can > run for such a folio: a THP is queued when it is mapped, as a candidate > for the underused check, and is queued "again" when a part of it gets > unmapped: > > CPU0 deferred_split_scan() CPU1 deferred_split_folio() > list_del_init(&folio->_deferred_list) > next->prev = prev > prev->next = next > entry->next = entry > list_lru_lock_irqsave() > folio_set_partially_mapped() > __list_lru_add() > list_empty(item) -> true > list_add_tail(item, &l->list) > item->next = &l->list > item->prev = tail > entry->prev = entry > > The folio now sits on the list_lru with ->prev pointing to itself. The > next removal leaves the neighbours pointing to it, and they still do so > after the folio has been freed. With CONFIG_DEBUG_LIST: > > list_del corruption. prev->next should be ffd4000000270090, but was > ffd4000000278090. (prev=ffd4000000270090) > > Fix it by grabbing the lock around list_del_init() so > deferred_split_folio() cannot race with it. > > Fixes: fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru") > Cc: stable@vger.kernel.org > Reported-by: Josef Bacik > Signed-off-by: David Hildenbrand (Arm) Reviewed-by: Johannes Weiner