From mboxrd@z Thu Jan 1 00:00:00 1970 From: joel@joelfernandes.org (Joel Fernandes) Date: Tue, 16 Oct 2018 12:43:13 -0700 Subject: [PATCH 2/4] mm: speed up mremap by 500x on large regions (v2) In-Reply-To: <35b9c85a-b366-9ca3-5647-c2568c811961@suse.cz> References: <20181013013200.206928-1-joel@joelfernandes.org> <20181013013200.206928-3-joel@joelfernandes.org> <20181015094209.GA31999@infradead.org> <20181015223303.GA164293@joelaf.mtv.corp.google.com> <35b9c85a-b366-9ca3-5647-c2568c811961@suse.cz> Message-ID: <20181016194313.GA247930@joelaf.mtv.corp.google.com> To: linux-riscv@lists.infradead.org List-Id: linux-riscv.lists.infradead.org On Tue, Oct 16, 2018 at 01:29:52PM +0200, Vlastimil Babka wrote: > On 10/16/18 12:33 AM, Joel Fernandes wrote: > > On Mon, Oct 15, 2018 at 02:42:09AM -0700, Christoph Hellwig wrote: > >> On Fri, Oct 12, 2018 at 06:31:58PM -0700, Joel Fernandes (Google) wrote: > >>> Android needs to mremap large regions of memory during memory management > >>> related operations. > >> > >> Just curious: why? > > > > In Android we have a requirement of moving a large (up to a GB now, but may > > grow bigger in future) memory range from one location to another. > > I think Christoph's "why?" was about the requirement, not why it hurts > applications. I admit I'm now also curious :) This issue was discovered when we wanted to be able to move the physical pages of a memory range to another location quickly so that, after the application threads are resumed, UFFDIO_REGISTER_MODE_MISSING userfaultfd faults can be received on the original memory range. The actual operations performed on the memory range are beyond the scope of this discussion. The user threads continue to refer to the old address which will now fault. The reason we want retain the old memory range and receives faults there is to avoid the need to fix the addresses all over the address space of the threads after we finish with performing operations on them in the fault handlers, so we mremap it and receive faults at the old addresses. Does that answer your question? thanks, - Joel 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=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT 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 1F7F6C5ACCC for ; Tue, 16 Oct 2018 19:43:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CE1CA21470 for ; Tue, 16 Oct 2018 19:43:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YMY3HKiJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="V9PgMDNF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE1CA21470 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=txee99mZWsxHNjmpsMWzyUJMkT98Uj2+WPtsJjFmS2c=; b=YMY3HKiJ0T7UUy uvweesoar9dZJ/d5ysx1vtBDkMG1Ph2p3e5X7QTkR5D3y0JckDf3DqzjKuxD75pJ2MH0FAGSha5Z8 JqOMRTLcETjjDDu3eP8kCwZsnRHwCWWuOCTFJ37wSnvf3VaMoXFPoYh7Zbb4KYIFHbVYHhxmQi6no CHc9FtNrL6upLUIm1M2KnFViOAHJEpm6/L5HOfp6cxdi52Hd+j7R9BrjF/pdysDBmLVP8xWMfq1GN uhWEI9l3ZVX/HCKXnSFpdSA48tc7JL837wSo6hkyF1ou/XZymJYwCJRcuDLbn2RPzYw3L/Aofkq+S 4w+hrXh6+zV0bhNPSQpw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCVFd-0007hP-R9; Tue, 16 Oct 2018 19:43:33 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCVFY-0007ad-LD for linux-riscv@lists.infradead.org; Tue, 16 Oct 2018 19:43:30 +0000 Received: by mail-pl1-x642.google.com with SMTP id 30-v6so11482586plb.10 for ; Tue, 16 Oct 2018 12:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4E6/TYIJnb1hpwFXfznXrU9WRJfBcYMDYHXRqDEZgOg=; b=V9PgMDNF7CBl5+Nzjvr0iSOtDiDCQgsN/s5ihAy9noZqWII6hYc6Ts6C5GhDKx8GXO m7lTUaprGsEeUyTBUKqmHo3irjZ1l34Zh9xqtEP2vVvNhHYNULvRTyjfiwn/iz3OaXl0 6o0VR9etFqC0VPLMHRowVmTVSwuMOe0dtplzs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4E6/TYIJnb1hpwFXfznXrU9WRJfBcYMDYHXRqDEZgOg=; b=enaKBwDST01cG8b2NplYf6+O8UTaICBNZ302XZ0pK1lwRowFa8h3L70W+2kNV/XYk/ ITk2gyoP/g1eOMe27KlO8WCED8h1cW6SkhbUhSr+AISxHs299fOtjuww/PCjFuMFd0bd Akv8Oyskl5YbfpJtY1N01QHmoRGkbBOjXpqE7O0+9MCCLMxDaxt7RkOyi7TW7I05XuVF UnRLRxcqdc4+uqSv0KNVuFioCLRzo0WgsC/6Whok1zNeLiE2P4WpN8/ZM4UELbzDv3vE m6xDbwl3KuSfW/Vd7mW6qWA98zAvMYwClzTpEcysv9eMceA7bngDTkmaEjo/DL5K82jc aQFg== X-Gm-Message-State: ABuFfohsNV7cu3u7sCpEmbclU1R/lDR2vvJRKHCumJbwOtxq6+HwalpE 96im4bUuo4VeCCwQEBKmqTmy4Q== X-Google-Smtp-Source: ACcGV62AdBcFxDIb9TDt/mmUnedT1xOttrv1cSqMsBN5bCJGRH95gVqQWD3vO6sNA2FVCR0J+aMC2w== X-Received: by 2002:a17:902:15a8:: with SMTP id m37-v6mr22725955pla.132.1539718996443; Tue, 16 Oct 2018 12:43:16 -0700 (PDT) Received: from localhost ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id s2-v6sm15420002pgo.90.2018.10.16.12.43.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Oct 2018 12:43:14 -0700 (PDT) Date: Tue, 16 Oct 2018 12:43:13 -0700 From: Joel Fernandes To: Vlastimil Babka Subject: Re: [PATCH 2/4] mm: speed up mremap by 500x on large regions (v2) Message-ID: <20181016194313.GA247930@joelaf.mtv.corp.google.com> References: <20181013013200.206928-1-joel@joelfernandes.org> <20181013013200.206928-3-joel@joelfernandes.org> <20181015094209.GA31999@infradead.org> <20181015223303.GA164293@joelaf.mtv.corp.google.com> <35b9c85a-b366-9ca3-5647-c2568c811961@suse.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <35b9c85a-b366-9ca3-5647-c2568c811961@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181016_124328_738497_45AB7171 X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Rich Felker , linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Dave Hansen , Will Deacon , mhocko@kernel.org, linux-mm@kvack.org, lokeshgidra@google.com, sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Jonas Bonn , linux-s390@vger.kernel.org, dancol@google.com, Yoshinori Sato , Max Filippov , linux-hexagon@vger.kernel.org, Helge Deller , "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" , hughd@google.com, "James E.J. Bottomley" , kasan-dev@googlegroups.com, elfring@users.sourceforge.net, Christoph Hellwig , Ingo Molnar , Geert Uytterhoeven , Andrey Ryabinin , linux-snps-arc@lists.infradead.org, kernel-team@android.com, Sam Creasey , linux-xtensa@linux-xtensa.org, Jeff Dike , linux-alpha@vger.kernel.org, linux-um@lists.infradead.org, Stefan Kristiansson , Julia Lawall , linux-m68k@lists.linux-m68k.org, Borislav Petkov , Andy Lutomirski , Ley Foon Tan , kirill@shutemov.name, Stafford Horne , Guan Xuetao , Chris Zankel , Tony Luck , linux-parisc@vger.kernel.org, pantin@google.com, linux-kernel@vger.kernel.org, Fenghua Yu , minchan@kernel.org, Thomas Gleixner , Richard Weinberger , anton.ivanov@kot-begemot.co.uk, nios2-dev@lists.rocketboards.org, akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org, "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org Message-ID: <20181016194313.Cma5dxTt1XBAqsnH5K-8ol6u-pUteLpgieyS3__xgyU@z> On Tue, Oct 16, 2018 at 01:29:52PM +0200, Vlastimil Babka wrote: > On 10/16/18 12:33 AM, Joel Fernandes wrote: > > On Mon, Oct 15, 2018 at 02:42:09AM -0700, Christoph Hellwig wrote: > >> On Fri, Oct 12, 2018 at 06:31:58PM -0700, Joel Fernandes (Google) wrote: > >>> Android needs to mremap large regions of memory during memory management > >>> related operations. > >> > >> Just curious: why? > > > > In Android we have a requirement of moving a large (up to a GB now, but may > > grow bigger in future) memory range from one location to another. > > I think Christoph's "why?" was about the requirement, not why it hurts > applications. I admit I'm now also curious :) This issue was discovered when we wanted to be able to move the physical pages of a memory range to another location quickly so that, after the application threads are resumed, UFFDIO_REGISTER_MODE_MISSING userfaultfd faults can be received on the original memory range. The actual operations performed on the memory range are beyond the scope of this discussion. The user threads continue to refer to the old address which will now fault. The reason we want retain the old memory range and receives faults there is to avoid the need to fix the addresses all over the address space of the threads after we finish with performing operations on them in the fault handlers, so we mremap it and receive faults at the old addresses. Does that answer your question? thanks, - Joel _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv