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 CD152C433E0 for ; Mon, 3 Aug 2020 03:51:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6C9822075A for ; Mon, 3 Aug 2020 03:51:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Z5WVfGWo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C9822075A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6124D8D00D4; Sun, 2 Aug 2020 23:51:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59A138D00AA; Sun, 2 Aug 2020 23:51:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 461038D00D4; Sun, 2 Aug 2020 23:51:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id 2B6A88D00AA for ; Sun, 2 Aug 2020 23:51:25 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C2195180AD801 for ; Mon, 3 Aug 2020 03:51:24 +0000 (UTC) X-FDA: 77107882488.13.card04_160649226f9a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 970C918140B7B for ; Mon, 3 Aug 2020 03:51:24 +0000 (UTC) X-HE-Tag: card04_160649226f9a X-Filterd-Recvd-Size: 3285 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Aug 2020 03:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8I3DaixdTox8M5PB85ZtuTeAJfxo74UHSwaDKrGgINE=; b=Z5WVfGWoWoC7TbrxqL63Kjx9A/ XcLQyHtwHj31skWxKNYftk6ZhWXafzjMIWR/dz1/RW19UmNy/crQQg/oxNvOvfYIgGDOyQPZblqtN rMq1kPGqOqs4UUlcjv91AxIYhPSSvQN4vMDBWOhGTwUjTPojiwjchiNGsNS9fkuJAeNSVCm9zBYGW 3MHqmwJ+U7gWObSfXTxUjurmIrcG5p9j8bMYemnAyBcMHtHZ7Pfpekh67L4/Fldgylf/6cf1vBIzb r0dbZZfewbS5Qwm6JC25fQpZt8BAP7oVxTlo8706Ng1S0/hTPZRKgEWcdfhISK+pa9LPnJAy5JNmN tpDGLpsw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2RVK-0005I3-1Z; Mon, 03 Aug 2020 03:51:14 +0000 Date: Mon, 3 Aug 2020 04:51:13 +0100 From: Matthew Wilcox To: John Hubbard Cc: Peter Collingbourne , Andrew Morton , Catalin Marinas , Evgenii Stepanov , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: introduce reference pages Message-ID: <20200803035113.GX23808@casper.infradead.org> References: <20200731203241.50427-1-pcc@google.com> <92fa4a71-d8dc-0f07-832c-cbceca43e537@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <92fa4a71-d8dc-0f07-832c-cbceca43e537@nvidia.com> X-Rspamd-Queue-Id: 970C918140B7B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Aug 02, 2020 at 08:28:08PM -0700, John Hubbard wrote: > This will end up overflowing the page->_refcount in some situations. > > Some thoughts: > > In order to implement this feature, the reference pages need to be made > at least a little bit more special, and probably little bit more like > zero pages. At one extreme, for example, zero pages could be a special > case of reference pages, although I'm not sure of a clean way to > implement that. > > > The reason that more special-ness is required, is that things such as > reference counting and locking can be special-cased with zero pages. > Doing so allows avoiding page->_refcount overflows, for example. Your > patch here, however, allows normal pages to be treated *almost* like a > zero page, in that it's a page full of constant value data. But because > a refpage can be any page, not just a special one that is defined at a > single location, that leads to problems with refcounts. We could bump the refcount on mmap and only put it on munmap. That complexifies a few more paths which now need to check for the VMA special page as well as the zero page on pte unmap. Perhaps a better way around this is that the default page can only be one of the pages in the mmap ... and that page is duplicated (not shared) on fork(). That way the refcount is at most the number of pages in the mmap. And if we constrain the size of these mappings to be no more than 8TB, that constrains the refcount on this page to be no more than 2^31.