From patchwork Tue Sep 27 11:01:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12990399 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 34FD0C07E9D for ; Tue, 27 Sep 2022 11:01:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACDFE8E00C4; Tue, 27 Sep 2022 07:01:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7E6E8E00C1; Tue, 27 Sep 2022 07:01:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91F188E00C4; Tue, 27 Sep 2022 07:01:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8277B8E00C1 for ; Tue, 27 Sep 2022 07:01:37 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5F8CD1A0E2B for ; Tue, 27 Sep 2022 11:01:37 +0000 (UTC) X-FDA: 79957574634.25.DFB4A24 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id DA0DC40009 for ; Tue, 27 Sep 2022 11:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664276496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xkTzwNdbrev2vLdkwk3qfmkYbyeGY/wzkkordbf1PA4=; b=Nssm/QzixKT9/+1Sb2N+r6y2E2ciJ/zNf5ML2/nlpRJgVqgdx0So8jdXuHvivTVcDnJRQM igNBXnP40ZIJRSVd6c1ZSLrIM+xgqVN21Zbc6vC2ncfc5srHsXcdAOLCUgxnExTYbJpE2D 35G3Fc6sJiWGGEMd3Gr6LIhCvv4jLtY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-194-vtxyoS1vPpmxrTaBbo-T1Q-1; Tue, 27 Sep 2022 07:01:32 -0400 X-MC-Unique: vtxyoS1vPpmxrTaBbo-T1Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3BA89101E14D; Tue, 27 Sep 2022 11:01:32 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.194.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A58EC15BB1; Tue, 27 Sep 2022 11:01:29 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Shuah Khan , Jason Gunthorpe , John Hubbard , Nadav Amit , Peter Xu , Andrea Arcangeli , Vlastimil Babka , Mike Rapoport , Christoph von Recklinghausen , Don Dutile Subject: [PATCH v1 2/7] selftests/vm: factor out pagemap_is_populated() into vm_util Date: Tue, 27 Sep 2022 13:01:15 +0200 Message-Id: <20220927110120.106906-3-david@redhat.com> In-Reply-To: <20220927110120.106906-1-david@redhat.com> References: <20220927110120.106906-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Nssm/Qzi"; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664276496; a=rsa-sha256; cv=none; b=IezH3Y1EPnKLqBdaraS5PSH3J4L06iVHsBxrMkK92y1JukPVu7f/YXETeefu4VUFkzxjiW sa2XJvc71z3wjGbthVfQpPx5xe5qVUODzJ68qaeworLPxE7vS9YQuTL0IPr562brP0MVOU iPBMQ98eP0nyNE0dpAAN1FyeHr86/uE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664276496; 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=xkTzwNdbrev2vLdkwk3qfmkYbyeGY/wzkkordbf1PA4=; b=UxUE4/Yc35gFSwuiYwk+M/Hqo+hx9wtJJbJRd5p9070DEkkrHNYbXPmRO6j4Wwu+vSUZs9 68mKnVoLekrAvfBXyVniXZGwVnxtWMrukDA27RSRXekQiCQU5fW7ppjTidob9/Ag3X4X0Z fBu76OfbBb7pTyCeBnXnObDln9Oe3SA= X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Nssm/Qzi"; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam01 X-Stat-Signature: 9q6e4ob4ks4f9jk64efgiqxyn5pdwhrr X-Rspamd-Queue-Id: DA0DC40009 X-HE-Tag: 1664276496-478476 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: We'll reuse it in the anon_cow test next. Signed-off-by: David Hildenbrand --- tools/testing/selftests/vm/madv_populate.c | 8 -------- tools/testing/selftests/vm/vm_util.c | 8 ++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/vm/madv_populate.c b/tools/testing/selftests/vm/madv_populate.c index 715a42e8e2cd..60547245e479 100644 --- a/tools/testing/selftests/vm/madv_populate.c +++ b/tools/testing/selftests/vm/madv_populate.c @@ -27,14 +27,6 @@ static size_t pagesize; -static bool pagemap_is_populated(int fd, char *start) -{ - uint64_t entry = pagemap_get_entry(fd, start); - - /* Present or swapped. */ - return entry & 0xc000000000000000ull; -} - static void sense_support(void) { char *addr; diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c index 6456027e1985..d37dbabeb875 100644 --- a/tools/testing/selftests/vm/vm_util.c +++ b/tools/testing/selftests/vm/vm_util.c @@ -35,6 +35,14 @@ bool pagemap_is_swapped(int fd, char *start) return entry & 0x4000000000000000ull; } +bool pagemap_is_populated(int fd, char *start) +{ + uint64_t entry = pagemap_get_entry(fd, start); + + /* Present or swapped. */ + return entry & 0xc000000000000000ull; +} + void clear_softdirty(void) { int ret; diff --git a/tools/testing/selftests/vm/vm_util.h b/tools/testing/selftests/vm/vm_util.h index bb8ec8d69623..691d063e79cc 100644 --- a/tools/testing/selftests/vm/vm_util.h +++ b/tools/testing/selftests/vm/vm_util.h @@ -5,6 +5,7 @@ uint64_t pagemap_get_entry(int fd, char *start); bool pagemap_is_softdirty(int fd, char *start); bool pagemap_is_swapped(int fd, char *start); +bool pagemap_is_populated(int fd, char *start); void clear_softdirty(void); uint64_t read_pmd_pagesize(void); uint64_t check_huge(void *addr);