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=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 C1568C433DF for ; Mon, 3 Aug 2020 03:29:59 +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 91072206F6 for ; Mon, 3 Aug 2020 03:29:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="276DGp91"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="T3YaTWWL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91072206F6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com 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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3/iEo+ze0wyYunr6r6GuinzxEQTBcW66mohQ471tMs0=; b=276DGp91LThz5ev5MyrJ7aYKr gvUtm7HG2pffrhjz5dZghWOKfxgC3NuiNrmZHwqr514ljjjxTKd2NQIXfpNSw9Korv/Vv3bk8XPrr TU2A+ye9U5h5+S+r7qqBttvFFhIs/wDJ/YERQ/LeVYICAvNGP0gX+d0L3ND0ykrGOR18fgO9Bf7Sc jvRXB8UruI602qfgoBc/CLHNGetXLIukXGh2fa6DLYps93cgM38LExGldeweQ+XoWWeQCA0qrxT1a oISL9Tc5NFJgHQKQDMQUt9D4Oeh/TLltad77pj7kFu3QVbZ3VJFLcAF8+NYh6Hi72JpfEkIaGLgfD 8ZjxSQPlQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2R98-0003vt-1W; Mon, 03 Aug 2020 03:28:18 +0000 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2R94-0003uj-B8 for linux-arm-kernel@lists.infradead.org; Mon, 03 Aug 2020 03:28:16 +0000 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 02 Aug 2020 20:27:55 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Sun, 02 Aug 2020 20:28:09 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sun, 02 Aug 2020 20:28:09 -0700 Received: from [10.2.58.124] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 3 Aug 2020 03:28:08 +0000 Subject: Re: [PATCH] mm: introduce reference pages To: Peter Collingbourne , Andrew Morton , Catalin Marinas References: <20200731203241.50427-1-pcc@google.com> From: John Hubbard Message-ID: <92fa4a71-d8dc-0f07-832c-cbceca43e537@nvidia.com> Date: Sun, 2 Aug 2020 20:28:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200731203241.50427-1-pcc@google.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1596425275; bh=to3PWnCaeBvNqUxrIlIx1/WQ3rw7XROT9vzswJSETpU=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=T3YaTWWLp1kixcjQgNOXuUZbtvEwm9z/lZE5GMolMF9tlKN8ut0SQe+6QIGAtbnwG xr1RxDwiv6ToFL4Fw1sxXcuL5PqbYC97Pk2j2/GM7fb9eK8RI7wCeClmODnB7Z+ny4 3m38u0Fadd1erRB+BQGve+s+yw5i3STBvegY/xfwaxTpdxuEDKuTwza1pNYZlaGkao X0XsHlC0oDHIo78gE2xR9SmwTln0fBNaJvnB7Z1dyx1ygJX3OTZJ/Z5hH/B0kfnFjj W83uksDqqCxTijJaCJwPgPMI61Y0i3iO0BUjJPOoS7cxu6ujl3hkUQBZJiAeE+IHyN ftkIB9rtJ/G5g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200802_232814_652883_BF5C8EFA X-CRM114-Status: GOOD ( 20.72 ) 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: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Evgenii Stepanov Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/31/20 1:32 PM, Peter Collingbourne wrote: ... Hi, I can see why you want to do this. A few points to consider, below. btw, the patch would *not* apply for me, via `git am`. I finally used patch(1) and that worked. Probably good to mention which tree and branch this applies to, as a first step to avoiding that, but I'm not quite sure what else went wrong. Maybe use stock git, instead of 2.28.0.163.g6104cc2f0b6-goog? Just guessing. > @@ -1684,9 +1695,33 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags) > return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; > } > > +static vm_fault_t refpage_fault(struct vm_fault *vmf) > +{ > + struct page *page; > + > + if (get_user_pages((unsigned long)vmf->vma->vm_private_data, 1, 0, > + &page, 0) != 1) > + return VM_FAULT_SIGSEGV; > + 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. > + vmf->page = page; > + return VM_FAULT_LOCKED; Is the page really locked, or is this a case of "the page is special and we can safely claim it is locked"? Maybe I'm just confused about the use of VM_FAULT_LOCKED: I thought you only should set it after locking the page. > +} > + > +static void refpage_close(struct vm_area_struct *vma) > +{ > + /* This function exists only to prevent is_mergeable_vma from allowing a > + * reference page mapping to be merged with an anonymous mapping. > + */ While it is true that implementing a vma's .close() method will prevent vma merging, this is an abuse of that function: it depends on how that function is implemented. And given that refpages represent significant new capability, I think they deserve their own "if" clause (and perhaps a VMA flag) in is_mergeable_vma(), instead of this kind of minor hack. thanks, -- John Hubbard NVIDIA _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel