Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1480558pxu; Thu, 17 Dec 2020 10:56:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkKjJ6HDPxABOiXtD7LPbw4sgKAN7Uh45NHB+orpDWMwLZAqj3cAzEGmi4eTdmRLnBoD6Y X-Received: by 2002:a17:906:518a:: with SMTP id y10mr386303ejk.323.1608231393664; Thu, 17 Dec 2020 10:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608231393; cv=none; d=google.com; s=arc-20160816; b=uBvXThLQPl0sDthv1zRaoDpUClhRbTg7jtrQjSX4SyYcJwnmuDP9pql0Qi39Ror9PZ ISh07XJCyr12oB8FSRq95vYek2bpWtVKCz1FgBDPehtIF7ZLomjg3tFA20qRPmloWiMb mR7ZZqa9A70P6cIvNhL4aojU0nujjY3gzPxwph1NdOaY/zu3vugTpbb6x2ju1vzg6qWW 2rkSzJSJi2N4R2AHTgDuC5jPMu1Wo7+So7LQBuAbnKZndOIVRWQHpCbT460bUpjD3uoG 61UugjmYdhXsF2Az9xpRWOayErJdc/xT/R2p8YCJeJMbezT8eJ43MBRStjbkW6mEz7Dc UccQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=fRwryvuVhXYrAhLWdCvlg8zqrU0LccdvvXixZFgTlpI=; b=kvCIXfU/1v9cZyvoG9YmaDKnc9uK0hj7IjG46ztG40qy0rLchJqj3t1u3I5HvQB7/1 DDzDm/2snr3wTKy1t/YCIKXX6FdrzWUwBEHNupBqPKXk2EjbUjTejtpSzTfcjIPawg5z mONMC6Ba/8rlpMlsD/PRduFhFfLDZO8YbA5RHIT7bAdpIbiF4miHiNgk/QoQiL5CcU65 l0hXFLNJm0N0IzV6AXnTXhwl/Ftmfe11xBzD42VnHrgy/V936KWw6dMGgKl4Kurnhiwt DhPPCdCx5C1aFGYvp9VxQFVyrVAn7VZ4XbHqjWVKNsKvS7tLvg9Q2vAI+D3kXJtSnUoQ TprQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=gDva44QE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pv8si3090294ejb.638.2020.12.17.10.56.10; Thu, 17 Dec 2020 10:56:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=gDva44QE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730992AbgLQSyc (ORCPT + 99 others); Thu, 17 Dec 2020 13:54:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728704AbgLQSyb (ORCPT ); Thu, 17 Dec 2020 13:54:31 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD55FC0619E1 for ; Thu, 17 Dec 2020 10:53:05 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id z20so20838653qtq.3 for ; Thu, 17 Dec 2020 10:53:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fRwryvuVhXYrAhLWdCvlg8zqrU0LccdvvXixZFgTlpI=; b=gDva44QEcG/VWunZgNqEGGjC6m5HKRd5jC3iu5YSaDSrrwASQW3uz9D7uUgtQbFZS9 YN1YGfbBQ27Me0nqIB5dGg6H090zCpDkS2icZOHxNb/089r2kSUj+OVuhMTICDAYNLZT HtRlXXdMCv904IqORReSjOaIMQk32q7XdGOEXHUvYw15a7J2dm++e/DVF6j7O6nvR7DY rVzv4TB6dwm1dsjL4NUpH5/QlV9WBOeJOrkHBIuU/H4vVoDTO80obrJk96W54xN8KSgf g6/DPummsvSPaE4NAtii+AUigVRv2OtUpjv2GFzonPdM+AdN8bG3gZYeRFoX9WxZ3SM9 stxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fRwryvuVhXYrAhLWdCvlg8zqrU0LccdvvXixZFgTlpI=; b=Q10539PxIdRJsHSErmAQ2SnPOF8zSvJ7GEDuc3XB8kS6eybIvf3Wx4Tu4bo2pqDxlv YuP+2usRCztJXT7iaw5QgLcwxcqjGMVzWx3a1C0L4hHfrQDRZSwJL/1LyPnTBnFFI5E3 QvwrX9m2LSjAz95oPsGCdZxb2dE2gxA42XQz8qN4W3O5a5oiIUfrpNsWrkEQY20L8eKn FrdqQIyWyQc4ACIsHLWIuQjNEuzAJgXCMBt0kNnVbD8SaWiet4FwMgJmDf8gTMwboTHG ONXUFN4uInJRglj/M0Pz2ukoIrZT3wb2+qwaoQ+C8+qgQE0WFvESxuez3Semk/5gyv1o loNA== X-Gm-Message-State: AOAM533K8emPQPtjAS2FelMNvDGTx57j5vMaWq8Crfun5zLf00Lq0H49 +JcaXvgjyV41USNqmauuuWMW/g== X-Received: by 2002:ac8:730d:: with SMTP id x13mr171787qto.162.1608231185009; Thu, 17 Dec 2020 10:53:05 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id m8sm4127434qkn.41.2020.12.17.10.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:53:04 -0800 (PST) From: Pavel Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, osalvador@suse.de, dan.j.williams@intel.com, sashal@kernel.org, tyhicks@linux.microsoft.com, iamjoonsoo.kim@lge.com, mike.kravetz@oracle.com, rostedt@goodmis.org, mingo@redhat.com, jgg@ziepe.ca, peterz@infradead.org, mgorman@suse.de, willy@infradead.org, rientjes@google.com, jhubbard@nvidia.com, linux-doc@vger.kernel.org, ira.weiny@intel.com, linux-kselftest@vger.kernel.org Subject: [PATCH v4 10/10] selftests/vm: test faulting in kernel, and verify pinnable pages Date: Thu, 17 Dec 2020 13:52:43 -0500 Message-Id: <20201217185243.3288048-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217185243.3288048-1-pasha.tatashin@soleen.com> References: <20201217185243.3288048-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When pages are pinned they can be faulted in userland and migrated, and they can be faulted right in kernel without migration. In either case, the pinned pages must end-up being pinnable (not movable). Add a new test without touching pages in userland, and use FOLL_TOUCH instead. Also, verify that pinned pages are pinnable. Signed-off-by: Pavel Tatashin --- mm/gup_test.c | 6 ++++++ tools/testing/selftests/vm/gup_test.c | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mm/gup_test.c b/mm/gup_test.c index 24c70c5814ba..24fd542091ee 100644 --- a/mm/gup_test.c +++ b/mm/gup_test.c @@ -52,6 +52,12 @@ static void verify_dma_pinned(unsigned int cmd, struct page **pages, dump_page(page, "gup_test failure"); break; + } else if (cmd == PIN_LONGTERM_BENCHMARK && + WARN(!is_pinnable_page(page), + "pages[%lu] is NOT pinnable but pinned\n", + i)) { + dump_page(page, "gup_test failure"); + break; } } break; diff --git a/tools/testing/selftests/vm/gup_test.c b/tools/testing/selftests/vm/gup_test.c index 42c71483729f..f08cc97d424d 100644 --- a/tools/testing/selftests/vm/gup_test.c +++ b/tools/testing/selftests/vm/gup_test.c @@ -13,6 +13,7 @@ /* Just the flags we need, copied from mm.h: */ #define FOLL_WRITE 0x01 /* check pte is writable */ +#define FOLL_TOUCH 0x02 /* mark page accessed */ static char *cmd_to_str(unsigned long cmd) { @@ -39,11 +40,11 @@ int main(int argc, char **argv) unsigned long size = 128 * MB; int i, fd, filed, opt, nr_pages = 1, thp = -1, repeats = 1, write = 1; unsigned long cmd = GUP_FAST_BENCHMARK; - int flags = MAP_PRIVATE; + int flags = MAP_PRIVATE, touch = 0; char *file = "/dev/zero"; char *p; - while ((opt = getopt(argc, argv, "m:r:n:F:f:abctTLUuwWSHp")) != -1) { + while ((opt = getopt(argc, argv, "m:r:n:F:f:abctTLUuwWSHpz")) != -1) { switch (opt) { case 'a': cmd = PIN_FAST_BENCHMARK; @@ -110,6 +111,10 @@ int main(int argc, char **argv) case 'H': flags |= (MAP_HUGETLB | MAP_ANONYMOUS); break; + case 'z': + /* fault pages in gup, do not fault in userland */ + touch = 1; + break; default: return -1; } @@ -167,8 +172,12 @@ int main(int argc, char **argv) else if (thp == 0) madvise(p, size, MADV_NOHUGEPAGE); - for (; (unsigned long)p < gup.addr + size; p += PAGE_SIZE) - p[0] = 0; + if (touch) { + gup.flags |= FOLL_TOUCH; + } else { + for (; (unsigned long)p < gup.addr + size; p += PAGE_SIZE) + p[0] = 0; + } /* Only report timing information on the *_BENCHMARK commands: */ if ((cmd == PIN_FAST_BENCHMARK) || (cmd == GUP_FAST_BENCHMARK) || -- 2.25.1