Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp273333lqs; Tue, 5 Mar 2024 01:20:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLMQKOWRnhoEUenLZJkFo4HyGQUpdckcx4wMDIv20dxQCnknECPa61aMhLqkOVq6Fhlho6N1RhAGvL3PZKJoOwi1iyWbb3kEXuUuUvOg== X-Google-Smtp-Source: AGHT+IHfK5dGGX8DhtCn/Ja8DBlk4U8X6e7qOTWm7u0ciAZWVwmRrdtSD/9RMykk3r+yI7iHPVcr X-Received: by 2002:a17:902:ed54:b0:1db:aa46:4923 with SMTP id y20-20020a170902ed5400b001dbaa464923mr1156547plb.40.1709630457787; Tue, 05 Mar 2024 01:20:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709630457; cv=pass; d=google.com; s=arc-20160816; b=hmEAPy0lBK37Jvn5ueqSWF3vvawFrzTHAfuzmZ9bZgwpZ2EzXzBgm/HEAHJhmQsNJR +wCT/6oHRqWgUzNj68KtJCLi7szQr+VOK2cDgGuGyOux1LmdfTxttSuuaCt+P3+UgMZ/ Ru5rxGOnXUGp/XSTXFmulzlSBwSPsm6OWFwp+pJRRYtxLSpug06ouk/GlPLv6zeyEw1C xDozirlgBJa5qYhIzKqgxaTVLVInjWpfRFqNgYipL0ScD6kkpn3e26lagdJVVqIW3LkB VNGXH5138DU/mN2HBha3B1wp8h2/HwL+fq48bwdliWS8LmHq+uU9+7DIcgwlspZK40tu edOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=8Epj7If0zvVbvccdyifxUIrmrXlDu3t1G5CCtAyXP6Q=; fh=HJFkQHXmoggbD63bfbIFnmrlX07EVjcezRgb8qTAr2U=; b=ZTyVnF/+v6W+Agjw+XP/lxEr8SGaREVfp2Ip40O2fqXSkEOg3lffsLrCYcIAPXId9q Jn0Lu7pHmG/BZYPLCGMbFpp3iLwHXAcE9R27gerlm1h9OY7J7IokYyidcDzEXrFXMvFA FwqW4rDqjaqNx6RDGemsOyJsDWrnfSTAEg1Bq53J1eFLhknmT540zkjDo45/nBecrbwd 2bnigB7WVxjAM8Ob+X3sYh0dMEMcUrXYzeiMcorllr2pYbCC3UFkyRkMVqzGtHlRjHLd iMZEAZDwGTVG8HjX1LB4wupoKKut/zs+9TDOCapEyAtjFFsthUJ3r357XfMRwJ75rrmp GnZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-91961-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91961-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m16-20020a170902f65000b001dba7e06c0dsi10025669plg.127.2024.03.05.01.20.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 01:20:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91961-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-91961-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91961-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1B681B24BAC for ; Tue, 5 Mar 2024 09:08:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FB9A51033; Tue, 5 Mar 2024 09:08:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D7E250A60 for ; Tue, 5 Mar 2024 09:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709629698; cv=none; b=U+YNF0KPQoPLlQi46gyC00creHJe8Sw476FxZ9yHmvQrVqMOsod3Ji6DM6h4nTPxjDpZJiagxTxMezpEJQcFufl4MeJzUp6b3TEsucpJfIdpHwvC2MGabar6t4UDZeX2CMQCXbgsv6AYcZBp5yhdHhzQYnMkxFUBbxo9XmR83ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709629698; c=relaxed/simple; bh=V6enSNG5S4Ac6DTmQkbJL3q6wOC+k2MTupNQ4UWKnOE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=adXL9GLKzuQmgofzh2drxZX/AH6LP/f4ksnvuwUd7OgiXfNYcjcPOoTY8nVB3rQVTM3Pi1FCvVcQPSEPkpBWcQotOLjxIByZsZ4CHHprfMFSA1H4XeJQDDmj3XEo/e84Jul2Ux2vmzHnaDpb3amsm6ydtiEGBUakla9/aXHbyDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A7271FB; Tue, 5 Mar 2024 01:08:53 -0800 (PST) Received: from [10.57.68.162] (unknown [10.57.68.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3A6D43F762; Tue, 5 Mar 2024 01:08:14 -0800 (PST) Message-ID: <6c16c7c5-8cf4-4c30-b3a5-a9ab55b21114@arm.com> Date: Tue, 5 Mar 2024 09:08:12 +0000 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-GB To: Barry Song <21cnbao@gmail.com>, "Huang, Ying" Cc: akpm@linux-foundation.org, linux-mm@kvack.org, david@redhat.com, chrisl@kernel.org, yuzhao@google.com, hanchuanhua@oppo.com, linux-kernel@vger.kernel.org, willy@infradead.org, xiang@kernel.org, mhocko@suse.com, shy828301@gmail.com, wangkefeng.wang@huawei.com, Barry Song , Hugh Dickins References: <20240304103757.235352-1-21cnbao@gmail.com> <878r2x9ly3.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 05/03/2024 08:56, Barry Song wrote: > are writing pte to zero(break) before writing a new value(make). while As an aside, "break-before-make" as defined in the Arm architecture would also require a TLBI, which usually isn't done for these write-0-modify-prots-write-back operations. Arm doesn't require "break-before-make" in these situations so its legal (as long as only certain bits are changed). To my understanding purpose of doing this is to avoid races with HW access/dirty flag updates; if the MMU wants to set either flag and finds the PTE is 0 (invalid) it will cause an exception which will be queued waiting for the PTL. So I don't think you really mean break-before-make here. > this behavior is within PTL in another thread, page_vma_mapped_walk() > of try_to_unmap_one thread won't take PTL till it meets a present PTE. > for example, if another threads are modifying nr_pages PTEs under PTL, > but we don't hold PTL, we might skip one or two PTEs at the beginning of > a large folio. > For a large folio, after try_to_unmap_one(), we may result in PTE0 and PTE1 > untouched but PTE2~nr_pages-1 are set to swap entries. > > by holding PTL from PTE0 for large folios, we won't get these intermediate > values. At the moment we get PTL, other threads have done.