From mboxrd@z Thu Jan 1 00:00:00 1970 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.