Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp787757ybt; Wed, 24 Jun 2020 11:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrqFT4uiajGEkVvyziTUnCabbqA5izfzXSzvg6kaMG5OfBpR6KNlKZ/a8H2zBllLVHh2gn X-Received: by 2002:a50:fe18:: with SMTP id f24mr13104672edt.14.1593022338006; Wed, 24 Jun 2020 11:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593022338; cv=none; d=google.com; s=arc-20160816; b=BxSwd9JR2FTncbc+cL65Y9HbxGlBV2g78KHBew5BOJ7QAl0xDlgW+RnxGML2M1Ywj9 PHODRn9Se1xgOgMRH7QypdBKxIXL/QjheYAnzAHW9owEQ2GG1JvjV3aNRi6tWQZ/iWBl 6ro1DOd36Cpsgw7hWuFGakVWAwutvJJm0qJZ8JrT6TUWmMQ4p58trKe25EkTRxoNhA3N oCreoxhPvto6QIrOrFlx0sHi6+hWYh4KPnFSiOtq5Jzz096w2ZYiE3uCkBEnu+n3/8Z2 4ciz5QM4Y7/K4z8dKthbM8Pc5ODT4j8fsExxIWoOgSRu02KgUNZQZfIXl040Jy5wAj/c YEjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=v8AB7qsvs43N+0jRYQSXO+VJlE9cLuPEgWDCbTOxaBo=; b=Xi+u4se4186LooGRP915cv8rFfgDBxIra/4sAV13alvZTwURk6ZO9fAy+UON1GkL14 rwpT1ACAkjiiGZ+GiKLKZWASu7FpL3iAXCGVNHjZTK/mEk5QB7tMp/cawl+DkaJNXLgj mz7kL4q0zqmmJ6hZZZ5Mc40MMsGRDggm6g6+VmCkzbGTumfffIs2vq28Rt8iWvtXEGey Jcw3+87OFr4lxR3AqzZaGbHeZT4dUEGq0YpVczyaet+c06tAkTuq+KTqcEzLpD4NYy2c bs3G/ix0PtOwtIUbSaD84WYXsItb16IsQf+lyX6YWwdMqd39ukVQiu70FPdEJ20UND0W C0Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=XcF7e2eY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d16si13103333eja.32.2020.06.24.11.11.52; Wed, 24 Jun 2020 11:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=XcF7e2eY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405137AbgFXSLE (ORCPT + 99 others); Wed, 24 Jun 2020 14:11:04 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:9403 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405002AbgFXSLE (ORCPT ); Wed, 24 Jun 2020 14:11:04 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 24 Jun 2020 11:10:18 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 24 Jun 2020 11:11:04 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 24 Jun 2020 11:11:04 -0700 Received: from rcampbell-dev.nvidia.com (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 24 Jun 2020 18:10:55 +0000 Subject: Re: [RESEND PATCH 2/3] nouveau: fix mixed normal and device private page migration To: Christoph Hellwig CC: , , "Jerome Glisse" , John Hubbard , "Jason Gunthorpe" , Ben Skeggs References: <20200622233854.10889-1-rcampbell@nvidia.com> <20200622233854.10889-3-rcampbell@nvidia.com> <20200624072355.GB18609@lst.de> From: Ralph Campbell X-Nvconfidentiality: public Message-ID: <330f6a82-d01d-db97-1dec-69346f41e707@nvidia.com> Date: Wed, 24 Jun 2020 11:10:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200624072355.GB18609@lst.de> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1593022218; bh=v8AB7qsvs43N+0jRYQSXO+VJlE9cLuPEgWDCbTOxaBo=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=XcF7e2eY9wqoGbIb+q0hlnCZ/aWuEywTrNd+N4L4Essfz340HGSxkpc1ljpr1gpus TYusA4foHTlYUOOM+r3sBtmdh2VuFUmY7hnTMDJNrmr3mnqALg8aLc8pJyTq45agq8 5QrKwM8xhvnHbGxx04z9MkU7Xn4z3SXmz1aaJE1z32/i9rO2QKJIrORoCdYqlGH+lH cHqn3pJe9GeBfSvOF90XWpUVGlpbDnaH4+a3Q5X7ERDb+ifB4Uj4MvTfp+c7qr+iHg etCGbdCdeUxoxmbOhGldwfksGpVUYMYARU3/e4z3Pxsj0lPCf7h/FKIjwmB9rzxKSj Pz9HFIyT0NVzQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/24/20 12:23 AM, Christoph Hellwig wrote: > On Mon, Jun 22, 2020 at 04:38:53PM -0700, Ralph Campbell wrote: >> The OpenCL function clEnqueueSVMMigrateMem(), without any flags, will >> migrate memory in the given address range to device private memory. The >> source pages might already have been migrated to device private memory. >> In that case, the source struct page is not checked to see if it is >> a device private page and incorrectly computes the GPU's physical >> address of local memory leading to data corruption. >> Fix this by checking the source struct page and computing the correct >> physical address. > > I'm really worried about all this delicate code to fix the mixed > ranges. Can't we make it clear at the migrate_vma_* level if we want > to migrate from or two device private memory, and then skip all the work > for regions of memory that already are in the right place? This might be > a little more work initially, but I think it leads to a much better > API. > The current code does encode the direction with src_owner != NULL meaning device private to system memory and src_owner == NULL meaning system memory to device private memory. This patch would obviously defeat that so perhaps a flag could be added to the struct migrate_vma to indicate the direction but I'm unclear how that makes things less delicate. Can you expand on what you are worried about? The issue with invalidations might be better addressed by letting the device driver handle device private page TLB invalidations when migrating to system memory and changing migrate_vma_setup() to only invalidate CPU TLB entries for normal pages being migrated to device private memory. If a page isn't migrating, it seems inefficient to invalidate those TLB entries. Any other suggestions?