Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp6617pxx; Mon, 26 Oct 2020 01:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0gyRrbSxzxnM1e+nBguxz13pP7ns3aeFJ3LSjnP/w53ICzoH6RZLsxam2XvO3SV7V4YAP X-Received: by 2002:a50:8c24:: with SMTP id p33mr14744711edp.330.1603701668193; Mon, 26 Oct 2020 01:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603701668; cv=none; d=google.com; s=arc-20160816; b=fwIk9ggZOR54sjqy/KS1zsHqyXJMjaOt7NTpr4x3rvpRhfQQfRl66HIPghf3tRByuD /v7dnjCgvBDfoEx1LgyGyZKxkoliiPjilHwulipmpWBlLsOxbcwZHW6SIseoRcLzGNOY XPQUdmWf0i55cA21FrGI2R6fVvekv0JOYG9yWLIha1f/gZmmCdEFTkt/CuKVoLAp56Cr Q+DH3YJWdOSRAbJ0hdr1VLMU9AJrdjQbMYOuZWvYp6ThgcOuj8Wi+We9siH2kIGrtPG0 6b1+/QBrJw4svqGTtrWLM8VLvG2Jg+OCPo8iYn/q2FpDqAqM5mb7hxcFC3jlZW+rN+3X kyug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=+khF+ZvzeyIHDY5/eKTF89q/JBWMw4rRReFYWF4Hd4w=; b=i0TMPqFr6a/dhFMvaV4URsx1/lb9xCbdBaTmPBTqc4XdVk5cnsfgziLhN19kqnsi8F w4ni9yq+s2JpRJpjmzw/WkQDR6Q98EiwLGy3PRKayWdAwKzChsXrmhhZZ+3TRcRO6pJU TS2qsHwZwju1crMpt9/UwmnnIyLK9Y4/WzEx6DYMmQE/oB8qHXm9BIGxj4WUrnjD3lgU kCFJcWnpLOkhwMdYq5pIOSqQEzj8dboZgJhHDe/8tHwQwFQnMk0breA5PXB8p/1Mo/4v f8sDP9JEoRWLtRbs1p6mHjoqLz04STlgFPAqIYdSoebIapUctg3IFd/+TP1cJi/ErIyY ZNDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=C6vzKzTp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si6715104ejx.576.2020.10.26.01.40.46; Mon, 26 Oct 2020 01:41:08 -0700 (PDT) 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=@nvidia.com header.s=n1 header.b=C6vzKzTp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1770614AbgJZGl0 (ORCPT + 99 others); Mon, 26 Oct 2020 02:41:26 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:12987 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1770526AbgJZGlB (ORCPT ); Mon, 26 Oct 2020 02:41:01 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sun, 25 Oct 2020 23:41:05 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 26 Oct 2020 06:41:00 +0000 Received: from sandstorm.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Mon, 26 Oct 2020 06:41:00 +0000 From: John Hubbard To: Andrew Morton CC: Shuah Khan , Mike Rapoport , Ralph Campbell , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jonathan Corbet , LKML , , , John Hubbard Subject: [PATCH v3 2/9] selftests/vm: use a common gup_test.h Date: Sun, 25 Oct 2020 23:40:14 -0700 Message-ID: <20201026064021.3545418-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201026064021.3545418-1-jhubbard@nvidia.com> References: <20201026064021.3545418-1-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603694465; bh=+khF+ZvzeyIHDY5/eKTF89q/JBWMw4rRReFYWF4Hd4w=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type:X-NVConfidentiality: Content-Transfer-Encoding; b=C6vzKzTpU4BWPEu+QeWyi689JB0MDDzfLgcoADTBK9hJBXuvbxIRWK22Fn4XTOz7K Io39s5Stx+Nnq4lwcxTH5RMOWdpkwViXnZ1mjJdbYo0qnDp6kMex8APbr7+YWX+tbH V8xCUlt0ueqEtZJ3XyT4S39j4ZTFNSPT0sa4kBpDut1DP0MhkHIsClVLCbynHaPW25 nfFS/mvRCRD1WbYfWORLpYNCF0ojASCO3f/GcHdYlwu8FuPyKqmVc0HelH0QZuRnvn 9pLYPTOQFMczMDEjOllvIfGxdOP0t1SGXvCTzcwLvqn0NB3xLQjOtE7W9WaAYRiRyD 8tvDG+qbcFjXQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid the need to copy-paste the gup_test ioctl commands and the struct gup_test definition, between the kernel and the user space application, by providing a new header file for these. This allows easier and safer adding of new ioctl calls, as well as reducing the overall line count. Details: The header file has to be able to compile independently, because of the arguably unfortunate way that the Makefile is written: the Makefile tries to build all of its prerequisites, when really it should be only building the .c files, and leaving the other prerequisites (LOCAL_HDRS) as pure dependencies. That Makefile limitation is probably not worth fixing, but it explains why one of the includes had to be moved into the new header file. Also: simplify the ioctl struct (struct gup_test), by deleting the unused __expansion[10] field. This sort of thing is what you might see in a stable ABI, but this low-level, kernel-developer-oriented selftests/vm system is very much not subject to ABI stability. So "expansion" and "reserved" fields are unnecessary here. Signed-off-by: John Hubbard Cc: J=C3=A9r=C3=B4me Glisse Cc: Jonathan Corbet Cc: Ralph Campbell Cc: Shuah Khan --- mm/gup_test.c | 17 +---------------- mm/gup_test.h | 22 ++++++++++++++++++++++ tools/testing/selftests/vm/Makefile | 2 ++ tools/testing/selftests/vm/gup_test.c | 22 +--------------------- 4 files changed, 26 insertions(+), 37 deletions(-) create mode 100644 mm/gup_test.h diff --git a/mm/gup_test.c b/mm/gup_test.c index 59472ea6aa39..4c2d70d88f24 100644 --- a/mm/gup_test.c +++ b/mm/gup_test.c @@ -4,22 +4,7 @@ #include #include #include - -#define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_test) -#define GUP_BENCHMARK _IOWR('g', 2, struct gup_test) -#define PIN_FAST_BENCHMARK _IOWR('g', 3, struct gup_test) -#define PIN_BENCHMARK _IOWR('g', 4, struct gup_test) -#define PIN_LONGTERM_BENCHMARK _IOWR('g', 5, struct gup_test) - -struct gup_test { - __u64 get_delta_usec; - __u64 put_delta_usec; - __u64 addr; - __u64 size; - __u32 nr_pages_per_call; - __u32 flags; - __u64 expansion[10]; /* For future use */ -}; +#include "gup_test.h" =20 static void put_back_pages(unsigned int cmd, struct page **pages, unsigned long nr_pages) diff --git a/mm/gup_test.h b/mm/gup_test.h new file mode 100644 index 000000000000..931c2f3f477a --- /dev/null +++ b/mm/gup_test.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __GUP_TEST_H +#define __GUP_TEST_H + +#include + +#define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_test) +#define GUP_BENCHMARK _IOWR('g', 2, struct gup_test) +#define PIN_FAST_BENCHMARK _IOWR('g', 3, struct gup_test) +#define PIN_BENCHMARK _IOWR('g', 4, struct gup_test) +#define PIN_LONGTERM_BENCHMARK _IOWR('g', 5, struct gup_test) + +struct gup_test { + __u64 get_delta_usec; + __u64 put_delta_usec; + __u64 addr; + __u64 size; + __u32 nr_pages_per_call; + __u32 flags; +}; + +#endif /* __GUP_TEST_H */ diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/= vm/Makefile index d1ae706d9927..9cc6bc087461 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -130,3 +130,5 @@ endif $(OUTPUT)/userfaultfd: LDLIBS +=3D -lpthread =20 $(OUTPUT)/mlock-random-test: LDLIBS +=3D -lcap + +$(OUTPUT)/gup_test: ../../../../mm/gup_test.h diff --git a/tools/testing/selftests/vm/gup_test.c b/tools/testing/selftest= s/vm/gup_test.c index 00b4731f535e..03f7c4f1beaf 100644 --- a/tools/testing/selftests/vm/gup_test.c +++ b/tools/testing/selftests/vm/gup_test.c @@ -2,39 +2,19 @@ #include #include #include - #include #include #include #include #include - -#include +#include "../../../../mm/gup_test.h" =20 #define MB (1UL << 20) #define PAGE_SIZE sysconf(_SC_PAGESIZE) =20 -#define GUP_FAST_BENCHMARK _IOWR('g', 1, struct gup_test) -#define GUP_BENCHMARK _IOWR('g', 2, struct gup_test) - -/* Similar to above, but use FOLL_PIN instead of FOLL_GET. */ -#define PIN_FAST_BENCHMARK _IOWR('g', 3, struct gup_test) -#define PIN_BENCHMARK _IOWR('g', 4, struct gup_test) -#define PIN_LONGTERM_BENCHMARK _IOWR('g', 5, struct gup_test) - /* Just the flags we need, copied from mm.h: */ #define FOLL_WRITE 0x01 /* check pte is writable */ =20 -struct gup_test { - __u64 get_delta_usec; - __u64 put_delta_usec; - __u64 addr; - __u64 size; - __u32 nr_pages_per_call; - __u32 flags; - __u64 expansion[10]; /* For future use */ -}; - int main(int argc, char **argv) { struct gup_test gup; --=20 2.29.0