Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2646836iob; Mon, 16 May 2022 03:03:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7C07ssg5hBCJfhkLdkfARtFZqDM6bmrs/XXhs/WPFm1jaPj9kjmXfImikw7J/dtnXkVXh X-Received: by 2002:a17:906:5d11:b0:6f5:942e:bc60 with SMTP id g17-20020a1709065d1100b006f5942ebc60mr14251222ejt.254.1652695413830; Mon, 16 May 2022 03:03:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652695413; cv=pass; d=google.com; s=arc-20160816; b=eCH+LpxU3dsUtusy23FQhVnrar+sFISl7EaYBx9W89GKHVq7sqthsKEOZYdDzUsACd ll/sFRWi6j51HBTVQsIU1rq0Vsktko+jbkDB3l+Q3p3hdvIxYygpdXDa676YqQRRxsf+ SDoc63cFvhs8L5UCaEktGt6R3C458W8o5wsq36iBJI/46Mg7rN9+8zlFxzYC66+ZtIQR yioU2/jI1aJhkCD6jVaTo1rSQzaCael88qTvYDnxk3+weNV6v0Dbp+9pUL+CklyVloa9 xHR49u+tlFx0eUcjad9tWAaBUbThmHnmNkrbXV5guc7u3KGP5jCcdAWoqojz+qy7s/hH DlJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=s6m5mIAvNMr00pbrrTVXzO/+PDbkBv+yX5Ofg7KGaA8=; b=b2vkajOnobQWAv5kxuE5Lqs1eJ0anTaj/DDzJ4YSrX83se+v1nE1vFAs+uIV2Vi0QV vGcNRsTkdIFAV+KfGgr979J3wpDrM6LDRyiyWl/bL0tI//LjBqOROQHPR6V7gC9Pw0R1 hyI7lz1Ytb42s1IIGSU2TBgjZOzK0Nuf2kl2Yyu8o954nz7yApdy/hIwHDg+ODDvSTun 9ffyM/HmKQTz9fiakFAO1oC2PP6Y2NdBnPhUuURda/g0gpvkH7nVtTG1VUH+ClofA5wa D7rFG8OuqEnAT5vWozCbJ/0KcnMppaz66jkuxV/qLkSitOS8psYgFih5pr0GKb1WxGzI cItg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=OIfY6u+n; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb6-20020a170907160600b006dffbac9704si12465928ejc.747.2022.05.16.03.03.05; Mon, 16 May 2022 03:03:33 -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=@Nvidia.com header.s=selector2 header.b=OIfY6u+n; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238262AbiEPIG7 (ORCPT + 99 others); Mon, 16 May 2022 04:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241375AbiEPIG6 (ORCPT ); Mon, 16 May 2022 04:06:58 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0EAF326DB; Mon, 16 May 2022 01:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X0aMmBz+P8MuW59mqLxtien9L7IzK+7R/gVImCjr/OEuEOUzDAZuZMUqov4q3hlsePfrCcqVmPZqIbzdAOL7YZIxWmvABXeiUhjFYlLTk2Jpv3X6f/yHkZhAEIC5lSeLElU8UroIHpjgUfn0lZMkuCj/KPN5Dv9rO8+JKnPo2j34fYQOI8NoIxJ7cMTtIsmmIKr3QfXTwcu9Yry+WK1wXdhbT/VBjKvVYTogCtuPTBFRje9vntgxR9nyHsz7UzCImiyWLy5s/t5dP5b0NFOizZKxKa9Mq8TK+FeiignK8Jei+z/MdtA3AckhSyVw+nXv3wEv94buJIQ7kQ15d0sNwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s6m5mIAvNMr00pbrrTVXzO/+PDbkBv+yX5Ofg7KGaA8=; b=mdoygEAEISNPG+CzOVKmihCQCpHYzy3ojgeSqMiFFlRjQuUxtoLO3n9yGQexsIBmJpbShV7zuqErNiU3OIMckDuYsys2gHvUQ405oPD/hFuApgdIcuM6S/ObT+AMvdK+8I6FdeD1CgwfUwIK60pphSdNkRTBWFt86gn8PqhmB1RfujZ73iKuPTzLEgSf91ZhIDdAUfPETpE6hVVXCOVgJcrQN82vlwwW4iYEfDTxNnvn6yrEFN/hOk8I878nI3+pVWH2sgkFjfDiyO1Ng/3BKgJazUzEj+fZ1d0yA2ju+JCTn8EorF2nXmAhI3a5JgcRWDXIk8hq3ZjiIJk1e/laKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s6m5mIAvNMr00pbrrTVXzO/+PDbkBv+yX5Ofg7KGaA8=; b=OIfY6u+nTja4GZHs7RP1KxozvmrZa0iCiKt0P9jwPvfBQ2FHysuSGt0qFnuAWCeySAW2atPMb/GFnpBQ1TWU+1uEZJGEPoZJe4DvyghKovdqF1qwF4m73Q3dec8PgNPTOoPdjEZfpftE8s4RHWJqvEZCoZZb5coVzDpdOZrRvZKO8yJUkfCOg2ceF997Uja8DS1MitrwfIJOg4cCpm2uJi1TxrsLoEk9Dd5MHpGbahCWntLX74nheUYvhA20pDFijnaYSTR/+h1DBRM9zPOGVfnrDthwDPoqtz6u4yoBKdEdwXNyxQZduKGfg/YWuVi3gNTfwbMcZZq4riVplGIxPg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by BYAPR12MB2936.namprd12.prod.outlook.com (2603:10b6:a03:12f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14; Mon, 16 May 2022 08:06:55 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::59cf:d090:5d26:6e7b]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::59cf:d090:5d26:6e7b%5]) with mapi id 15.20.5250.018; Mon, 16 May 2022 08:06:54 +0000 References: <20220505213438.25064-1-alex.sierra@amd.com> <20220505213438.25064-15-alex.sierra@amd.com> User-agent: mu4e 1.6.9; emacs 27.1 From: Alistair Popple To: Alex Sierra Cc: jgg@nvidia.com, david@redhat.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 Subject: Re: [PATCH v1 14/15] tools: add hmm gup tests for device coherent type Date: Mon, 16 May 2022 18:02:56 +1000 In-reply-to: <20220505213438.25064-15-alex.sierra@amd.com> Message-ID: <87ee0taokl.fsf@nvdebian.thelocal> Content-Type: text/plain X-ClientProxiedBy: BY3PR03CA0006.namprd03.prod.outlook.com (2603:10b6:a03:39a::11) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3511d01-2899-43e7-46af-08da37130a81 X-MS-TrafficTypeDiagnostic: BYAPR12MB2936:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: afba5DwhCcLRcoAW3v5DzIRNYoHR6ozdKvX6qQnNjalmneWCcAnIM98/G8Vv6lHCUguOpR1VY31pgxbWgGvst/zAZS2cv6MoT+NbPRo3e0mWHRMjjy3QR5AHDIDyUyT4UBsEbwoR0puR+vXs1DWDQB4fvOvuOD8S5mQK4pxWoE98o6nm+Y9rlfmzaeaFC0TB4UkkJIl4zi2SEXzwWqaTYU8XeqlxCw2kwKc9Cnt7B/hTQllR7qJPfgRt3M++bgQSobLM/dyPzPvgIduk7PHi13BmpwnMbQ/pGa3oD9PQVRRS/It2pmPy+kGCSAe2kiqvcMvKoVg11Yx83IfusAMWv5frD8oxI+9BMrKPn3ISY1Bv5E1BdmoMCzpW6pQwgGv/w0t3BljcBplhoXi+gQY9CZ8g8Uwmbc/9L6BB+hKOM+K7Pt94VvZSUN1DCIbIeHon9rT5bPNk9XLrjmwxYF0z/Zbn5eAjr9GzTUQC9G7sUBKGvrKtvLrYzJx70XFpPKbqvu3dwGq1Slrz97uZTzI4byv4YlXanqMrPEnlqP0YPAfWxSOV6pFtyo2DsMEe/oORTeWDVxgQEf+N6jXPI3u0K6g8ZvdGxon73ECRUMgap1CUUSuTt5ml4qGx0d198DXPH3fXOvpXoeMUqSMSb1wM3w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(86362001)(8676002)(66556008)(66946007)(4326008)(66476007)(38100700002)(6916009)(83380400001)(6486002)(316002)(508600001)(186003)(6512007)(9686003)(26005)(6506007)(2906002)(7416002)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ZHweYjSS6llbStAtlU2NOx74UGsbnT9CZWQ00RCT4F8zrYHzEsj8noaoxWXZ?= =?us-ascii?Q?f0waaBYzdEgNJGy2SLkx9Ue+gg5KcCz5tPtMNJdFGwcYUAktDrf3mLgU1+SC?= =?us-ascii?Q?q3DZBF6vi1SlCmUXTYnFpJ/4yBRYP1UkP5zakbA5DbRSlSMk+No+RbuRhcac?= =?us-ascii?Q?nsKWK5rh/0p/+Gt+pELlGhMHaikAgH2cz+5rgchqXeM6k6evnmNFIRtFXqY3?= =?us-ascii?Q?e5+q5E0E2wnX6DMdr3sS9IEVz8WL31aSkwewUAOPfrH6QFUzRLv6ZOb3kNWc?= =?us-ascii?Q?Z/8Dlw1O7K6UknIw9fw7ByBNbChP7VIkr51AREndOZwTdRqdaSMAWydC3DKG?= =?us-ascii?Q?1CG5cT3ue1e7bwdk4YDgFvG+zZUyknQbYwI3K+L40zXFpkpKZfZHg1B/6uxt?= =?us-ascii?Q?cSdO/yZcHG3w7ceP+mSIHfSgD7/NiX6gFx/HnImo3UeYlDfmMwbarBVY5TBc?= =?us-ascii?Q?xrRbmPeavwEw6IaZ1Gy2SJYZG2obHzueRtAPEPnfWqnFU8EFzKVxDRhsKGI3?= =?us-ascii?Q?Cf1BGXI5UrMrkS710KPby/95VrLor98R3iHesPywkW8NEH2AxurMNdX4raSc?= =?us-ascii?Q?lvDTbF4wrFhgPsLRqGbI9kwaxjGJ0kxuMjQlaxJlB6Z9zR5ne7abbJEEyXCU?= =?us-ascii?Q?iAopwGuDOAJjVLXSAGNNmZ9UrMAxzz0MgcNjVD5sH7xodZsu1Wec9x4nTssa?= =?us-ascii?Q?LXO9gtDW2gV/Q3FqtWe1HPJDtbvSFHRLX3XfShIhiv/sGCFU+L8ZhDS95EM9?= =?us-ascii?Q?KWL0CGBNUOPChhfs26v3JyP+VhVbgnJy4HXkA8aNa2SHAfLfe/OgMV/Aoeia?= =?us-ascii?Q?fPGuL3NT6dPL9HjfAnmViDcMMlmOiRbLxNaxkM7mZuE86qaLjJUzDHHcta6t?= =?us-ascii?Q?MlCJCzIbXx/uYMhwvPQ3eEid42e1kIWnllENQ6AblOvgleh82Ib2qh/yqBUO?= =?us-ascii?Q?CqQFw6GRLmIyyrQvy/CCxvfEpdCIvbmBYGhlDMZH/yQhJDEBZT8YFLeORBSp?= =?us-ascii?Q?jtBtGtJM5T8LGGf/B1kwi8APs4+N0YAEpw1nskhRZMp3yITgtDMLyBL0mTGu?= =?us-ascii?Q?Q0GRYAhERz3ouMMICGEWxhv6Nt6K6V3a2aa/5fogDiFFp/rgXOsWoH2fJ+pC?= =?us-ascii?Q?G+U1jBRJCoNCq9X/4+ulFABtHsk5Qr8TCW0rcS5JfjjemSPgCHMSd1WJgkJR?= =?us-ascii?Q?Rn1lcdB9ekWHYWejPYUzpGgwPkfux82aN5Omqes+e4k1Yj9VVmF3p9N9SFgd?= =?us-ascii?Q?VLI+L+dn4oK7SZs3YAITY3NPcqsfL5LifvDNulsUVvPbAayRK93Aa4YgWCfr?= =?us-ascii?Q?MNiE6f7Y5iOhYnnFEmvjx5x9haf2skUoiKP/LDKQd42Bh5+ZGKUlBmOmxV/C?= =?us-ascii?Q?IxoMzMc5L+zM/zdWtA+u9OzvTZ1VwVyXGe6YDZfkHQ9Rz9xKN0oD46O4Pa6T?= =?us-ascii?Q?sEeH+UHlk3V520HdeScz4ch7NUBtwNsYeBgHBKdXZ5zWc6W21JMwZ+x1opqM?= =?us-ascii?Q?Z53iwFiE/LEUloiUDR7QcOrEr9qUQ72CBHDyCJsIbahAdfdx6HOZ+AbA2kGP?= =?us-ascii?Q?L5HZzxVDNsXw4BMjwutP2keIaH7KNu9Ypn5e991f8YzOZk7c0BjzZyjYhdKM?= =?us-ascii?Q?Zj3RxTFIgMjzWzB23DHyyNtEA9pV1JbCrewF7CYJkCEf9D9aC2Gy7HMMzgdw?= =?us-ascii?Q?5XHVUhibF6GLOlDIYOOjHiGrtJFXPK6iUwkgUnDUJL8KHJH7caQvD4uMsur8?= =?us-ascii?Q?rdoVguywaA=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3511d01-2899-43e7-46af-08da37130a81 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2022 08:06:54.7903 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sW5dNvIl1u7K/xdnn7m6PfaYycZBwBkbIAeH4KpabPZ0NSG+VVGPwwBziFaW1X3hmiV9Y0ntILv1zhh/vIaCeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2936 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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-ext4@vger.kernel.org Alex Sierra writes: > The intention is to test hmm device coherent type under different get > user pages paths. Also, test gup with FOLL_LONGTERM flag set in > device coherent pages. These pages should get migrated back to system > memory. > > Signed-off-by: Alex Sierra > --- > tools/testing/selftests/vm/hmm-tests.c | 104 +++++++++++++++++++++++++ > 1 file changed, 104 insertions(+) > > diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c > index 84ec8c4a1dc7..65e30ab6494c 100644 > --- a/tools/testing/selftests/vm/hmm-tests.c > +++ b/tools/testing/selftests/vm/hmm-tests.c > @@ -36,6 +36,7 @@ > * in the usual include/uapi/... directory. > */ > #include "../../../../lib/test_hmm_uapi.h" > +#include "../../../../mm/gup_test.h" > > struct hmm_buffer { > void *ptr; > @@ -60,6 +61,8 @@ enum { > #define NTIMES 10 > > #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) > +/* Just the flags we need, copied from mm.h: */ > +#define FOLL_WRITE 0x01 /* check pte is writable */ > > FIXTURE(hmm) > { > @@ -1766,4 +1769,105 @@ TEST_F(hmm, exclusive_cow) > hmm_buffer_free(buffer); > } > > +static int gup_test_exec(int gup_fd, unsigned long addr, > + int cmd, int npages, int size) > +{ > + struct gup_test gup = { > + .nr_pages_per_call = npages, > + .addr = addr, > + .gup_flags = FOLL_WRITE, > + .size = size, > + }; > + > + if (ioctl(gup_fd, cmd, &gup)) { > + perror("ioctl on error\n"); > + return errno; > + } > + > + return 0; > +} > + > +/* > + * Test get user device pages through gup_test. Setting PIN_LONGTERM flag. > + * This should trigger a migration back to system memory for both, private > + * and coherent type pages. > + * This test makes use of gup_test module. Make sure GUP_TEST_CONFIG is added > + * to your configuration before you run it. > + */ > +TEST_F(hmm, hmm_gup_test) > +{ > + struct hmm_buffer *buffer; > + int gup_fd; > + unsigned long npages; > + unsigned long size; > + unsigned long i; > + int *ptr; > + int ret; > + unsigned char *m; > + > + gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR); > + if (gup_fd == -1) > + SKIP(return, "Skipping test, could not find gup_test driver"); > + > + npages = 3; > + size = npages << self->page_shift; > + > + buffer = malloc(sizeof(*buffer)); > + ASSERT_NE(buffer, NULL); > + > + buffer->fd = -1; > + buffer->size = size; > + buffer->mirror = malloc(size); > + ASSERT_NE(buffer->mirror, NULL); > + > + buffer->ptr = mmap(NULL, size, > + PROT_READ | PROT_WRITE, > + MAP_PRIVATE | MAP_ANONYMOUS, > + buffer->fd, 0); > + ASSERT_NE(buffer->ptr, MAP_FAILED); > + > + /* Initialize buffer in system memory. */ > + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) > + ptr[i] = i; > + > + /* Migrate memory to device. */ > + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); > + ASSERT_EQ(ret, 0); > + ASSERT_EQ(buffer->cpages, npages); > + /* Check what the device read. */ > + for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) > + ASSERT_EQ(ptr[i], i); > + > + ASSERT_EQ(gup_test_exec(gup_fd, > + (unsigned long)buffer->ptr, > + GUP_BASIC_TEST, 1, self->page_size), 0); > + ASSERT_EQ(gup_test_exec(gup_fd, > + (unsigned long)buffer->ptr + 1 * self->page_size, > + GUP_FAST_BENCHMARK, 1, self->page_size), 0); > + ASSERT_EQ(gup_test_exec(gup_fd, > + (unsigned long)buffer->ptr + 2 * self->page_size, > + PIN_LONGTERM_BENCHMARK, 1, self->page_size), 0); > + > + /* Take snapshot to CPU pagetables */ > + ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_SNAPSHOT, buffer, npages); > + ASSERT_EQ(ret, 0); > + ASSERT_EQ(buffer->cpages, npages); > + m = buffer->mirror; > + if (hmm_is_coherent_type(variant->device_number)) { > + ASSERT_EQ(HMM_DMIRROR_PROT_DEV_COHERENT_LOCAL | HMM_DMIRROR_PROT_WRITE, m[0]); > + ASSERT_EQ(HMM_DMIRROR_PROT_DEV_COHERENT_LOCAL | HMM_DMIRROR_PROT_WRITE, m[1]); > + } else { > + ASSERT_EQ(HMM_DMIRROR_PROT_WRITE, m[0]); > + ASSERT_EQ(HMM_DMIRROR_PROT_WRITE, m[1]); > + } > + ASSERT_EQ(HMM_DMIRROR_PROT_WRITE, m[2]); > + /* Check again the content on the pages. Make sure there's no Very minor nit-pick, but if you happen to be re-spinning anyway the comment formatting needs fixing and a new line before the comment would be nice. Otherwise: Reviewed-by: Alistair Popple > + * corrupted data. > + */ > + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) > + ASSERT_EQ(ptr[i], i); > + > + close(gup_fd); > + hmm_buffer_free(buffer); > +} > TEST_HARNESS_MAIN