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=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 1F405C4167B for ; Wed, 9 Dec 2020 18:40:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5917122BF3 for ; Wed, 9 Dec 2020 18:40:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5917122BF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 89B648D0037; Wed, 9 Dec 2020 13:40:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 84CEE8D0031; Wed, 9 Dec 2020 13:40:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 713E78D0037; Wed, 9 Dec 2020 13:40:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 576478D0031 for ; Wed, 9 Dec 2020 13:40:57 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 12FC08249980 for ; Wed, 9 Dec 2020 18:40:57 +0000 (UTC) X-FDA: 77574610554.12.toy42_3b03b48273f1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id E545F180555DE for ; Wed, 9 Dec 2020 18:40:56 +0000 (UTC) X-HE-Tag: toy42_3b03b48273f1 X-Filterd-Recvd-Size: 3867 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 18:40:56 +0000 (UTC) Date: Wed, 9 Dec 2020 18:40:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607539255; bh=AKh72l/qCDJ+OF5xZaRceF1XEBCreajcbzaT7M4kvfw=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=Iy9itZlx7gE6PT6ZwwhQ01TtLlW69FypnHVNorFWzLp395LNO8/HID27Ch0/MMQM8 Az9qi7eDLyKJyf8vX9699KLigiwiHWtneFKfKmqUemRzmmaCb/DR4udaUyuOenUe8W eTdBAT+5NBALSn5vn4MntkmvYfl3CQz0MPlt8ZzHQCwQ50OtdMhFkXhDXhiaiekZ16 JpVUXG7SGNwW8UqHtbvbr1taBWRHsWHdLmKHk2CeFyf6P34yQS1SXCLO6LET52ObEm u/08UTlpiTrfMorXbW2oLJEcdPxfokupyFc6iSBjhc4i9Vn+lJZzDQqYveTW93GFis O+S36NFLObA9A== From: Will Deacon To: Linus Torvalds Cc: Linux Kernel Mailing List , Linux-MM , Linux ARM , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , "Kirill A . Shutemov" , Vinayak Menon , Android Kernel Team Subject: Re: [PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting Message-ID: <20201209184049.GA8778@willie-the-truck> References: <20201209163950.8494-1-will@kernel.org> <20201209163950.8494-2-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 Wed, Dec 09, 2020 at 09:58:12AM -0800, Linus Torvalds wrote: > On Wed, Dec 9, 2020 at 8:40 AM Will Deacon wrote: > > > > @@ -3978,8 +3994,17 @@ static vm_fault_t do_fault_around(struct vm_fault *vmf) > > > > /* check if the page fault is solved */ > > vmf->pte -= (vmf->address >> PAGE_SHIFT) - (address >> PAGE_SHIFT); > > - if (!pte_none(*vmf->pte)) > > - ret = VM_FAULT_NOPAGE; > > + if (pte_none(*vmf->pte)) > > + goto out_unlock; > > + > > + if (vmf->flags & FAULT_FLAG_PREFAULT_OLD) { > > + pte_t pte = pte_mkyoung(*vmf->pte); > > + if (ptep_set_access_flags(vmf->vma, address, vmf->pte, pte, 0)) > > + update_mmu_cache(vmf->vma, address, vmf->pte); > > + } > > Oh, please dear God no. > > First you incorrectly set it old, and then you conditionally make it > young again and as a result force an atomic rwm update and another TLB > flush for no good reason. There shouldn't be a TLB flush here, but I agree that it would have to go and nobble the hash for PowerPC if they wanted to enable this. > Just make sure that the FAULT_FLAG_PREFAULT_OLD never sets the > *actual* address to old. > > And yes, that probably means that you need to change "alloc_set_pte()" > to actually pass in the real address, and leave "vmf->address" alone - > so that it can know which ones are prefaulted and which one is real, > but that sounds like a good idea anyway. Right, I deliberately avoided that based on the feedback from Jan on an older version [1], but I can certainly look at it again. > Then you can just make alloc_set_pte() do the right thing in the first > place, instead of doing this nasty "lets do it wrong and fix it up > later" horror. I'll have a crack at this in v2. Cheers, Will [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/1511845670-12133-1-git-send-email-vinmenon@codeaurora.org/