From patchwork Thu Mar 30 19:06:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13194742 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 3B94CC6FD1D for ; Thu, 30 Mar 2023 19:06:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDC68900003; Thu, 30 Mar 2023 15:06:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF0266B0078; Thu, 30 Mar 2023 15:06:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CD8D900003; Thu, 30 Mar 2023 15:06:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8EB586B0074 for ; Thu, 30 Mar 2023 15:06:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5B014AC70B for ; Thu, 30 Mar 2023 19:06:46 +0000 (UTC) X-FDA: 80626496412.21.7F1B559 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 7F83A18000A for ; Thu, 30 Mar 2023 19:06:44 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mNXgQ0SR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=urezki@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680203204; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=voXOGIdYOWM2wLNWqmTahTqMnugMmbDeB8dmByAxjSs=; b=pv7WA8ErfOWazPM51p20z9L2t8D7ODzuRW5lLDNW1kbRBoEU9mImqqSlRzGLSf6AatPBBb So/rkwEU/vBytdsLLbfw9uCfHd0WeEL0/EqRyg8XSXNzt+sQBQ3v8n4dAo5PoDjOOhmqTy jA83tN1S1nOt8dGOi5fTS8aSJ7x8l6o= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mNXgQ0SR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=urezki@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680203204; a=rsa-sha256; cv=none; b=O/jYjvBJfhFfEqrSKu618Vo92sQvuzFJBXKWkV0LXa7CuSA0OPlPJQrBDa+cyaTDWzQbwP kkUcc7tNmHOUk8gg6OYyAyOUWdVq72Fqkg42aCM6MTk4TC7o3kIHidTWHC2U+ELp0CRAVE Gl37f9k/Sh7t5U/0SoEh1m8Dexn1VY8= Received: by mail-ed1-f51.google.com with SMTP id w9so80561605edc.3 for ; Thu, 30 Mar 2023 12:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680203203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=voXOGIdYOWM2wLNWqmTahTqMnugMmbDeB8dmByAxjSs=; b=mNXgQ0SRS48kDk5F+4+TYcIY68iJFezo2AcCPQVSkQkTvq5hJG0XolZpaqsLaZARmx tFzenxMn1LAXy5MrS+W1o4Upp8BJzcUuOS5hedmSRfR006gAxaUiMnO7XqYQpeLEyQPJ 2lWnIBO8KbOEOhh2UD9M/6BBFnC4IFdp76kciTBnyFArOvmKJgLwfFbO0glV6lVu1JXB YWQH0CGqsBeRqwvmFg3rhKJrvzs43CO9rIxeb9XBquzS7MxCnmPFexNGPfIrvFslsxSK d5UykufwU9IhTzQ7d5VSJwPGE+lJ20pe9QckBuC81p6MTJN2iVuvo3obysSIvoWt6dyc RLYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680203203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=voXOGIdYOWM2wLNWqmTahTqMnugMmbDeB8dmByAxjSs=; b=L3812HYrTkuxveYaosW7ClthQySfQeQhcBKrJSV01oVVSgyVIkta5xi2pWn8r/Psyq zc3BOZFSusYCBI5DGYOcqFHyJRs4CAj4iNvP1uPH5IUyYHnMwmEKLPFCy045cOQKR/l/ HcAbkvGwKKf4DWow1v9DrksW1JT7I5xZ3Ka82MPDBqaZftfjE4ADUquxLiLKMGwPZHZu wxx39epI7TfUnRMkpDdgNNjTathfK0wyzoSpPrEz6H79ASbHzbAULNENZLxSYEh6G0fA qHPvb6keinOLlcRk3hahyNM9+Kp76jUS1k6YsAQQ9tzPQmMRYlSZRBTEsa72G5wQnBjV 7EEQ== X-Gm-Message-State: AAQBX9cu4Mh2sRgs7P7W+low8vb2thC6G+p2QjrVpNHI6VRn8qdz8U8N uMeEBMinDcg4nq/seNr/QKQ= X-Google-Smtp-Source: AKy350bRthKl0rgnD5bNDKbIzTOBEPf+AIAt2HRlcVZrT3FbMB536ToFxOSzKbPE1+MuS7SWfepGPA== X-Received: by 2002:a17:907:d047:b0:945:2f54:5eae with SMTP id vb7-20020a170907d04700b009452f545eaemr14046768ejc.77.1680203202841; Thu, 30 Mar 2023 12:06:42 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id o18-20020a17090608d200b0092973e209f2sm122240eje.109.2023.03.30.12.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 12:06:42 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Baoquan He , Lorenzo Stoakes , Christoph Hellwig , Matthew Wilcox , Dave Chinner , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH v4 2/2] lib/test_vmalloc.c: Add vm_map_ram()/vm_unmap_ram() test case Date: Thu, 30 Mar 2023 21:06:39 +0200 Message-Id: <20230330190639.431589-2-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230330190639.431589-1-urezki@gmail.com> References: <20230330190639.431589-1-urezki@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7F83A18000A X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: w13xeyzy5zq61cm77bc87ib3kneqoe51 X-HE-Tag: 1680203204-792796 X-HE-Meta: U2FsdGVkX193rpJ69G+xDO9Xwckbjz2VU9eeYLduI1BHzwlzqUektE6ULO8g4/cgLxhdE0Bw3RxMhrc3VY6UO6fnc2BsAMS+ZOQSLqLgv5eUxo3V/qpLSctMuO3uMj48rw9pMcSbyDplUY1VC0S1HrrGb86MKiutoB06GI0RssNyhlBaw5TUozWMKV4msBrF8um53wFhqWHurV+V2iRuRTtiHqcVvNxstxVcGoa4UGyD8EE/3MoknvbD0VI3BXcFzej+VQEwFdZErehqV0w7rxSmlU6inHdYpCv4M3/4EF/EWugZpfVKevlrojSbL77+oxGLCjEwCZ+KXNncgIjEq46r0E1jw5uLzlvPYPrZVi4rIdcFRxtorNb0CSpidRK29sTz8Ub1iZ+M3HHWc35UZTR/I2JGUe/D2RyC6jAl57xtVpqLg6jpuEwFnl/I3oxWg6dUFireFjUSVgc4G81AC/7Sq1x0mqv9mm9ARZt/xwXFSveNXocerg7AFuD5Rbk6PEPdtewuDq/fxxKOpoUM0QXvFgCIffJTeWm4zw+sPTTGSw8RkEhTEaUPRe2TL+93nP9MqcFXPspz7Lp5BpEA5fXpcuIfZzS6olh+9OGgL6yScPO4a+YgJAYyq+no45Zp4If/hlnIHGEHcFCG4aOd4gzwuRYW1nuzW7ulgcqij2hakn0IYKEpgc5MObkRnREAhmgbYB7wm0ta+NNUfkfBtimETP8OH9g314qSipKXy2uYhUBCuRASOUuvVgAggy1VG3SIrNtT8rumGwVNwe72KCRw+VqF6PaM3MbNfLj2v3TzPOoAy8Db7PUwQzLBzkjxOW/aO5CtfPdKc1QMdWYqaPPrcEJV4kdiobqQSdqFCoXqqR8AwZlU/Im5rb6xIkElfSSsg30GHTD8/sPsSre1/NWP6FxWFmWmygmygSEPf7Jbod3ERJiFeUZ0JqfXlTIf3X+YrTPfkTMlrRkr381 M2njjrpx XsrUGTLiovC6G6VzzG6Q42PZx3YmpRODhvEQjmff6AFQLrOdAh/OhhABcp3NX+sbTjOB3+IAz1GFrMB3rsHwZ8bJt03r9AUsTcYWzKlt9XxZdjkFq0BBg1q4m8vQDNX6d/CJeNdrOWai656OuWLbHtVaxjQoKJUCobjV86Tb0JLqMvwXAqnDU0RLaRGdUHb8Ve5+z4tGb0CpLnPIL1PYGGYr9qccSGZGVfmvo017N5XmMAAiF0NN1309rlQAlDbD8nG+QroI5ukPPs6XuQMM99DxvfyBf0IIFbYdiUK5GFHj+YZAZxLDMP5lQQrg75NtUJlP5wU+13o2w3t7qe0LDU08I9h9/N9ZgkoOOPK8a5i5YfjD/vS/Ti9n+boukFyhbTAt9el9Lnr0fxqVnGNwHVGIPUuoGQ36khElxA/DweppRW10DvvM2YJqJfllQtu0xPUSh3MRV1k/dGv743AHkxzxykWEnYFZMQdm7BtY2m5sin9S3tHNSajCqYizB9eVi8fqL 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 vm_map_ram()/vm_unmap_ram() test case to our stress test-suite. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes Reviewed-by: Baoquan He --- lib/test_vmalloc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c index cd2bdba6d3ed..1622f3f9ec23 100644 --- a/lib/test_vmalloc.c +++ b/lib/test_vmalloc.c @@ -53,6 +53,7 @@ __param(int, run_test_mask, INT_MAX, "\t\tid: 128, name: pcpu_alloc_test\n" "\t\tid: 256, name: kvfree_rcu_1_arg_vmalloc_test\n" "\t\tid: 512, name: kvfree_rcu_2_arg_vmalloc_test\n" + "\t\tid: 1024, name: vm_map_ram_test\n" /* Add a new test case description here. */ ); @@ -358,6 +359,41 @@ kvfree_rcu_2_arg_vmalloc_test(void) return 0; } +static int +vm_map_ram_test(void) +{ + unsigned long nr_allocated; + unsigned int map_nr_pages; + unsigned char *v_ptr; + struct page **pages; + int i; + + map_nr_pages = nr_pages > 0 ? nr_pages:1; + pages = kmalloc(map_nr_pages * sizeof(struct page), GFP_KERNEL); + if (!pages) + return -1; + + nr_allocated = alloc_pages_bulk_array(GFP_KERNEL, map_nr_pages, pages); + if (nr_allocated != map_nr_pages) + goto cleanup; + + /* Run the test loop. */ + for (i = 0; i < test_loop_count; i++) { + v_ptr = vm_map_ram(pages, map_nr_pages, NUMA_NO_NODE); + *v_ptr = 'a'; + vm_unmap_ram(v_ptr, map_nr_pages); + } + +cleanup: + for (i = 0; i < nr_allocated; i++) + __free_page(pages[i]); + + kfree(pages); + + /* 0 indicates success. */ + return nr_allocated != map_nr_pages; +} + struct test_case_desc { const char *test_name; int (*test_func)(void); @@ -374,6 +410,7 @@ static struct test_case_desc test_case_array[] = { { "pcpu_alloc_test", pcpu_alloc_test }, { "kvfree_rcu_1_arg_vmalloc_test", kvfree_rcu_1_arg_vmalloc_test }, { "kvfree_rcu_2_arg_vmalloc_test", kvfree_rcu_2_arg_vmalloc_test }, + { "vm_map_ram_test", vm_map_ram_test }, /* Add a new test case here. */ };