Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1808187lqg; Mon, 4 Mar 2024 04:42:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXC1qPfSBzl7jSAfMc6X8jCUe1tzvBEUQoMhdOD7llKRq1qP/+ojOk0OmS/8w1UGX3w8upPchfANCm1F/fig0r7bjGG8uF1WslxonIr4A== X-Google-Smtp-Source: AGHT+IGpDm267MC24o9JFsITGNcVnLsi2/6WfRYZUTe0MIbnnIIG+QEKes/PZXUw1smzRC/c/pfI X-Received: by 2002:a0c:fe04:0:b0:690:79bd:8206 with SMTP id x4-20020a0cfe04000000b0069079bd8206mr1422626qvr.21.1709556131143; Mon, 04 Mar 2024 04:42:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709556131; cv=pass; d=google.com; s=arc-20160816; b=UgzH1EAyOMpnTYk0uBmcXIgxzUkuyTl5XhbCToTEmbzADQ1es2FPf23iVxJd0NmYZD kmY+D2odIcl4FFuMoODcARaH88AJ6tRqN71ZJlHXT1vhvT/DOVntfiN+H/1MrTiAsnkR yK3wyib5c26RLKJpJo0CSZ+i9Caajb0V+DsmQxPy4MIgdlnPqayMZHBPYYoHSaSDu6bW WSpx5MXtWGkVpL0CE78e9DwWNutuHXeUDBbq0399CGmLUspOmCK39sBtbZ6kEybC2H5f 685uEQstZBpASURff8gToLrWm/Aa+kpjZHn+OzkvgLvlw9MKQXGyE23ZtkQ3cInP7miy mXdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=/iKHiVaDQ6he2DYPyr6bxqLUCe6rQEgP8PNq9ZdcfyM=; fh=HgIXiWOS6WML6lma47I+mC8wQH28JGBDtNl46bJ7L28=; b=wKkYpNKOd3ZuID25ujkGm/vB45BHpfSI7X/ni2tNz1xNAsyQ4wvykkC5iJVksVESly FF2J2zJFxJrgcc++/Gbl7IOy7N/3grONX85lXEb+PE0vOK1hhM8D8J/BvQvGFLLhPJN7 WoqSrV6iTdtDWBEIw2o8o81QqzBP93sPlvDNOmaR5XN0gSh/YYOBJ0akrDHb8Ny2hMWR BP44Ga/EVg8UOmEcrt9/YLiVuzuEAEWtr9SBgbcpfojh+vw5W+rRi50y9iQZdCQIXZkt o5IqdjkaWfN3x9MP/8njZsa3iVx3h2ReuQdzabYQlFzRGT1zpNB267BXtzLpAwgZQotV elRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="M/uaQbCG"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-90586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90586-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e9-20020a0562140d8900b0068fcacfb34asi9459771qve.235.2024.03.04.04.42.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 04:42:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="M/uaQbCG"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-90586-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90586-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A4FDE1C23A70 for ; Mon, 4 Mar 2024 12:41:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C148E3D0D9; Mon, 4 Mar 2024 12:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M/uaQbCG" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED5443C6A4 for ; Mon, 4 Mar 2024 12:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709556105; cv=none; b=jI57wjWI5aFQqrZ6HqHxgPOozVTyE/5G/SDqLOBPONCQnPTfz2L083v3v8xYAFuoQMAiPSr/d43idqfrSptHAlZS7V+nNxogewiMYjgn3FN/86v6XOPyMg0mDBSnX0EWs4EcMoVrkA5IXG/9c4oimbb4/oKG1TX7jeP1iheh9cY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709556105; c=relaxed/simple; bh=sod6nZw96gk259vlxS7BmmHi5xl0g7UYFM8jONcxblU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UcVoxOXiBsDmAKD4o8vm6j9ngoWg+7xP+0ASjYckjOieOU7FJqsvsP+otrhkt5andgGBRqi5rFLlwlMcPJjESSezMtxD953e51LqJtXAyfWwvq6kr8gT1465nsL3VgfNL2NGAFNy2E8uVKz4UlN6LYXDftKFX3NTXNTJ9uoPPk8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=M/uaQbCG; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709556102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=/iKHiVaDQ6he2DYPyr6bxqLUCe6rQEgP8PNq9ZdcfyM=; b=M/uaQbCGbFgRj8rTe9l01y/ViLpfKXjmP9sddlxUemqdXJcNK2YQPmsmUZFccmmPUOBXW3 jds35/j+ZmLDbpSJWS5q6jgbYOH3MPBzjc0uI64xE5S8vgeLnjb4AusYLtPlLc/v65ebmi Z9t6gkzE32ydQdDE22Lt55SHTKIzW94= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-K4pQcuzzMY6APm8PWY-HCg-1; Mon, 04 Mar 2024 07:41:41 -0500 X-MC-Unique: K4pQcuzzMY6APm8PWY-HCg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4129b426bdaso29425065e9.0 for ; Mon, 04 Mar 2024 04:41:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709556100; x=1710160900; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/iKHiVaDQ6he2DYPyr6bxqLUCe6rQEgP8PNq9ZdcfyM=; b=cttc2PoIJZMt+F7OpkSoMiDBFrbgEIqkA+1GhWTcrQNX2mYvB6vvtf0KOeTGw1Qr+5 PwtghIaLIwmZ4ouqIbynuzJJMaz04vc29qOsVi+HWjDnaQVFaVmR3TQ8einSSD5TK2oq n56MAnXPvAM1OG94lVr8q31QZuteH9XBUrCYS0ucwMT0COU4NxhwaVuI4ZMQ7QV1gVmS gFaYQ4wwI8PWR4zecnsXXKdGL/52dR8BRYp3LgFud/DQ4sHKU4Pt/5/+Muwgxuye+Zss p0kDyLterR51Y6FQaj5MIKfiOvtMqc7WKZS0t2o93Ds97XN7phMMH+LxU0PyBy2JZeDk dx+g== X-Forwarded-Encrypted: i=1; AJvYcCUKo5hGyeCshHRdVBSrWtsLCANc3zHYD07/GptgTblqrR2YGOGMhKbqk0y+2wqlN/zTKIi/RTu3MdGWN4H9qWj9fZU4MXLk0xjetSlQ X-Gm-Message-State: AOJu0Yzwn1Sx8DfxNxyIwcEaD76KfnmwFTdEcDWo1NHtcD3Iup53hoUE 8u9n/tYOKhfoUChijDvLUXqiD48Tb+If6coKWt2TcAqnV7b4lofXCkccQwQEIT2jXX9Ml5WjEAf eb3Amqu8+otmugfJxMTjjjsPNuKBq/V7zDx5twH6N/Low8ylpeLVKB0xf/GmIsg== X-Received: by 2002:a05:600c:5188:b0:412:e461:a16f with SMTP id fa8-20020a05600c518800b00412e461a16fmr1424591wmb.37.1709556100125; Mon, 04 Mar 2024 04:41:40 -0800 (PST) X-Received: by 2002:a05:600c:5188:b0:412:e461:a16f with SMTP id fa8-20020a05600c518800b00412e461a16fmr1424576wmb.37.1709556099744; Mon, 04 Mar 2024 04:41:39 -0800 (PST) Received: from ?IPV6:2003:cb:c733:f100:75e7:a0a4:9ac2:1abb? (p200300cbc733f10075e7a0a49ac21abb.dip0.t-ipconnect.de. [2003:cb:c733:f100:75e7:a0a4:9ac2:1abb]) by smtp.gmail.com with ESMTPSA id e2-20020a05600c218200b004125f34fd7csm17364777wme.31.2024.03.04.04.41.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Mar 2024 04:41:39 -0800 (PST) Message-ID: <37f1e6da-412b-4bb4-88b7-4c49f21f5fe9@redhat.com> Date: Mon, 4 Mar 2024 13:41:38 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] mm: hold PTL from the first PTE while reclaiming a large folio Content-Language: en-US To: Ryan Roberts , Barry Song <21cnbao@gmail.com>, akpm@linux-foundation.org, linux-mm@kvack.org Cc: chrisl@kernel.org, yuzhao@google.com, hanchuanhua@oppo.com, linux-kernel@vger.kernel.org, willy@infradead.org, ying.huang@intel.com, xiang@kernel.org, mhocko@suse.com, shy828301@gmail.com, wangkefeng.wang@huawei.com, Barry Song , Hugh Dickins References: <20240304103757.235352-1-21cnbao@gmail.com> <706b7129-85f6-4470-9fd9-f955a8e6bd7c@arm.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5q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RxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <706b7129-85f6-4470-9fd9-f955a8e6bd7c@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 04.03.24 13:20, Ryan Roberts wrote: > Hi Barry, > > On 04/03/2024 10:37, Barry Song wrote: >> From: Barry Song >> >> page_vma_mapped_walk() within try_to_unmap_one() races with other >> PTEs modification such as break-before-make, while iterating PTEs >> of a large folio, it will only begin to acquire PTL after it gets >> a valid(present) PTE. break-before-make intermediately sets PTEs >> to pte_none. Thus, a large folio's PTEs might be partially skipped >> in try_to_unmap_one(). > > I just want to check my understanding here - I think the problem occurs for > PTE-mapped, PMD-sized folios as well as smaller-than-PMD-size large folios? Now > that I've had a look at the code and have a better understanding, I think that > must be the case? And therefore this problem exists independently of my work to > support swap-out of mTHP? (From your previous report I was under the impression > that it only affected mTHP). > > Its just that the problem is becoming more pronounced because with mTHP, > PTE-mapped large folios are much more common? That is my understanding. > >> For example, for an anon folio, after try_to_unmap_one(), we may >> have PTE0 present, while PTE1 ~ PTE(nr_pages - 1) are swap entries. >> So folio will be still mapped, the folio fails to be reclaimed. >> What’s even more worrying is, its PTEs are no longer in a unified >> state. This might lead to accident folio_split() afterwards. And >> since a part of PTEs are now swap entries, accessing them will >> incur page fault - do_swap_page. >> It creates both anxiety and more expense. While we can't avoid >> userspace's unmap to break up unified PTEs such as CONT-PTE for >> a large folio, we can indeed keep away from kernel's breaking up >> them due to its code design. >> This patch is holding PTL from PTE0, thus, the folio will either >> be entirely reclaimed or entirely kept. On the other hand, this >> approach doesn't increase PTL contention. Even w/o the patch, >> page_vma_mapped_walk() will always get PTL after it sometimes >> skips one or two PTEs because intermediate break-before-makes >> are short, according to test. Of course, even w/o this patch, >> the vast majority of try_to_unmap_one still can get PTL from >> PTE0. This patch makes the number 100%. >> The other option is that we can give up in try_to_unmap_one >> once we find PTE0 is not the first entry we get PTL, we call >> page_vma_mapped_walk_done() to end the iteration at this case. >> This will keep the unified PTEs while the folio isn't reclaimed. >> The result is quite similar with small folios with one PTE - >> either entirely reclaimed or entirely kept. >> Reclaiming large folios by holding PTL from PTE0 seems a better >> option comparing to giving up after detecting PTL begins from >> non-PTE0. >> I'm sure that wall of text can be formatted in a better way :) . Also, I think we can drop some of the details, If you need some inspiration, I can give it a shot. >> Cc: Hugh Dickins >> Signed-off-by: Barry Song > > Do we need a Fixes tag? > What would be the description of the problem we are fixing? 1) failing to unmap? That can happen with small folios as well IIUC. 2) Putting the large folio on the deferred split queue? That sounds more reasonable. >> --- >> mm/vmscan.c | 11 +++++++++++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 0b888a2afa58..e4722fbbcd0c 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -1270,6 +1270,17 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, >> >> if (folio_test_pmd_mappable(folio)) >> flags |= TTU_SPLIT_HUGE_PMD; >> + /* >> + * if page table lock is not held from the first PTE of >> + * a large folio, some PTEs might be skipped because of >> + * races with break-before-make, for example, PTEs can >> + * be pte_none intermediately, thus one or more PTEs >> + * might be skipped in try_to_unmap_one, we might result >> + * in a large folio is partially mapped and partially >> + * unmapped after try_to_unmap >> + */ >> + if (folio_test_large(folio)) >> + flags |= TTU_SYNC; > > This looks sensible to me after thinking about it for a while. But I also have a > gut feeling that there might be some more subtleties that are going over my > head, since I'm not expert in this area. So will leave others to provide R-b :) > As we are seeing more such problems with lockless PT walks, maybe we really want some other special value (nonswap entry?) to indicate that a PTE this is currently ondergoing protection changes. So we'd avoid the pte_none() temporarily, if possible. Without that, TTU_SYNC feels like the right thing to do. -- Cheers, David / dhildenb