From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A53DC00140 for ; Thu, 18 Aug 2022 15:55:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93FA28E0002; Thu, 18 Aug 2022 11:55:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EFBE8E0001; Thu, 18 Aug 2022 11:55:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7904E8E0002; Thu, 18 Aug 2022 11:55:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 692F18E0001 for ; Thu, 18 Aug 2022 11:55:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 17DEA161D6C for ; Thu, 18 Aug 2022 15:55:56 +0000 (UTC) X-FDA: 79813164270.20.DD99AC1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 693E61613E1 for ; Thu, 18 Aug 2022 15:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660837821; 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: in-reply-to:in-reply-to:references:references; bh=ZlNW+boxKqgfwr0TWqSRLZOIUoJTEM6tD/36NIupE70=; b=HEPYOKtwhA8FmoRkQSXl2UeprtIWTQYFiS7IEH77XqZqNsis1W8Vy9DBjsBlR0ElGUfnxu ZHYojA6WHUhHYdc6JTB02/AU17vSEDt3yPJMekGh910RKHH8CjaS7MgwjwOiwt9DuFxuJw neJyq8typLuL98HzCmhmf2lKwX6limc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660837943; 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: in-reply-to:in-reply-to:references:references; bh=ZlNW+boxKqgfwr0TWqSRLZOIUoJTEM6tD/36NIupE70=; b=DnRwULGvIlEmzzU9IkYUI5RUic3peRXpHn+N32jlQEgUEezo1Z3VIcYGsQ4Kc5ghbc+D2W 4hQIDIQqKJ7YTj5trWLFkZQGuwY/Okk0mD9Ey25iZLJ7xs7XczbowyTFWz48L8QxFCyw+0 cGHkyzdVg8YLDkZRRKKGlxC+KkBQUMo= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-389-6R8wHcs7NdqdGd2HKAOOVQ-1; Thu, 18 Aug 2022 10:44:49 -0400 X-MC-Unique: 6R8wHcs7NdqdGd2HKAOOVQ-1 Received: by mail-qt1-f200.google.com with SMTP id bz20-20020a05622a1e9400b003436a76c6e6so1294978qtb.1 for ; Thu, 18 Aug 2022 07:44:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=ZlNW+boxKqgfwr0TWqSRLZOIUoJTEM6tD/36NIupE70=; b=t9P/mkLvazgTMW0ywVhmz/HKJWOIYitnofKy1BrzWo6/RstZynb6aDnK3r/5BLbaRO 1VUY8UdIgyNwUxGEk5q/FEHbHLR+SypMonNlOIu5l2hhBsxQ/H2Tm54bmmmc+nChoU3P phZ5mTZ+3TOTEg988Nxn0nwgfCxTjYx2JtXg5hUBvsaMnhNZLn+2h431ZubfsHNLwp39 iLC/O3KRE1e/nxTL88sV+qYd5xX7ybZVx8EZwxwzDAaoVMHo/JjE7019Ros2zxUCXRen XIYV22nIwBjia7fPuVz5h66Xan0ca2UcyKBDIyToXUFTzu/uJZGuCCWP1ZV16JTsLwqR NiFw== X-Gm-Message-State: ACgBeo39oW8Iyinomq3s/AxIEvaekiD7SEPKRSAaJcDxAKqbL3b8xB6+ c1PJGWK29HCkzoSM4ADXPbsw/TSdt9/I+Lbez3QocZgysSB/e2M9Mz3TH3IwE9H0iy5bVhFsJEG p+BX4cFnZw6I= X-Received: by 2002:a05:622a:1c3:b0:344:56b5:f14b with SMTP id t3-20020a05622a01c300b0034456b5f14bmr2982394qtw.152.1660833888688; Thu, 18 Aug 2022 07:44:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Y7IFVVzndjOAS+SeXLhYlIl9eakAp1CbXrmWdBV9kzpU04h8jW0ij46cg9iIRTWVE+UYkxA== X-Received: by 2002:a05:622a:1c3:b0:344:56b5:f14b with SMTP id t3-20020a05622a01c300b0034456b5f14bmr2982368qtw.152.1660833888473; Thu, 18 Aug 2022 07:44:48 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id y10-20020a05622a120a00b003435a198849sm1216076qtx.47.2022.08.18.07.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 07:44:47 -0700 (PDT) Date: Thu, 18 Aug 2022 10:44:46 -0400 From: Peter Xu To: "Huang, Ying" Cc: Nadav Amit , Alistair Popple , huang ying , Linux MM , Andrew Morton , LKML , "Sierra Guiza, Alejandro (Alex)" , Felix Kuehling , Jason Gunthorpe , John Hubbard , David Hildenbrand , Ralph Campbell , Matthew Wilcox , Karol Herbst , Lyude Paul , Ben Skeggs , Logan Gunthorpe , paulus@ozlabs.org, linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page Message-ID: References: <6e77914685ede036c419fa65b6adc27f25a6c3e9.1660635033.git-series.apopple@nvidia.com> <871qtfvdlw.fsf@nvdebian.thelocal> <87o7wjtn2g.fsf@nvdebian.thelocal> <87tu6bbaq7.fsf@yhuang6-desk2.ccr.corp.intel.com> <1D2FB37E-831B-445E-ADDC-C1D3FF0425C1@gmail.com> <87czcyawl6.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 In-Reply-To: <87czcyawl6.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HEPYOKtw; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DnRwULGv; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660837973; a=rsa-sha256; cv=none; b=w7SdqyyH51iGUAhK4Fyd475u3F5U9BulE2CVkCNCVb26D3pr9WcTffvgfqDUqNCroFITDU Tl2ivuWSzzBgMGHCSxWPWo72b8T8FnId4DvGlbV6PewnPjy7P1suV7ef9bz5J7N3pBpWBj Nl1raonFTAs94Xxr3wyLhhmbJ8D/So0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660837973; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZlNW+boxKqgfwr0TWqSRLZOIUoJTEM6tD/36NIupE70=; b=ByjdyRLFaqZaNzOkwsjfDOZM3LVHthxG+QI4v53hzjZZnne759EzoRzlnD3pVcxEboEm4k bJ5pVqrGwPmWuDagAgowurv/+Z8qlfGfRPgdcHbZvkFUtW2vN/8NMPxj66KBxUxDCZ9nx0 2eCTkktxXuB9oHaTQYNRBgX/L9W16Q0= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 693E61613E1 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HEPYOKtw; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DnRwULGv; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: n5igafmd4ou9uwoe91niaojyc6a1n9h4 X-Rspam-User: X-HE-Tag: 1660837970-903487 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Aug 18, 2022 at 02:34:45PM +0800, Huang, Ying wrote: > > In this specific case, the only way to do safe tlb batching in my mind is: > > > > pte_offset_map_lock(); > > arch_enter_lazy_mmu_mode(); > > // If any pending tlb, do it now > > if (mm_tlb_flush_pending()) > > flush_tlb_range(vma, start, end); > > else > > flush_tlb_batched_pending(); > > I don't think we need the above 4 lines. Because we will flush TLB > before we access the pages. Could you elaborate? > Can you find any issue if we don't use the above 4 lines? It seems okay to me to leave stall tlb at least within the scope of this function. It only collects present ptes and flush propoerly for them. I don't quickly see any other implications to other not touched ptes - unlike e.g. mprotect(), there's a strong barrier of not allowing further write after mprotect() returns. Still I don't know whether there'll be any side effect of having stall tlbs in !present ptes because I'm not familiar enough with the private dev swap migration code. But I think having them will be safe, even if redundant. Thanks, -- Peter Xu