Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.38 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796042019; b=xg3gkM784+sOli5LVbIFIdL9Ii1RqdwujNiDlfjJSd72MWwvAgWeq0CwVPjn4h1vprHw wD0TyeuUGD53KPlUGy7JMBlhJnCpHQQArhJ3NwjDS1yjEsrRTD+biFDQ9wJScfUfFIT36 3sLFldifeA+gBIw6X3BU60MmKuvdJJb/Zbkm9sfl7YUG1QK073oPrcWWC3OpFxMqmhPdc 77HnOt3BFyk2URjKk9ikOpZj7G4Wpw/QxeqQPLlYbAC4e2p11VfJTI2wyZJUkcLV2rJ5w yuhkTpUpo11XmuXBpD5RH8Ut493wcf5hx+aETj8vgcy2rrX3JXrTO2KUsBmDAxX+YIQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796042019; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=DedeKt8BxWhOI/kwg8Fu5E1ZH4NFZC5HAJeOlzFKEik=; b=x4OhDic5V0VqDSbK+AG9T6px+QJpjaew202Oi3Nr2Ufa4O+lKLyy0LcBKeuCth2r4bsD ViE4ZhmtqE4lB+RIr6PZBrMrU5ttW9A4cUtqoVh8VtMUU3thOJTMWVn8dmkRjQfL4Yizm Q9pU2HvGv6ssL6fT/il9FPSaBWV4GrHxEhtszQeC1J9ncGMZoH4soN6vWd8fjhIf9Dewv KdVu9HWPJ53iPxZdDvs48KIrz3dxNblWWkoxn3HpMs/JD6vOhf+N8Ol0YHGL5JWU4PC9H VcO5CMG/SJ2skTBQfWRX3Si2WlWd06PKwF7zb4bPolQksBIZHjKk0+jglB0nfTSavSg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=SIqBEej6; arc=none smtp.remote-ip=91.218.175.38 Received: from mta0.migadu.com (out-38.mta0.migadu.com [91.218.175.38]) (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 F1E6D606A31C for ; Mon, 30 Nov 2026 12:33:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F1E6D606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=SIqBEej6 X-Envelope-To: stable@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=LbtLlU0moLw+ma2hXZX2UxE9DkqQOYW35hJ24Nt0xMA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796042017; v=1; x=1796646817; b=SIqBEej6aQ9hbjhdKIT2X+yjAMJtsa3SGARXzauHw0K0j2/RjC97TYmRRYpm8oRvgJ+FucgQ VgoDiic6LAGi6/JnC2jwPLCntJJfBdPH9srDrLT4YpEoG2ZWEkLcTeUppr/RWdMdYzGePE2aAvb 1zmJ59g0ITq4P7hxs0XnNjJs= X-Envelope-To: stable@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id bda32b5d19a697a5; Mon, 30 Nov 2026 12:33:36 +0000 X-Mizu-Trace-ID: bda32b5d19a697a5 X-Migadu-Flow: FLOW_OUT Message-ID: <8c67417f-0d76-46db-80c4-ad7a18617de3@linux.dev> Date: Mon, 30 Nov 2026 20:33:25 +0800 X-Mailing-List: stable@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 5.15.y v2] khugepaged: fix readahead lock inversion in collapse_file() To: Sasha Levin , stable@vger.kernel.org Cc: syzbot+16bf7cd0ebeb1de93aa5@syzkaller.appspotmail.com, Pedro Falcato , "David Hildenbrand (Arm)" , Zi Yan , Baolin Wang References: <20261127081618.31491-1-lance.yang@linux.dev> <2026-11-28-1-daily-reply-0027@kernel.org> Content-Language: en-US From: Lance Yang In-Reply-To: <2026-11-28-1-daily-reply-0027@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/11/30 02:59, Sasha Levin wrote: >> We need to release those folio locks before starting readahead. On a page >> cache miss, roll back first, populate the collapse range, and retry once. > > Both the 6.1 and the 5.15 backport retry with the same huge page > ("goto retry") after collapse_file() has already inserted it into the > page cache. These trees lack a2e17cc2efc7 ("mm/khugepaged: maintain > page cache uptodate flag"), which keeps the new page out of the page > cache until the collapse succeeds. So a racing lookup can hold a > reference to the locked, not-uptodate page and wait on its lock; the > rollback unlock_page() can hand it the lock, and the retry then > re-locks the page with __SetPageLocked() and sets ->mapping again. Two > tasks then hold PG_locked, or a waiter treats the not-uptodate THP as a > normal page cache page. This is from reading the code, not reproduced. Ouch ... I missed that some upstream fixes hadn't made it into 6.1.y or 5.15.y. On 5.15, v2 also skipped an existing page_count() check on retry :( > Could you respin: either free the huge page and allocate a fresh one > before retrying, or do the readahead after the rollback and return > SCAN_FAIL without a retry? (5.15 already stopped reusing the Sure. In v3, we drop our reference to that huge page and retry with a fresh one. 6.1.y: https://lore.kernel.org/all/20261130123040.40795-1-lance.yang@linux.dev/ 5.15.y: https://lore.kernel.org/all/20261130123237.41399-1-lance.yang@linux.dev/ I've tested both backports. Thanks for catching this! Cheers, Lance > huge page when page_count > 1 in 033b5d775511 ("mm/khugepaged: fix > filemap page_to_pgoff(page) != offset").) >