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=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 01251C433DF for ; Mon, 3 Aug 2020 09:34:44 +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 C1D3D206D7 for ; Mon, 3 Aug 2020 09:34:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YEF+Le9U"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="AE7BGOYG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1D3D206D7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name 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: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=FPDhHDEozm851l4ExVXk9UWOuYTG94NpuZpEVpmOtjQ=; b=YEF+Le9U8+72fUIq6se+Eng6p ejDPIE4Epkq7PQZFaBtr8To2BRqaA12n164CraxbeJNYn34HE3kYVfUpRF3LItbb7K9iRwyvTmYEv +ZtMDm13Uq1hdJSiInynUyjhQrJKboJ0oPlHJgTg1EXli6WZd4pnuS5nAyZDGaNserMjjbWNLYKsk 9X3pK9UCiVdt5bDndh6PKuKZ1ykEcsdukG6z1aZ186HOIyaCdbmCVEOQAcQuiLEQBMAuObnCswMTY 67ot9Bm357ewVID8PlibwPYpyMHFMfqWtFl2m9oGG6NUpVCamobaWD8dD5QS9m4pw9jOkF0p25ukz rTl6P1VrQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Wq3-0007H1-VJ; Mon, 03 Aug 2020 09:33:00 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Wq0-0007GI-Rp for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 09:32:57 +0000 Received: by mail-lf1-x144.google.com with SMTP id x24so2785968lfe.11 for ; Mon, 03 Aug 2020 02:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mcQI0cC775Sd04iZMIrBeKr+uEG11QbMPcE3c59G3+8=; b=AE7BGOYGIoNiwD5gLMrVBS8icv4i/EEeEs02gUeqKScTO2DxzQ6JHI8J85wd841hsR DjXHErfNfzVICUt1c6wdd8YjLuPax6Jbw5FoG93BwQVTsN0RxVBZ847jteiSQ+LxmlQD oi/bmk9kgZY/fHueFfwvXBDbLrsw8Vd3XdBp7Exw5yGbkkXgLcIbvuLXoB9uVkwcF2My RJxyg5BOnqOzpB9ySF1k4OeFgxxutpSAp+l3b1K7AkR4bXjWmhZakT6HgO3ZzRpvdwJO pbsceHyh9NbHHgz9ccmFAFmC/xfeOhXP4ykyxaOoM7TGl6JF+fKliwt9fFYFERZZZ7MD 70Eg== 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; bh=mcQI0cC775Sd04iZMIrBeKr+uEG11QbMPcE3c59G3+8=; b=ko2kuuL3OIsaES1UpB76LHQLnbBuUEHJKguiZ1oki1WkR0/QFLgqtzrnKeTt07g90U N0sgiLTpp4289+ZpzPdts1tIZjBVL5wH6wy3k4kU1cP/G+/mKGW42Pdirb5uvEL5FGbA XUFeP1JDaUDK6oDrRfMNp0LVr+f0bXpt5kOzOcT1bxdtz8PHgDik/KPtLLT1clrXDROm 13yrln9sqSfOZwL0XnHzE+GTdvHzsmJCT3B/VakD4yIYGwZkZ1W6/f7M8EPQFt7+s9J/ DfI98YpQfpCUVcpFPLcgbKj6fGpZMyNS6FlP1XUAvYZhXwKAj6JiKXcRULusfzWyHxkl FIhw== X-Gm-Message-State: AOAM532tNSXzoNU7KkmiiVr5iH/1bkq80FsUdzS0do3YHbYgU0KwgFNE 1+T1pKfnZMTvjY5HnV2IlSAhqg== X-Google-Smtp-Source: ABdhPJyNfssvlofacXd0vdtqby+h8tUvpSBXJJ9IMENqabOypsf3Klky5WxWuAFteyC0b+Jp/tnOpA== X-Received: by 2002:ac2:488c:: with SMTP id x12mr7619304lfc.4.1596447173545; Mon, 03 Aug 2020 02:32:53 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id v11sm4004247ljh.119.2020.08.03.02.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 02:32:52 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 05B02101674; Mon, 3 Aug 2020 12:33:00 +0300 (+03) Date: Mon, 3 Aug 2020 12:32:59 +0300 From: "Kirill A. Shutemov" To: Peter Collingbourne Subject: Re: [PATCH] mm: introduce reference pages Message-ID: <20200803093259.ookknl4y7ee5hun7@box> References: <20200731203241.50427-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200731203241.50427-1-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200803_053256_950440_AD89A93E X-CRM114-Status: GOOD ( 20.29 ) 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: Catalin Marinas , Andrew Morton , linux-arm-kernel@lists.infradead.org, Evgenii Stepanov , linux-mm@kvack.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 31, 2020 at 01:32:41PM -0700, Peter Collingbourne wrote: > Introduce a new mmap flag, MAP_REFPAGE, that creates a mapping similar > to an anonymous mapping, but instead of clean pages being backed by the > zero page, they are instead backed by a so-called reference page, whose > address is specified using the offset argument to mmap. Loads from > the mapping will load directly from the reference page, and initial > stores to the mapping will copy-on-write from the reference page. > > Reference pages are useful in circumstances where anonymous mappings > combined with manual stores to memory would impose undesirable costs, > either in terms of performance or RSS. Use cases are focused on heap > allocators and include: > > - Pattern initialization for the heap. This is where malloc(3) gives > you memory whose contents are filled with a non-zero pattern > byte, in order to help detect and mitigate bugs involving use > of uninitialized memory. Typically this is implemented by having > the allocator memset the allocation with the pattern byte before > returning it to the user, but for large allocations this can result > in a significant increase in RSS, especially for allocations that > are used sparsely. Even for dense allocations there is a needless > impact to startup performance when it may be better to amortize it > throughout the program. By creating allocations using a reference > page filled with the pattern byte, we can avoid these costs. > > - Pre-tagged heap memory. Memory tagging [1] is an upcoming ARMv8.5 > feature which allows for memory to be tagged in order to detect > certain kinds of memory errors with low overhead. In order to set > up an allocation to allow memory errors to be detected, the entire > allocation needs to have the same tag. The issue here is similar to > pattern initialization in the sense that large tagged allocations > will be expensive if the tagging is done up front. The idea is that > the allocator would create reference pages with each of the possible > memory tags, and use those reference pages for the large allocations. Looks like it's wrong layer to implement the functionality. Just have a special fd that would return the same page for all vm_ops->fault and map the fd with normal mmap(MAP_PRIVATE, fd). It will get you what you want without touching core-mm. -- Kirill A. Shutemov _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel