Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3987471ybb; Mon, 23 Mar 2020 11:22:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt0xOk9+XaG1aYxrGgk2WDONLM7wjpaMI5dRYB440rQr6dZa2n1QRUEy8Qls2V6QF1S+QAj X-Received: by 2002:a05:6830:19ea:: with SMTP id t10mr18955668ott.200.1584987756851; Mon, 23 Mar 2020 11:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584987756; cv=none; d=google.com; s=arc-20160816; b=OCmjG4uynx62C+K//qH4smiBE0zaAFYM2Ot3DYBezm5G/9Ux0NEPp/sUNdXM8/q1Fg AsnJSDq1lbz1VZ0PSR4lc8QCvyoR2nYv6vm9H+54XGV2SGPIs4PeHcb4XBbSz1vVXDsw Zanh/nPvtI3KrIMm6zbPvWy94Gyi/tD6aSs39J3t0coY74zB8CnOV3BGwumwoq492RSQ FZKt8fz2TGEWSOIeVBfAsRS/R7d2yN0QA/jMOk9pmp6ewDNFnn/gRKWmaAukc+kSbfBB VvI82Q/dONgbJgVhWWpuAI9iT81E40nXnZIfwwa0Dx9+3fa/kcqMY7BrJFcuqQYLfNdc NARQ== 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=1Wek6LBYAdU1aHIlmdcVgKcV0g9ZqFumuUlMbDqQya8=; b=zDOTeX7EQ8sUOa7V/z6+5ZfhjZ1OnKf70//nF0DJtHz5vlNwOcqmjVHksp0EmcsZTp n5+HgXSyDsbcHPcWaDBqpo01kqTUPzkwFIwbfvWVGlls/E52JOQFMAWeZB4alIaJVGTh /SVNKi70C16U4irIMc0/ZEt+uqmqMokVEv3TgYoMN5eGcOFSICKkgQMJibK6t95qP/b8 wuw+21K96c7zTCYntw7n+rHRHiqm1/Yj1RkEQ7YoULPkyDelNysuwlZezX3hp7j2xsVB LCkFEPwsW1LYuqTglE6B7NooXhuLr6rm8fhwZG2bn/YA9tshEQWEB1DFWikrGJOAgKxs C/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=V6XX7qH9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id k193si7756186oih.78.2020.03.23.11.22.24; Mon, 23 Mar 2020 11:22:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=V6XX7qH9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727283AbgCWSVR (ORCPT + 99 others); Mon, 23 Mar 2020 14:21:17 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:2790 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727091AbgCWSVQ (ORCPT ); Mon, 23 Mar 2020 14:21:16 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 23 Mar 2020 11:21:02 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 23 Mar 2020 11:21:15 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 23 Mar 2020 11:21:15 -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; Mon, 23 Mar 2020 18:21:15 +0000 Subject: Re: [PATCH v8 0/3] mm/hmm/test: add self tests for HMM To: Leon Romanovsky , Jason Gunthorpe CC: Jerome Glisse , John Hubbard , Christoph Hellwig , Andrew Morton , Shuah Khan , , , , References: <20200321003108.22941-1-rcampbell@nvidia.com> <20200321090047.GM514123@unreal> <396f0c30-4a49-6a18-ff02-a73ee1a09883@nvidia.com> <20200321215505.GW20941@ziepe.ca> <20200322081038.GG650439@unreal> From: Ralph Campbell X-Nvconfidentiality: public Message-ID: <010050db-a37d-d200-88d4-696cc2c8d9d6@nvidia.com> Date: Mon, 23 Mar 2020 11:21:13 -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: <20200322081038.GG650439@unreal> 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=1584987662; bh=1Wek6LBYAdU1aHIlmdcVgKcV0g9ZqFumuUlMbDqQya8=; 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=V6XX7qH92buUCwPTHr32tVk37r9DCwWiP01gZ5NQeioLh2l4m+RDLIaGzQFmE8xKW 9/9K4I5SpNQDgrdpE8b4vsxDz1hF89T0L/c6ByepnxqI1t6ti/j72xBQ9/dn/F8nV6 Wo4ZwOBBiq7JgsD3MPAa6a1LK6MWvXuNW0KdD/ac0hLX6xK8K25QJw2JYFDH4wXJzb ac8IxYzO30X+L8jxW31n/NglXxNBSsNufj05l8/Ih8O2Sjp6v/4e1vKAHYosj1IfeM PvKEoZrvRH0HnckdaiMqeu01h824HMlqbHXQEZwriSE2Q6iDBk4tOKGOYAsamku+pt ctx4qI2Fc5iaw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/22/20 1:10 AM, Leon Romanovsky wrote: > On Sat, Mar 21, 2020 at 06:55:05PM -0300, Jason Gunthorpe wrote: >> On Sat, Mar 21, 2020 at 10:27:46AM -0700, Ralph Campbell wrote: >>> >>> On 3/21/20 2:00 AM, Leon Romanovsky wrote: >>>> On Fri, Mar 20, 2020 at 05:31:05PM -0700, Ralph Campbell wrote: >>>>> This series adds basic self tests for HMM and are intended for Jason >>>>> Gunthorpe's rdma tree which has a number of HMM patches applied. >>>>> >>>>> Changes v7 -> v8: >>>>> Rebased to Jason's rdma/hmm tree, plus Jason's 6 patch series >>>>> "Small hmm_range_fault() cleanups". >>>>> Applied a number of changes from Jason's comments. >>>>> >>>>> Changes v6 -> v7: >>>>> Rebased to linux-5.6.0-rc6 >>>>> Reverted back to just using mmu_interval_notifier_insert() and making >>>>> this series only introduce HMM self tests. >>>>> >>>>> Changes v5 -> v6: >>>>> Rebased to linux-5.5.0-rc6 >>>>> Refactored mmu interval notifier patches >>>>> Converted nouveau to use the new mmu interval notifier API >>>>> >>>>> Changes v4 -> v5: >>>>> Added mmu interval notifier insert/remove/update callable from the >>>>> invalidate() callback >>>>> Updated HMM tests to use the new core interval notifier API >>>>> >>>>> Changes v1 -> v4: >>>>> https://lore.kernel.org/linux-mm/20191104222141.5173-1-rcampbell@nvidia.com >>>>> >>>>> Ralph Campbell (3): >>>>> mm/hmm/test: add selftest driver for HMM >>>>> mm/hmm/test: add selftests for HMM >>>>> MAINTAINERS: add HMM selftests >>>>> >>>>> MAINTAINERS | 3 + >>>>> include/uapi/linux/test_hmm.h | 59 ++ >>>> >>>> Isn't UAPI folder supposed to be for user-visible interfaces that follow >>>> the rule of non-breaking user space and not for selftests? >>>> >>>> Thanks >>>> >>> >>> Most of the other kernel module tests seem to invoke the test as part of the >>> module load/init. I'm open to moving it if there is a more appropriate location. >> >> Is it even possible to create a user mm_struct and put crazy things in >> it soley from a kernel module? > > I didn't look very closely of what Ralph did in his patchsets, but from > what I know, if you want in-kernel interface, you use in-kernel module, > if you want to test user visible uapi, you write application. You don't > create new UAPI just to test something in the kernel. > > Can kunit help here? > https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html > > Thanks > >> >> Jason The tests are intended to cover hmm_range_fault() and the migrate_vma_setup(), migrate_vma_pages(), and migrate_vma_finalize() kernel functions that a device driver can call to initialize hardware that has its own page tables. An example is a GPU where the code on the GPU sees the same address space as code running on the host CPU. This means the test has to have a user process to create a user process address space and a device driver to simulate some real device driver. The UAPI is for the user level test program to tell the kernel module test driver what to do and return results. The complexity is all around maintaining coherent copies of the user process page tables while hardware and CPUs are accessing the same physical addresses. The pages are not pinned as with most I/O so system activity like pagein/pageout, LRU page reclaim, compaction, and the process calling functions like mmap(), mprotect(), madvise(), fork(), etc. all update the CPU and device page tables and would be very hard to duplicate in a kernel level only KUNIT style of test.