From patchwork Mon Nov 13 17:01:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10056425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C404660586 for ; Mon, 13 Nov 2017 17:02:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B356629359 for ; Mon, 13 Nov 2017 17:02:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4DD5293C5; Mon, 13 Nov 2017 17:02:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8BFAA29359 for ; Mon, 13 Nov 2017 17:02:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D050F6E6B0; Mon, 13 Nov 2017 17:02:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0053.outbound.protection.outlook.com [104.47.32.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09A716E6B0; Mon, 13 Nov 2017 17:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LhMQYihC0ehk02SmcNnBPO4hGPcFMjxP6UPKX9m/wGg=; b=KxxP/xcOVBotu+u4JV1VqmqJdA+lo+u5sgM6JdaBo1gP1lcE7Aam5StvhRfN/BHr/kCnkPxV03NhWfVV5qIIzFY8vH/mc8UKyOBKiSBBrW19ywc1o/aRDH50XNaHoulLX0iw+D9Zmv5XGZncTxpKI3HZKwsBfREb5a6xMgy+pP0= Received: from DM3PR12CA0066.namprd12.prod.outlook.com (10.161.151.34) by MWHPR12MB1453.namprd12.prod.outlook.com (10.172.55.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.218.12; Mon, 13 Nov 2017 17:01:58 +0000 Received: from CO1NAM03FT036.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by DM3PR12CA0066.outlook.office365.com (2603:10b6:0:56::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.218.12 via Frontend Transport; Mon, 13 Nov 2017 17:01:58 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by CO1NAM03FT036.mail.protection.outlook.com (10.152.80.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.218.12 via Frontend Transport; Mon, 13 Nov 2017 17:01:58 +0000 Received: from ubuntu-1604-test.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.361.1; Mon, 13 Nov 2017 11:01:56 -0600 From: Andrey Grodzovsky To: Subject: [PATCH libdrm v2] amdgpu: Add memory over allocation test. Date: Mon, 13 Nov 2017 12:01:42 -0500 Message-ID: <1510592502-2230-1-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(2980300002)(428002)(189002)(199003)(53416004)(2950100002)(305945005)(72206003)(50986999)(76176999)(8676002)(77096006)(6916009)(2906002)(81166006)(81156014)(478600001)(33646002)(356003)(97736004)(101416001)(6666003)(2351001)(50226002)(105586002)(106466001)(189998001)(8936002)(16586007)(316002)(86362001)(36756003)(54906003)(68736007)(53936002)(5660300001)(4326008)(50466002)(104016004)(47776003)(450100002)(5003940100001)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1453; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT036; 1:xqtHK+bsjIAaoq0bb6vTm0nHMPsA0GKdHi8V5O4tVJ3n3+luhk3ZKaU4gECJ4H168akTfcr9J9wNN+oEbSjPjMK4gaWnxwUJ8GaLtc+k6ianH9QOJxUfWYoOp1bHfLzb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1e40fd2-248f-4f81-dbea-08d52ab84034 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:MWHPR12MB1453; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 3:zUs5BEXvQdZNIpn8hHhl4D5LSqSMFujtxMqKaegkCoUMcVJjrAmnA20JlTM5mzp/nekZeb0wcog3hrkOlzAF2ApRwk8jwfRuvvpUL5II3QadwAqUXXsD8SrgGGmZFYVkocjNQqPo8PwFVhJxJeD011WHB5SBOA5BHAYZEHeK4FoKEawg+JHIMLYnLKJyTMYBcA0s9irens+ZhSr/YUH9uzIjgfToWd5/2LktxYzRlSUy9TykgRNSwhloC463f/Mc1I+wXd3cay3CEQ/BV5zYs9qA0xcjhvjGf/S9v3XHC6TuLH0AvYWiv0J/ahCWGVZv+VpcyFa3A5IvLWrNLR88btLHFZ433BUrebwDIU9jDWQ=; 25:eFEoONzgl7b+sFqI+TB2p5QC32jNQn86be956pUTMJmC0ltNB0U96ETrgg4+IsZCpzM6+kEw6zZ+bbT3McfG51lUOA37sqhnoomLZVVmq7yb4a4aBs4bemdhnn6R3sMQ5AC+Z6M2iM8a/tyv3jHGhsm7Z8NuenQUeCyUSB0uCs1L+Ij703DYVYDn7zhJ5W5JKUqEYKwnwX+cP2QrelRu+lUacNMGIpMdodSCWlxvmMvmNj343JMJNmXbG64fbcIf40ITwwBfz6GvtqqZzxzwJOkBQzerj+A+UySSUNrWFyBXfUeTHSLUntQ3tEEO31062fUktMONZtv2cG7Uln/IBA== X-MS-TrafficTypeDiagnostic: MWHPR12MB1453: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 31:eWVTk7so4AsikPTNNAyX91u354irXa1B0//RDv9uX7esCypI0U5lj0QpdGgJMHbV/JGmmDctDNugej/jErmTw5lJ+Q7/V7EcsS127nCE/pdYkaxJ9/SpLhdA8Z31z+WJFZ7dmifD/vP4tKB9DsyADyGquCvq2tOpkFIc5FO8lOLQ3Ob8/dTDFA2+KbfACx93dydjn8JANlUJPlP8VLmOokUnx/96n8M9yLDWihUBQgk=; 20:C6Q7JQhYHQmtEEgYI2mMhuk/IME9s1os+leBoKavh0S+BP3XC5gqYV/6/W9nuhaJygiXeqUp7J+qXtGNFdrqTdfsC40Nf2f2JY72p4UYGs8ls3XljtraK2hXgjid9jQIS413Zuie+b4eiQee6uAYULMiQ/rDLRdLVJqpA/J6yCPaZ7gZsdKy4dOBFXd8MHS8NiA0gEr/hvekNROauQ/F2OihztY6w7tTQfsSr2h/8fak+ldpISxGfKveyENb3Ij4vsCFQ8SWRZzR/CKoF/KNyO4Okr9FSA0RjAeyMGX1H6PTjM2bNMcvn8j3XKtRwEelyt2Z7nYRH7rAB5EmuPxf+rfWbjESHdi3iQxEgfYZ09vKApAbHI7rhK0c6rvyWAImnuI8Q+u4rTYScreCU64cSm4PINce9xQ8iL8wSyxqE0Vhdg+ryak9w568sFUc5gGGiKehJiCjkwUYc4ENK7Pia/LtyuJuZ/VXMMC8BAiRcWry+85dLf0jJCd4nTjB4JZ2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3231022)(3002001)(100000703101)(100105400095)(93006095)(93003095)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR12MB1453; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR12MB1453; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 4:qFWQ9EfRJXFQgiubLSFEhPb8YJ2NpA+ghVcVhF5o3pAwriTbe58I+L/EMNhLUzArI36RQz6qfiEzyYFVS3SfYLpp0n071LFSHT/Qrgrmyz/dom2KcRLVrop72rb65pMHRuZTkjafzPRpMSL0H58NuVnCfE/b99Msa4eeLGVRbMFtRPnQLtG7aublWB8uP2u+76uoig6Lf7rHlFx1vjSXwV4wZ+a2YFBjdY0ZzKgGh5ggbO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Dbv2IPv+k8Wls+0NDAC/0oVc/5IOWLmWr9Kc+gv7/j7l8BcYtSlh2VJCveY/a9I24T/pIWfcI80yX+McIiAQncHnZq85JCNwE=; 7:bazYtqzXJWjTewagYWwumdokeufCaz1CZlTHgiRKxeWV+f0ufy43TsYjK4u/QgewNmLMc9VYxi0Mu2OZ87rYP69fGg+SYuLJGqTX6tS/gVMTY1QU1YjrvlWVIgCecmEIhKy4mpqmQLlONjkYNxEnCg6dNRw6hzlnY7i9JSHc7EcguhDwx8sZfmLk+yE7nGB8g0NRxGYBxRhnEasfslIKnrSN98/xpcasAS9FOj5HbnUiZ3rtDY9ss4b/GVJIZHDT SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1453; 20:atpMYajgZ3WLrRL+kIOhL66WvhINnmvRxtJSUMe/KOejHcp+tDk8/sVUnTm3Hj7S2K4itFHxzVp+cjYmpEsbbkqopEwV1NCfLfu5lUXmVieAaqtKGrbr/P57NZPnQ2+yO+5XcgAAGA2MwnlA7rDFMbKKQiXmtb/P7NfSFqo8K6+uPIE7hZUiTVnPGUyGAECW+dVkSyX8kDGz0wGUjM//q4S274WcSAL355e+Bqur6uGgdRODkAo2vH8s5hvUFVnc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2017 17:01:58.0317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1e40fd2-248f-4f81-dbea-08d52ab84034 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1453 Cc: Christian.Koenig@amd.com, amd-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Allocates 1 TB of memory. Test is disabled by default since it's triggers OOM killer. v2: FIx the test to only alloc the BO and assert if return value not equal to -ENOMEM and remove test disable on start. Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/bo_tests.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c index 4545196..53e76c1 100644 --- a/tests/amdgpu/bo_tests.c +++ b/tests/amdgpu/bo_tests.c @@ -47,6 +47,7 @@ static void amdgpu_bo_export_import(void); static void amdgpu_bo_metadata(void); static void amdgpu_bo_map_unmap(void); static void amdgpu_memory_alloc(void); +static void amdgpu_mem_fail_alloc(void); CU_TestInfo bo_tests[] = { { "Export/Import", amdgpu_bo_export_import }, @@ -55,6 +56,7 @@ CU_TestInfo bo_tests[] = { #endif { "CPU map/unmap", amdgpu_bo_map_unmap }, { "Memory alloc Test", amdgpu_memory_alloc }, + { "Memory fail alloc Test", amdgpu_mem_fail_alloc }, CU_TEST_INFO_NULL, }; @@ -244,3 +246,25 @@ static void amdgpu_memory_alloc(void) r = gpu_mem_free(bo, va_handle, bo_mc, 4096); CU_ASSERT_EQUAL(r, 0); } + +static void amdgpu_mem_fail_alloc(void) +{ + amdgpu_bo_handle bo; + int r; + struct amdgpu_bo_alloc_request req = {0}; + amdgpu_bo_handle buf_handle; + + /* Test impossible mem allocation, 1TB */ + req.alloc_size = 0xE8D4A51000; + req.phys_alignment = 4096; + req.preferred_heap = AMDGPU_GEM_DOMAIN_VRAM; + req.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS; + + r = amdgpu_bo_alloc(device_handle, &req, &buf_handle); + CU_ASSERT_EQUAL(r, -ENOMEM); + + if (!r) { + r = amdgpu_bo_free(bo); + CU_ASSERT_EQUAL(r, 0); + } +}