From patchwork Sun Feb 7 08:18:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhou Wang X-Patchwork-Id: 12072657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AA18C43381 for ; Sun, 7 Feb 2021 08:28:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1ADCC64E72 for ; Sun, 7 Feb 2021 08:28:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1ADCC64E72 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=ySz1SEDBgYTsXNXFz70Ku7Z7kAbIQ2jEaBMdaAB8quI=; b=iuk6On2iKwlsR3+3ib1z4mJXKH OICR3ORZDwzlwNVgF8IGSy7VL3KslmCbyqLDGhd9eYQHEQ/yzoPdkj+97My9q3RkVt7QFhDRNF9tw A9moy5Zp0QB2r/CXt2Kwmdy/EMARJjQvStHVovMtnksZQ0ubhDWs6KGsvlGbRcIvk9q9mOk/CbNAZ xnOPd8UY+c40ngAcSoWMHXH4LDoyBOW4Ip8oH6/BlnM1hkxNMa7SRkLnEYq0MgWRXu/CWH8n2v3e5 usvq9yXLrI94XJKaFpyuaD/PNjK0+vyqYz+8yqWS61O0j17kce6kveZ8NJL96hyTU3TShrQ7fOvFb Btkhs1JA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l8fP2-0008Uv-2E; Sun, 07 Feb 2021 08:26:44 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l8fOr-0008NX-Bj for linux-arm-kernel@lists.infradead.org; Sun, 07 Feb 2021 08:26:39 +0000 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DYMf66cr2zjKdl; Sun, 7 Feb 2021 16:25:02 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Sun, 7 Feb 2021 16:26:15 +0800 From: Zhou Wang To: , , , , , Andrew Morton , Alexander Viro Subject: [RFC PATCH v3 0/2] mempinfd: Add new syscall to provide memory pin Date: Sun, 7 Feb 2021 16:18:02 +0800 Message-ID: <1612685884-19514-1-git-send-email-wangzhou1@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210207_032634_408615_0B4EA411 X-CRM114-Status: GOOD ( 10.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: song.bao.hua@hisilicon.com, jean-philippe@linaro.org, kevin.tian@intel.com, jgg@ziepe.ca, gregkh@linuxfoundation.org, eric.auger@redhat.com, Zhou Wang , zhangfei.gao@linaro.org, liguozhu@hisilicon.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series adds a new mempinfd syscall to offer a common way to pin/unpin memory. Patch 1/2 is about mempinfd codes. Patch 2/2 adds a simple test tool about mempinfd. Change logs: ------------ v2 -> v3: - Follow suggestions from Greg and Kevin, add a new syscall. - Add input check. - Use xa_insert to replace xa_store. - Add lock to pretect pin and xa_insert. v1 -> v2: - Some tiny fixes. - Follow Greg's suggestion to get mm-list and iommu-list involved. Links: ------ - v2: https://www.spinics.net/lists/kernel/msg3808926.html - v1: https://www.spinics.net/lists/kernel/msg3805205.html Zhou Wang (2): mempinfd: Add new syscall to provide memory pin selftests/vm: add mempinfd test arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 + fs/Makefile | 1 + fs/mempinfd.c | 199 ++++++++++++++++++++++++++++++++++ include/linux/syscalls.h | 1 + include/uapi/asm-generic/unistd.h | 4 +- include/uapi/linux/mempinfd.h | 23 ++++ init/Kconfig | 6 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mempinfd.c | 131 ++++++++++++++++++++++ 10 files changed, 368 insertions(+), 2 deletions(-) create mode 100644 fs/mempinfd.c create mode 100644 include/uapi/linux/mempinfd.h create mode 100644 tools/testing/selftests/vm/mempinfd.c