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 X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34CB6C433DF for ; Sun, 23 Aug 2020 13:21:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E64B2206C0 for ; Sun, 23 Aug 2020 13:21:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FZq3Un6J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E64B2206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7E0036B0002; Sun, 23 Aug 2020 09:21:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 790416B0003; Sun, 23 Aug 2020 09:21:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A6038D0002; Sun, 23 Aug 2020 09:21:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 54CC66B0002 for ; Sun, 23 Aug 2020 09:21:40 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1598D180AD820 for ; Sun, 23 Aug 2020 13:21:40 +0000 (UTC) X-FDA: 77181895560.07.bells16_50149962704a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id E4ECA1803F9AC for ; Sun, 23 Aug 2020 13:21:39 +0000 (UTC) X-HE-Tag: bells16_50149962704a X-Filterd-Recvd-Size: 6536 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Sun, 23 Aug 2020 13:21:39 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id q3so1619772pls.11 for ; Sun, 23 Aug 2020 06:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=B8k8A6mqkAf4Abkd337/J3hCnYeAjf22Nhb3MAscNIk=; b=FZq3Un6JF89tRn1uFKQYwRCucYJapkFL072YvjpoJLMkz6gI3fWTBx7Lg7Y7JKonYe toBfH8PwTH4N803BBtGbq2NuaJ+rC3q1haB2tRf2G4exNDTUS0wo8AJftCdIztldalO7 nqJfO7A4YV47UXyOHDJch6SmG9NEmQIvrm/4BF9vGFoxtv8od2hKEpOUmcFnMJxRinhz gmS56nN39OzLT0U0OvzD5ZsH4fOZB5vY1p8vnZ037QS73biRLDcnGukQsmIRIYTD5svo plVADtPG5MB5QcoBVoCcXsxktYV/N8Js0Zh9+9YWHUsHAKQPA/iTUDxwejMrxhrfMgzZ vqMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=B8k8A6mqkAf4Abkd337/J3hCnYeAjf22Nhb3MAscNIk=; b=VcRvb/9tK9F927K4Pgt0cBjIa2qcCnnO4f+S1e2WJz28F7aUVRaFE4EAPK+2/HGPPt /HbGZeEs/lwixUrK+d15xC8XZn4isqo9IXqXFqwhF9y+pvLnSvrQ+elfXe+yBUwEHvUF CyC+jW+1YOA4vY6A49+TPD90VcbfgetkWbmdY3n13l4W87d3fo8KY93SSg2OLSuznaRH 1/yf+ghtb+mvIR3rV4j29ct92iy3fWtFbOiCL7Yuy14vaFIDrKHBOlehKipzdtAZjOsy 61Wr3pz14Zam12TZSrlulNmxKbnfJMRbWLMgN1WF8xcyOtCwhT8subFLUmEJv7h98576 yXug== X-Gm-Message-State: AOAM531OUCQopuCXXRUtngD/sNDRSRCv11l+Uv/1tzZN/dlrE0Rpepj+ mHy9NboblL1zeYL50qPTf9c= X-Google-Smtp-Source: ABdhPJyv6ATRN7kHSAV4fChnuJ/M0Ib5RmobeWRrr4OxRQnSwGBydDM0Rr0plbCLfp7c0MZEczii5A== X-Received: by 2002:a17:90b:4c46:: with SMTP id np6mr1080502pjb.201.1598188898654; Sun, 23 Aug 2020 06:21:38 -0700 (PDT) Received: from [192.168.1.7] ([1.23.2.212]) by smtp.gmail.com with ESMTPSA id u65sm8112219pfb.102.2020.08.23.06.21.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Aug 2020 06:21:38 -0700 (PDT) Subject: Re: Regarding HMM To: John Hubbard , Ralph Campbell , linux-mm@kvack.org Cc: jglisse@redhat.com References: <3482c2c7-6827-77f7-a581-69af8adc73c3@nvidia.com> <9af4d56c-61f5-9367-28bf-b6f1236e90fa@nvidia.com> From: Valmiki Message-ID: Date: Sun, 23 Aug 2020 18:51:35 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <9af4d56c-61f5-9367-28bf-b6f1236e90fa@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E4ECA1803F9AC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000132, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 19-08-2020 02:05 am, John Hubbard wrote: > On 8/18/20 10:06 AM, Ralph Campbell wrote: >> >> On 8/18/20 12:15 AM, Valmiki wrote: >>> Hi All, >>> >>> Im trying to understand heterogeneous memory management, i have >>> following doubts. >>> >>> If HMM is being used we dont have to use DMA controller on device for >>> memory transfers ? > > Hi, > > Nothing about HMM either requires or prevents using DMA controllers. > >>> Without DMA if software is managing page faults and migrations, will >>> there be any performance impacts ? >>> >>> Is HMM targeted for any specific use cases where DMA controller is >>> not there on device ? >>> >>> Regards, >>> Valmiki >>> >> >> There are two APIs that are part of "HMM" and are independent of each >> other. >> >> hmm_range_fault() is for getting the physical address of a system >> resident memory page that >> a device can map but is not pinned in the usual way I/O increases the >> page reference count >> to pin the page. The device driver has to handle invalidation >> callbacks to remove the device >> mapping. This lets the device access the page without moving it. >> >> migrate_vma_setup(), migrate_vma_pages(), and migrate_vma_finalize() >> are used by the device >> driver to migrate data to device private memory. After migration, the >> system memory is freed >> and the CPU page table holds an invalid PTE that points to the device >> private struct page >> (similar to a swap PTE). If the CPU process faults on that address, >> there is a callback >> to the driver to migrate it back to system memory. This is where >> device DMA engines can >> be used to copy data to/from system memory and device private memory. >> >> The use case for the above is to be able to run code such as OpenCL on >> GPUs and CPUs using >> the same virtual addresses without having to call special memory >> allocators. >> In other words, just use mmap() and malloc() and not clSVMAlloc(). >> >> There is a performance consideration here. If the GPU accesses the >> data over PCIe to >> system memory, there is much less bandwidth than accessing local GPU >> memory. If the >> data is to be accessed/used many times, it can be more efficient to >> migrate the data >> to local GPU memory. If the data is only accessed a few times, then it >> is probably >> more efficient to map system memory. >> > > Ralph, that's a good write-up! > > Valmiki, did you already read Documentation/vm/hmm.rst, before posting > your question? > > It's OK to say "no"--I'm not asking in order to criticize, but in order > to calibrate > the documentation. Because, we should consider merging in Ralph's > write-up above > into hmm.rst, depending on if it helps (which I expect it does, but I'm > tainted by > reading hmm.rst too many times and now I can't see what might be missing). > > Any time someone new tries to understand the system, it's an opportunity > to "unit test" > the documentation. Ideally, hmm.rst would answer many of a first-time > reader's questions, > that's where we'd like to end up. > > > thanks, Hi John, i did give initial reading, but Ralph details on migration_* API's above helped a lot to clarify things better, yes adding above details into hmm.rst would help beginners. Regards, Valmiki