Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3017737rwb; Mon, 15 Aug 2022 16:14:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR5uvNbIg+glO6rSpzO9ZDoVdpYWpDQUvJ/9b8mPSHyPWjWGtap8NNSj98ElyE7HF6FYge+Q X-Received: by 2002:a17:907:c06:b0:701:eb60:ded with SMTP id ga6-20020a1709070c0600b00701eb600dedmr12040762ejc.178.1660605265593; Mon, 15 Aug 2022 16:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605265; cv=none; d=google.com; s=arc-20160816; b=BnNtU6dBFr9X7pSeZq+Wbw3IKT6uue3ovceT5ItbBdNTmeaqtuQTqniNbalZfzxrMd wJYYeMA+7fz2hNjzTX6orAXiSZ1InkIlWuIqIxm4H8UU1L/uDNSyonY0Zu0IeIkxUuRS vu9JTB4j4P0twProP72g2Wgg+Jgzxig8v69GY1w7Ma+6zmHz+EpsZm76TUYaAdpK8Xbg 7sj+y97BiVSzEAR7xArePEb1jSDxUCmztvglKxM3ulzwzr8lE5y/cShtggYeTJqUYnuU 76Xug4pIVG5iJReILBtbtrogPQy0X6qV+NLwRt3LnDN2EVUViKPB1Bt3RdW0IXiTCDSu IM5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=trYiUZWGHSUh+Fi/mUD7Vj9TWPb8FmuPVtaP1Bo49SM=; b=NPRe5CY7vv7ZwlkV7h3e2d4t+fYXwrUQB8ugkyqRqlFSWP/DMYjgw/XU/436DWwoGi TbhKsbMpyqvVFjLo0VA3T3FnJ2UD3P2Z/OrRq0PdxVxvD+rLOMee8mohiwxm4PxikJHe 7quN1mP0aej98PaskzWt2xsrSfrk1WPbg3fB0mPMbQE1RgOBwu5RO5npvt2kxnyJFyDE Blpt7VDl++hYi8/prKUfbF2y1ghsIsLmt7TAqbaxdMGkLn4VU2et5Gnzd70r5cLJGYhy RZRrQ0y3WIhuDHJbFk73ooY8Vj9LBCkgXTHjR1HTVWXwfIZPHgIlMNtttTTlngxzmWtN VdcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sp3BtlDz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ej27-20020a056402369b00b00443b1e53479si3659142edb.374.2022.08.15.16.14.01; Mon, 15 Aug 2022 16:14:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sp3BtlDz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347449AbiHOVSY (ORCPT + 99 others); Mon, 15 Aug 2022 17:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244087AbiHOVJc (ORCPT ); Mon, 15 Aug 2022 17:09:32 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D72D255082 for ; Mon, 15 Aug 2022 12:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660591134; 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=trYiUZWGHSUh+Fi/mUD7Vj9TWPb8FmuPVtaP1Bo49SM=; b=Sp3BtlDzZGXKUSB5ED1mDrxz5KXpE5SdfJnFXsyMdu9keO69E5vaxuC4c0/sahVHWvNmIb Xssf6QUmC1z/cyIRyRZf7CpG5dEvoYywKz0jjb4S+tzgGayZT+DGD2Io7f24l4iI4qzOKC 31fKxjW8qO+IVIPhvcepG92DmWfEMrU= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-520-_zc38eWzOaCR0ifSMl8uyQ-1; Mon, 15 Aug 2022 15:18:53 -0400 X-MC-Unique: _zc38eWzOaCR0ifSMl8uyQ-1 Received: by mail-qk1-f198.google.com with SMTP id j19-20020a05620a289300b006b949aff6ddso7642890qkp.0 for ; Mon, 15 Aug 2022 12:18:53 -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=trYiUZWGHSUh+Fi/mUD7Vj9TWPb8FmuPVtaP1Bo49SM=; b=DPUrmudcmhvc21eIcK+YJAp+S6C4exydKKEb2zLxyRM5KP/TkWEjLAkQ0lQY0vaR6E EcAa6h2hClwzBxfrB7A4s7Kld8UqZrcNLUBDQ+R1kdVaY2GR6XOZoxRdGGfU1kAO68n6 CBYzFlJx0dytE2p0yjLXv1IHX0aJphbTrY1XByc6EWtbB1uUUaKEJnGHmRFGItz8vl+h 9y3q7QZu/9j8jtSh0ZUve68hRGoNgZ1HwyfNxkr/66cO4G8uKd+vTje9gOtO+Df97LUI jNmhWQTfatvBbACdYs6CAtJTnEYJu70tX+NBuqWP439TNixTOyHs/dJM1d66cGcxB8NN w01A== X-Gm-Message-State: ACgBeo1GpJEatwPxZc+Ma/lQTSx5Qi7md2h/ueAFBTma+lmEmVbias2l uA8XP0WhWzHsdnlkDiqpxLphg1xG5FXpUPrWPUm/R3qT+ymIA/DmTuhFaW9PJBrIYae7XMXz9ch 9MPPcU2l3rhfLf8s93fn5U5RW X-Received: by 2002:a05:622a:30d:b0:343:63d1:3751 with SMTP id q13-20020a05622a030d00b0034363d13751mr15450249qtw.679.1660591133251; Mon, 15 Aug 2022 12:18:53 -0700 (PDT) X-Received: by 2002:a05:622a:30d:b0:343:63d1:3751 with SMTP id q13-20020a05622a030d00b0034363d13751mr15450229qtw.679.1660591133009; Mon, 15 Aug 2022 12:18:53 -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 bs30-20020a05620a471e00b006b910e588a4sm9888488qkb.129.2022.08.15.12.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 12:18:52 -0700 (PDT) Date: Mon, 15 Aug 2022 15:18:50 -0400 From: Peter Xu To: "Huang, Ying" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Minchan Kim , David Hildenbrand , Nadav Amit , Andrew Morton , Hugh Dickins , Vlastimil Babka , Andrea Arcangeli , Andi Kleen , "Kirill A . Shutemov" Subject: Re: [PATCH v3 5/7] mm: Remember young/dirty bit for page migrations Message-ID: References: <20220809220100.20033-1-peterx@redhat.com> <20220809220100.20033-6-peterx@redhat.com> <87pmh6dwdr.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87pmh6dwdr.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 12, 2022 at 10:32:48AM +0800, Huang, Ying wrote: > Peter Xu writes: > > > On Tue, Aug 09, 2022 at 06:00:58PM -0400, Peter Xu wrote: > >> diff --git a/mm/migrate_device.c b/mm/migrate_device.c > >> index 27fb37d65476..699f821b8443 100644 > >> --- a/mm/migrate_device.c > >> +++ b/mm/migrate_device.c > >> @@ -221,6 +221,10 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > >> else > >> entry = make_readable_migration_entry( > >> page_to_pfn(page)); > >> + if (pte_young(pte)) > >> + entry = make_migration_entry_young(entry); > >> + if (pte_dirty(pte)) > >> + entry = make_migration_entry_dirty(entry); > >> swp_pte = swp_entry_to_pte(entry); > >> if (pte_present(pte)) { > >> if (pte_soft_dirty(pte)) > > > > This change needs to be wrapped with pte_present() at least.. > > > > I also just noticed that this change probably won't help anyway because: > > > > (1) When ram->device, the pte will finally be replaced with a device > > private entry, and device private entry does not yet support A/D, it > > means A/D will be dropped again, > > > > (2) When device->ram, we are missing information on either A/D bits, or > > even if device private entries start to suport A/D, it's still not > > clear whether we should take device read/write into considerations > > too on the page A/D bits to be accurate. > > > > I think I'll probably keep the code there for completeness, but I think it > > won't really help much until more things are done. > > It appears that there are more issues. Between "pte = *ptep" and pte > clear, CPU may set A/D bit in PTE, so we may need to update pte when > clearing PTE. Agreed, I didn't see it a huge problem with current code, but it should be better in that way. > And I don't find the TLB is flushed in some cases after PTE is cleared. I think it's okay to not flush tlb if pte not present. But maybe you're talking about something else? Thanks, -- Peter Xu