From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 AFCCAC433E0 for ; Sun, 12 Jul 2020 20:39:47 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 C674C206E2 for ; Sun, 12 Jul 2020 20:39:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=pm.me header.i=@pm.me header.b="JMmUGmf+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C674C206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=pm.me Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1juikV-0000nx-5s; Sun, 12 Jul 2020 16:38:59 -0400 Received: from mail-40136.protonmail.ch ([185.70.40.136]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from <0x60@pm.me>) id 1juikS-0000nf-R8 for kernelnewbies@kernelnewbies.org; Sun, 12 Jul 2020 16:38:57 -0400 Date: Sun, 12 Jul 2020 20:38:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1594586331; bh=602g8IpoXwXtQqHy/Me7YJZS0/6QyLPb5xHjcWKDkMM=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=JMmUGmf+4etBAHrUlY3+GELaYYLW0IrcNPZLNyOQgm1GwsEfkPEpmjE2xCCTkEuh7 g22ODG9qYt3co3D9MzNSfc/x6N14B+XIDZRy2I5OROeTQsROp+bgiFW70yIM8r+Y3q nxOlKVTFiXP3vJgA4eaQ1V923ZGbzkg8FXmUEEuRNb9Va7FKCWxW7TxZahH2/xN8cf 0iI52oD2KWwqHCUS9ENUc/rwpls+FA5taHC/kOLtrx5HDPcEWnecGyc4JC7RnWm2Kf dCahMU+5BpP7RW/VyKweylDR/KthIUvFy95WWpsXrTJUGwycbuOfFU89rgcIP2cniM h1c7qZ+P6QKgA== To: "kernelnewbies@kernelnewbies.org" From: heep <0x60@pm.me> Subject: Turn private hugetlb mapping into VM_SHARED Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: heep <0x60@pm.me> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Hello, list, I am working on a tool to introspect live memory of KVM machines, and mmapping its memory, instead of calling process_vm_readv on every read, would increase its performance significantly. Understandably, almost all virtual machine monitors (like QEMU) create private mappings for the memory. So, trying to understand the memory managment subsystem I am hoping to write a kernel module to do the remappings, and conversion from private, to shared mappings. My current focus is on hugetlb pages. At first, I remapped the pages using remap_pfn_range, but there is a memory safety risk when the VM shuts off, and that memory gets used elsewhere. Now, I am trying to turn the underlying mapping into a shared one, so that the kernel can keep track of the memory used. What would be the best way to do so? I noticed there is resv_map that stores represented mappings, and while on private mappings it's on vma, on the shared ones - it is in the inode, but making the inode point to the VMAs map leads to a bus error in userspace. I must be missing some key pieces. Does anyone know how to best achieve what I am trying to? Or is it something fundamentally wrong to do? Many thanks, Auri B. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies