From patchwork Wed Jul 27 00:08:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Campbell X-Patchwork-Id: 12929934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1618C19F28 for ; Wed, 27 Jul 2022 00:08:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CD4D900002; Tue, 26 Jul 2022 20:08:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47C9C6B0072; Tue, 26 Jul 2022 20:08:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F6CC900003; Tue, 26 Jul 2022 20:08:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 19E0B900002 for ; Tue, 26 Jul 2022 20:08:49 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B3BA1AB04C for ; Wed, 27 Jul 2022 00:08:48 +0000 (UTC) X-FDA: 79730943936.11.26179D3 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2041.outbound.protection.outlook.com [40.107.237.41]) by imf23.hostedemail.com (Postfix) with ESMTP id 54B501400A0 for ; Wed, 27 Jul 2022 00:08:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eBY5w58gsz8qYbIk4XLxLWQJc79ApB9PzC6aTB1mFKa+A6QOBp6RVKr+V5yTWxvdfxtWo82H/TqxRgtfkyAFLcLBfPtcW38TYFe/1tJZXaPGSzDOVDuD8/m7k0g40KSbzrhwbAWvZh3kOfeadyD6LkeaJfUvobmOzJjXfEt62Apx0i5BJff2zq/qt63UJNlK8Lm/FFb/hUiQdnrxpcA40N9hDM4b9z2fbYHqd7j3SQ3IgQzqMpCMZ4yK8zgF4SsYmjzBfr6N5J3NZnD+RhbPvY7gyLcCHK04gRFeJZgpcjtBWyGlfiEyPflSvKkzUI1fsHiiJYSAND2E6aWp4uJOqA== 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=1yvx1WWz8TdrJ2KCl9b88mUhn9tYTpLlr3WG6SIaM0k=; b=DzaRQcb1W48nFTNjmy+3//SoFPpIUIHPn9CKfFL0p/k4X7F0cfXLVeQAZcM564UxwFREbban1o0OmEYTQzkt7wEJHcD0zXQmeb+XDsjunAHZ3aUXRwkns8gFc05LUVBaUM2TmDtKEIB3CraLLwW/oreS/u76Pa+JPkebzvu+tbDPuFEcSKUCyLIBkc6ajwqs2Buxd2KyzH5lz/v56TcSUkMXN+naghmga3MVAfaAKCe4sAZczcerbGL47d7O1f4VTn7GsKLFaJGpxWCsjBccQA5ZkTiWN/qC8Aa7V6o6ErPtTCgnq5IhTW/VbcIj1OKfTKmPXUN3XFtcJ3T5F00tDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=amd.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); 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=1yvx1WWz8TdrJ2KCl9b88mUhn9tYTpLlr3WG6SIaM0k=; b=iGcddrvF0bHvrPp1bOv3YrY5uqhfoWbkXcNQCI3k9S3Un1XMaslV5z2x7yt560OdLU8GOGyDDcNiDZWOj2Oq96Ne8Pvd8ahCA3W3XnW5oF3BnaijDTi8cpTZA7yai2Ae6t4F07HkeyHkdVY0STX4lkvKRoQ6rofyW/kVb0x40S2mFof3bmj5Z9+wEfcCSpbMQ8R7xBq/Uraoy6tLrGeWSb2heg4BXfBHMX1ug3+d3GXSbpQusx4BW7ex30ax0m+gWavU+b/fcenvxkXhEqGAr/ir5zHPpbfIVSu/9mRcf9yfYLiSOPkyo/tjgYdNXahBdpEvxJq+US/th64xMR7yUA== Received: from BN9PR03CA0350.namprd03.prod.outlook.com (2603:10b6:408:f6::25) by MN2PR12MB3902.namprd12.prod.outlook.com (2603:10b6:208:169::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Wed, 27 Jul 2022 00:08:46 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::4d) by BN9PR03CA0350.outlook.office365.com (2603:10b6:408:f6::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.24 via Frontend Transport; Wed, 27 Jul 2022 00:08:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5482.10 via Frontend Transport; Wed, 27 Jul 2022 00:08:46 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 27 Jul 2022 00:08:45 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 26 Jul 2022 17:08:45 -0700 Received: from rcampbell-dev.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Tue, 26 Jul 2022 17:08:45 -0700 From: Ralph Campbell To: CC: Felix Kuehling , Philip Yang , Alistair Popple , John Hubbard , Jason Gunthorpe , Andrew Morton , Ralph Campbell Subject: [PATCH v3 2/2] mm/hmm: add a test for cross device private faults Date: Tue, 26 Jul 2022 17:08:37 -0700 Message-ID: <20220727000837.4128709-3-rcampbell@nvidia.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220727000837.4128709-1-rcampbell@nvidia.com> References: <20220727000837.4128709-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b46532ce-478e-4a0a-6662-08da6f642cc9 X-MS-TrafficTypeDiagnostic: MN2PR12MB3902:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: acWbPZWGJWlduPEn0pg5XbZEh3BX/MjkJgMYGkIgfcV+O2/dN81/C8HTI31nR7vJapEwV254AuVwg79n+BwGKrPCFLRyxOZy3EXYfuQlFRBAE9+Q2SqAClq+oRXVGsvSyNk6u7ZaNY2viLVtygJBLkyq2R6GrfIpXZddQOUzKJE3DZ3GxM8rvNJrzlOivFG+wT4eG/meOvn+2q3lcFaipe6peuP3Si6UsI6pKBfd7ABSNx98boINhQ/CoFX4EcVcKDxtv+6OiXxXID7AfPgCSEXg5r1SxLs/dDtvcTzF6/0sErIznGGZHQ8Ua14oY056iUQiIQ7js8eLz8KsgVO9vdVJxjkvKRwOcNthrSVGq4DUPRV2QzZkA7jrJSko7CifsZRFw5Z+2kQ4CldvN5g4thNw6zbreNT/HxxtLz97lY6FP2KCMX6pV3/Uf/IPdfAHHKM9NC2iu67DN7+AGeVi3+zyHc0bEFzGM1Y8B2Y4opJ8OBn2ZFJqf++PTE3S1dPrQ1HI94CgLsQfxTPqqZrblRu6bAjkg8OS+f9tOBb1Z01pX4bqVI9v9yTC+Mq/7WwiOAgcVjFjRQzrY2zCUz9TOoDkC9rfEZC3Q6Ih98Rza+DNtUgnTJl1H/zb/rWLQjVuc2BVDaN9bOVa3D0I3bOl+1vhFOjRhyQzbuDo/BV16ZfyeRG7wzjaogaot539N2iXUdTHoLt/biEvo9pvcbX0qYtlofoI3aqs5Cna3TPR3vGIsQoxTG72QBy3/Vg+uC8YpCsnjzYB7REuclIcvRHadWSsfciGYg9wHhGkj5oBOHV6O536vbjEq2XjIiGe4ofQrL7IlxgDpnoIfT2n6asE8w== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(396003)(39860400002)(376002)(36840700001)(46966006)(40470700004)(2616005)(70586007)(70206006)(82740400003)(107886003)(186003)(81166007)(1076003)(478600001)(7696005)(6666004)(8676002)(41300700001)(26005)(4326008)(40460700003)(356005)(8936002)(36756003)(2906002)(5660300002)(40480700001)(316002)(83380400001)(86362001)(82310400005)(6916009)(36860700001)(426003)(47076005)(336012)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 00:08:46.3437 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b46532ce-478e-4a0a-6662-08da6f642cc9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3902 ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1658880528; a=rsa-sha256; cv=pass; b=3jWuU7rwJ9u5duEcZ+tukdKWJ485zzq3pyBfQWFFM0LeOh8EplADP2aeT5I4mHKn9w+RSb RVvqZ5THA9wnwAL0L12c7jOEADCpe0WnN7Z7Mh8wr4fMuMWP5pSZk670sX9JS+EbFzrdWD R/412gIBA6v5MOzV52m4rtQMkXE9VNg= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=iGcddrvF; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of rcampbell@nvidia.com designates 40.107.237.41 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658880528; h=from:from:sender: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:dkim-signature; bh=1yvx1WWz8TdrJ2KCl9b88mUhn9tYTpLlr3WG6SIaM0k=; b=STStn/yyZar7NwgMuiy4AP9fqgmYj1CzDbuOLQKNG2Ey8ASyV2TinKssygKqyAKg/TUiU2 yLR3u66hir7g1mYf7hyG9H8bVzBgBoHf1l2RwXtziWylIwdT0iYlEucYbKoWTxO9ztgeAf 5FWSW1zN05BAoe7SEbOSCNTzBd2ampM= X-Rspamd-Queue-Id: 54B501400A0 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=iGcddrvF; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of rcampbell@nvidia.com designates 40.107.237.41 as permitted sender) smtp.mailfrom=rcampbell@nvidia.com X-Rspamd-Server: rspam09 X-Stat-Signature: 1i1bq6c5udhdmjesidmuafkzamyzss7j X-HE-Tag: 1658880528-890539 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a simple test case for when hmm_range_fault() is called with the HMM_PFN_REQ_FAULT flag and a device private PTE is found for a device other than the hmm_range::dev_private_owner. This should cause the page to be faulted back to system memory from the other device and the PFN returned in the output array. Also, remove a piece of code that unnecessarily unmaps part of the buffer. Signed-off-by: Ralph Campbell Reviewed-by: Alistair Popple Cc: Felix Kuehling Cc: Philip Yang Cc: Alistair Popple Cc: Jason Gunthorpe Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/hmm-tests.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c index 203323967b50..a5ce7cc2e7aa 100644 --- a/tools/testing/selftests/vm/hmm-tests.c +++ b/tools/testing/selftests/vm/hmm-tests.c @@ -1520,9 +1520,19 @@ TEST_F(hmm2, double_map) for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) ASSERT_EQ(ptr[i], i); - /* Punch a hole after the first page address. */ - ret = munmap(buffer->ptr + self->page_size, self->page_size); + /* Migrate pages to device 1 and try to read from device 0. */ + ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, npages); + ASSERT_EQ(ret, 0); + ASSERT_EQ(buffer->cpages, npages); + + ret = hmm_dmirror_cmd(self->fd0, HMM_DMIRROR_READ, buffer, npages); ASSERT_EQ(ret, 0); + ASSERT_EQ(buffer->cpages, npages); + ASSERT_EQ(buffer->faults, 1); + + /* Check what device 0 read. */ + for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) + ASSERT_EQ(ptr[i], i); hmm_buffer_free(buffer); }