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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 CBC0EC4338F for ; Sun, 1 Aug 2021 19:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEABF60F48 for ; Sun, 1 Aug 2021 19:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbhHATt0 (ORCPT ); Sun, 1 Aug 2021 15:49:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhHATtZ (ORCPT ); Sun, 1 Aug 2021 15:49:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9265E60F48; Sun, 1 Aug 2021 19:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1627847357; bh=NTAguXKSk7YmzRLIg8c4guzvhTisx0c9C03a7Nlyj0c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YOoCmi2lFdEaPtaYD77vZpRAJf2VVhXEelHOrQjZnwTuHmEANlsEWHa7qsVv9OGH8 CGDu7AxTpCDyR+YmCJ9k77b+6YOgTJY16BAynxC8wnyLZT7DMjaCKoDudJcH4ztoj4 /hGHSFfDBsTSKnv0otaLCFi95EH3O8zY+QH1txas= Date: Sun, 1 Aug 2021 12:49:17 -0700 From: Andrew Morton To: Mina Almasry Cc: Ken Chen , Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Kennelly Subject: Re: [PATCH v1] mm, hugepages: add mremap() support for hugepage backed vma Message-Id: <20210801124917.ca6fce3972866dc738bfcb7b@linux-foundation.org> In-Reply-To: <20210730221522.524256-1-almasrymina@google.com> References: <20210730221522.524256-1-almasrymina@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Jul 2021 15:15:22 -0700 Mina Almasry wrote: > Support mremap() for hugepage backed vma segment by simply repositioning > page table entries. The page table entries are repositioned to the new > virtual address on mremap(). > > Hugetlb mremap() support is of course generic; my motivating use case > is a library (hugepage_text), which reloads the ELF text of executables > in hugepages. This significantly increases the execution performance of > said executables. > > Restricts the mremap operation on hugepages to up to the size of the > original mapping as the underlying hugetlb reservation is not yet > capable of handling remapping to a larger size. > > Tested with a simple mmap/mremap test case, roughly: > > void* haddr = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, > MAP_ANONYMOUS | MAP_SHARED, -1, 0); > > void* taddr = mmap(NULL, size, PROT_NONE, > MAP_HUGETLB | MAP_ANONYMOUS | MAP_SHARED, -1, 0); > > void* raddr = mremap(haddr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, taddr); Could we please get testing for this added into tools/testing/selftests/?