Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp275168lqs; Tue, 5 Mar 2024 01:26:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUc543jdpKNptrp8PL3pE3yyimzKjrXcXOqwP/aL8+5bzaEDO/xnc6lyzy5y5aVPdeGb915QQjEN/XvLA86/Pr+lgdBMma7rNTPa1/E9g== X-Google-Smtp-Source: AGHT+IFKt2wxtFU/hzAYpdzv++2O8NMsYWjzv8lxjS8/s4FY15VHvwK4RCeGwQD7FawFt5lrc6Xy X-Received: by 2002:a05:6358:724b:b0:178:95b6:f87c with SMTP id i11-20020a056358724b00b0017895b6f87cmr1411714rwa.11.1709630764750; Tue, 05 Mar 2024 01:26:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709630764; cv=pass; d=google.com; s=arc-20160816; b=xFZ5SwGSQfbJXEJlafA6zlrqZ8KDQq8VlMWDyGPUt5qRM2BNUxHEkT6DD4Q/QBwy7U Wq93NjZ5X9UGtsiKZQNI2xhIwpDsXe+HMhU2TUK0GxXGdAXsllQGw61r4Aror51ipVxg F976iJP9VOkrxlhk35xt/bRwGdPXJjAJjOrzF0epCGZ6zE2p6nKZq7DX0+xsaQNRr6zb TvR4tl074/WD5fOZHVaV/f9bgX3M1OD3XoELM9DxadOifa4dSyTJpZiFPwDaKMH9JdL4 SHkPv0PhO/dSMjgbEsZApSOEdc/F5UlX8uE5WMIHgjygGrnmnX/bjZyFleEU6OhMMhix a6+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=HK4MOFklGD0kksSLsuZIfHxojou135gVm+eLOXKc4TA=; fh=W+PrY+MInswHDdwDX0GCFdcaEXVdG9ptaqhr4rdqABg=; b=Uk3IMdgLw1Gt/DcbPToIR7zlh55t0adiV8PuKH+yRWMGqjmIXzo177WafPrLgC5v27 WitDglGE5krQhikqJAQ4CFQ6QPiEXgJxZcjf2Kz43ZS5ZyiOXaaXRF6dsD7XV4FVgG/l Yw1OcXpca2wXyVotFhafGv5ohnAXg/NNCwln1eApu5eSFh5vR2ZdBodU1xV3cCRTpxf4 eoJXLPMaxsy/ZJ5HZ6xTEQheU5br5Krqr/F1an1mAu6MWYeu3adlk5HHebM25jTm5JuE 11vMA819swbzjJ04ouystVLCphNuoWpB/MZzrMJ7QHFCwCzw4+oG17WaQMVAXRTWGqss 1GKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ixPBNacA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-91969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 k5-20020a6568c5000000b005dc49fa1174si9796331pgt.762.2024.03.05.01.26.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 01:26:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91969-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; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ixPBNacA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-91969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 C85D4B252DA for ; Tue, 5 Mar 2024 09:11:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3198B5026E; Tue, 5 Mar 2024 09:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ixPBNacA" Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1BAE4DA1F for ; Tue, 5 Mar 2024 09:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709629911; cv=none; b=dpRuJcVb1XNNsHhqFSX7Gvk4uLcMxXZpWRFAnNJyfTewZl6UBW/A4zvGwmEx94rKhwLO5kyqcuSKr8Z8BsheEt8mM+6GEyLth2coaF3U/S/wfruWazgOmtq+/UcIm6fl+u89RL0ZV+QU3W9gj7G07zU4UGBlsnokfmPAA1upk/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709629911; c=relaxed/simple; bh=lspHgMoDrQwCjSsOqQZMNObR97AWdxVqEXmXExyUvME=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=UFTSMwUsGa/9oUNkD3t0xQkSAJJcemo9GJOY6m/QfaGBYE9vRQ5NsaiCqq8vFdGwHmbraFyJK9u7r6y4NNz4thvuOsLuDl/3Zkbi4kv6gEcf/xH2VFm7Ns0Q9YeQjYnJnsyWCDULarhoA0tp2SUoLaB9QujRzUzoh46nvsP31zw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ixPBNacA; arc=none smtp.client-ip=209.85.221.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-4d332d0db9cso1176361e0c.3 for ; Tue, 05 Mar 2024 01:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709629909; x=1710234709; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HK4MOFklGD0kksSLsuZIfHxojou135gVm+eLOXKc4TA=; b=ixPBNacAZbJ37BCTTj7pe5ptRU10Afa6LbYqjn3tiELLfmuLQaVT6PGwAsEj/D7nT0 zcJxzdzxaY7DlmI9dZIl17L6cM74QRWrJvjoqSd2K0Kbhk2KhTNElfqnqCjYVmyiXps0 2stB/9oim58S0QtzZNEEziIbzDqOqeAliVuaPQ7iGVJk+yZq1kazxs4w2iO7Y8n7O7sH crzljuTzfNuOp56qR34zzBJqshokddRA6Uc8egQBVNq0PgUJ6MJZVp17vgfIwAzA3Sgu 4QDsOTr7vYH3/8pNDnPOZheMd290JF1XnoV6EegUog5WONRVFs8yzIt5t/noul2JIc8O YJlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709629909; x=1710234709; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HK4MOFklGD0kksSLsuZIfHxojou135gVm+eLOXKc4TA=; b=WrYbGWKjRoVw74IVJh0KT9lYznIPCQd+Xf5/h99dS5v65ec7d2GpDKfwxLzZvcY6H9 gejvX/9/3EYjV0GmqhTbAUISt2dBoRY6Y/s6F9oDhU77lb9CnMoX48Rvcele8VAm6bC2 IbrEqjBs12RdOV2owlfENq0PD2r02uiR58OCx63qztAsfA5dqK6YRCTbDicTcHCx8gUl Er57ZSvB8v5fi3pwL/ReVzKCIylomst1iyfqcva9fjmvMs803dzIRtVLswPkICzteI92 lDVUDVffcxyUmNoWtCe9w41YhEXR8CYDkmY8FSQ6gHdS04PuPF2AxQVokFU603SL7nd9 1pWw== X-Forwarded-Encrypted: i=1; AJvYcCU5QaCxDdMs9dOhis7fIl2gCKnPHS5BdT/evE7iQ5guBAwUAh84SRqNyFbPtWmKsmLGhF5yJTItKeGCLJ3JlX6Stez2v0CmlrKvY/b7 X-Gm-Message-State: AOJu0YxQSXFj0eOME2PlArS7VSQKJBUYf5OHBvwARHd3fFm+b1ju/IDD 3OXofbmrBk9pkOYm+lv4bBV5EcRTXE/9HVRrfn1PycuyiQE0rUOYMaYjz1nkn1K7ZV2wohTPyZ4 DEP4pIBRe3P9AHOEGuh/XpuQWu6Y= X-Received: by 2002:a05:6122:2521:b0:4d3:3359:b97d with SMTP id cl33-20020a056122252100b004d33359b97dmr1377973vkb.2.1709629908769; Tue, 05 Mar 2024 01:11:48 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240304103757.235352-1-21cnbao@gmail.com> <878r2x9ly3.fsf@yhuang6-desk2.ccr.corp.intel.com> <6c16c7c5-8cf4-4c30-b3a5-a9ab55b21114@arm.com> In-Reply-To: <6c16c7c5-8cf4-4c30-b3a5-a9ab55b21114@arm.com> From: Barry Song <21cnbao@gmail.com> Date: Tue, 5 Mar 2024 22:11:37 +1300 Message-ID: Subject: Re: [RFC PATCH] mm: hold PTL from the first PTE while reclaiming a large folio To: Ryan Roberts Cc: "Huang, Ying" , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 5, 2024 at 10:08=E2=80=AFPM Ryan Roberts = wrote: > > 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 cer= tain > 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 an= d finds > the PTE is 0 (invalid) it will cause an exception which will be queued wa= iting > for the PTL. > > So I don't think you really mean break-before-make here. I agree I use a stronger term. will change it to something lighter in v2. > > > 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 o= f > > 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 intermedi= ate > > values. At the moment we get PTL, other threads have done. > Thanks Barry