Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp968152iog; Thu, 30 Jun 2022 14:03:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uSkOjiw+CQlRJt0eYVEM9ZxwSly8wHBTY2hfs4+/lrcG3xPbza9MD36DG1P1+Xfd8uhVOK X-Received: by 2002:a17:902:7d94:b0:168:f2b5:a989 with SMTP id a20-20020a1709027d9400b00168f2b5a989mr16511941plm.50.1656623012769; Thu, 30 Jun 2022 14:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656623012; cv=none; d=google.com; s=arc-20160816; b=CctL3VU+eklmcku+Q7AQm02aQ4YBkWNDw9Ri587Fs4K6GvlZ4nSzNwyx0XLhsbkcB9 HRH+CPeK6lqyE0Ko0IT+4uK1nmQ4ntjxnxOYQN6tt2xlIm3Ko4VmbO5jkhLB/tLPW/Tx p7qNDbPcbpWmNBsV77PGBfvzz8K4hPLLQf3xNNgs5T9Mg+Rq4x4DRh/2I4hooIKWMrrF uHD4nMm8flH28n9zF7c7AaDmOfMU4gxs4EfPLKLhOof+xO3a9zrekKZIcuqM58nyg/5W 8QRX2vqvtg0uhhQD/32p+HnJfG+GCKzz7Y4j8PqhXDpjbQVQeuS8SN6z6rPkGSMKI2M4 O1Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=cs91WyVesi99NqFGAEv3+PryqGuZwEkmE4TutiLYwN4=; b=NX/y6qawHIiLJP2OnU6W8B/xdFZJjGtRT0mwW6Jsg/3gXBIIKYDcY7WD07i5IveCCc BC6FcAjbx7ZW9ZVs6LK0X7LqcuDUprlIhGFYykbJEN+BWUpgm5vpeFEfhgxqRFvFUsI1 WlAS//Crq41kaQspglB0sROb9kIkAcgGXpXJ7FqCHu5t5TRP1AGA6uxZ16/gVUPKDtIx YWwkRWIkaMFIrvcnUvJ7aDnB4ooBlSKCJ803yhpC7qjDNW+4OhgghTSI+faGjXOlfeZD 5sXjz1VUYQS+jn9UlZKWJmFXGMtfhccM0vuIO0Y3QsvGLAQUoOoXhO7lqJ9GFHIIj9Eo fu/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GFobmnGz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 t4-20020a1709028c8400b001619fb0b872si1025638plo.618.2022.06.30.14.03.09; Thu, 30 Jun 2022 14:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=GFobmnGz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S237065AbiF3U4Q (ORCPT + 99 others); Thu, 30 Jun 2022 16:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232936AbiF3U4Q (ORCPT ); Thu, 30 Jun 2022 16:56:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0022E3F89F for ; Thu, 30 Jun 2022 13:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656622574; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cs91WyVesi99NqFGAEv3+PryqGuZwEkmE4TutiLYwN4=; b=GFobmnGzXZZ5xmq3c4odqlUMDeXoILxDr9NNxFFeNpLmygnKHi5wadatfEXfqiAusZeY8p XFLpYysngdgHl7DIvQiBeKeHYH4iMLDWgBHCg1Z18BgLuUbt9Ib/hSCVZsh/uzRm7tQVzn wxBh8wjpIPTMVpKqhUf1veo9hHIu4sE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-82JKDJA-N5WYcOXwkye-ug-1; Thu, 30 Jun 2022 16:56:05 -0400 X-MC-Unique: 82JKDJA-N5WYcOXwkye-ug-1 Received: by mail-wm1-f72.google.com with SMTP id v8-20020a05600c214800b003a1819451b1so224898wml.7 for ; Thu, 30 Jun 2022 13:56:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=cs91WyVesi99NqFGAEv3+PryqGuZwEkmE4TutiLYwN4=; b=IIdqHX36Sv+geS05ABnHTgsLVrI2cn4CvQFGTB5OPfJhgGv2sjVzrrKqF8LSjm+A+u ldDQzAEpSgTxJKTmvjPjKwO0lof5HIaOPVQgUpUz7dF03jFV7/VSQHo24KOLd9YvNobz u0cF+H2Lh4T3//pSm+gGsx3qQTP3llyPcRUs5gRwnQ5IfAQcjr/jUck4W7wAT59io8RZ 4z3Nsm9weLEY28C49PyHOk51BuIuckI7IbWlCY+jAGUSA0vGuqgVTyzQUaMX6siClwhz hD8clhooeDcAQk49r/H9yji+4ygBMILXsup7a0PADiF0jcpmzRXXyDMxiBX2hzxP2BJ/ tW9A== X-Gm-Message-State: AJIora9mCPtlZ03lvu1mNY4UNJHRUhSaQXyzeKOk8AyE3Dr0j6oaKT2u NlC+1skyjXeg2+lIerXstxQadh3+MYhSagtHNxhhaloAXpXdyGN78bM4Ga7rhseQfG/xdqOWIiH +7Q4Ou75r3j5s6cUzVvCLxg== X-Received: by 2002:a05:600c:22d0:b0:3a0:3bb9:3936 with SMTP id 16-20020a05600c22d000b003a03bb93936mr14637980wmg.137.1656622563847; Thu, 30 Jun 2022 13:56:03 -0700 (PDT) X-Received: by 2002:a05:600c:22d0:b0:3a0:3bb9:3936 with SMTP id 16-20020a05600c22d000b003a03bb93936mr14637943wmg.137.1656622563542; Thu, 30 Jun 2022 13:56:03 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:7f00:214b:cffb:c693:2b71? (p200300cbc7087f00214bcffbc6932b71.dip0.t-ipconnect.de. [2003:cb:c708:7f00:214b:cffb:c693:2b71]) by smtp.gmail.com with ESMTPSA id p3-20020a05600c064300b0039c8a22554bsm7666219wmm.27.2022.06.30.13.56.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jun 2022 13:56:02 -0700 (PDT) Message-ID: <24577304-15ea-0c9c-9b73-946143bf2726@redhat.com> Date: Thu, 30 Jun 2022 22:56:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: en-US To: Alistair Popple Cc: Alex Sierra , jgg@nvidia.com, Felix.Kuehling@amd.com, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jglisse@redhat.com, willy@infradead.org, akpm@linux-foundation.org References: <20220629035426.20013-1-alex.sierra@amd.com> <20220629035426.20013-5-alex.sierra@amd.com> <956b1c51-b8f1-0480-81ca-5d03b45110f7@redhat.com> <878rpe73t3.fsf@nvdebian.thelocal> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v7 04/14] mm: add device coherent vma selection for memory migration In-Reply-To: <878rpe73t3.fsf@nvdebian.thelocal> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-ext4@vger.kernel.org On 30.06.22 13:44, Alistair Popple wrote: > > David Hildenbrand writes: > >> On 29.06.22 05:54, Alex Sierra wrote: >>> This case is used to migrate pages from device memory, back to system >>> memory. Device coherent type memory is cache coherent from device and CPU >>> point of view. >>> >>> Signed-off-by: Alex Sierra >>> Acked-by: Felix Kuehling >>> Reviewed-by: Alistair Poppple >>> Signed-off-by: Christoph Hellwig >> >> >> I'm not too familiar with this code, please excuse my naive questions: >> >>> @@ -148,15 +148,21 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, >>> if (is_writable_device_private_entry(entry)) >>> mpfn |= MIGRATE_PFN_WRITE; >>> } else { >>> - if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) >>> - goto next; >> >> Why not exclude MIGRATE_VMA_SELECT_DEVICE_PRIVATE here? IIRC that would >> have happened before this change. > > I might be missing something as I don't quite follow - this path is for > normal system pages so we only want to skip selecting them if > MIGRATE_VMA_SELECT_SYSTEM or MIGRATE_VMA_SELECT_DEVICE_COHERENT aren't > set. > > Note that MIGRATE_VMA_SELECT_DEVICE_PRIVATE doesn't apply here because > we already know it's not a device private page by virtue of > pte_present(pte) == True. Ah, stupid me, pte_present(pte) is the key. > >>> pfn = pte_pfn(pte); >>> - if (is_zero_pfn(pfn)) { >>> + if (is_zero_pfn(pfn) && >>> + (migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) { >>> mpfn = MIGRATE_PFN_MIGRATE; >>> migrate->cpages++; >>> goto next; >>> } >>> page = vm_normal_page(migrate->vma, addr, pte); >>> + if (page && !is_zone_device_page(page) && >> >> I'm wondering if that check logically belongs into patch #2. > > I don't think so as it would break functionality until the below > conditionals are added - we explicitly don't want to skip > is_zone_device_page(page) == False here because that is the pages we are > trying to select. > > You could add in this: > >>> + !(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) > > But then in patch 2 we know this can never be true because we've already > checked for !MIGRATE_VMA_SELECT_SYSTEM there. Ah, okay, thanks Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb