Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4201132pxu; Wed, 9 Dec 2020 10:45:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvJBP2HQto+tA7HV2k7Dr1iJit0Jro7+s/Ke8Pf1foNKg3MOTA8l2fEdJljZAnIOweqmGy X-Received: by 2002:a17:906:f905:: with SMTP id lc5mr3214147ejb.177.1607539513361; Wed, 09 Dec 2020 10:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607539513; cv=none; d=google.com; s=arc-20160816; b=gVPIkm2r3EQVKgc/zpo/qxHwQBJjjG8mPpvdoeONWGoFsSRX5SBWZPZE2cVfahDhtf hME37x9ka0cfySP327dL0KlUE9ayFaMYa5zse/zVklwwu5tJDKmk7fZdm2pBLSiawXQv jX4KK2YsTedByPsqDJvW3T+aumqp9y+zUaSgr62f/C6y9N7CrCQ3RSid969A+RvWXK4d P7nAh/gg9ncP2wMKjjkusOa2/BnJg0YtSMdi9eRutWo1LDrJmrZDC+RJLCZJObTr9MgX EpRpNMeBjNyGsWQRdKjSbrlHDiuNB+XotA1MbA4UyBedID4E5b/AjwtZQFAPxGAZhyRT BNPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from :dkim-signature:date; bh=T2Iv4bQuvfpPcpXkkVXmo3EcH6PgJ81QRuzRXfgjaUM=; b=HDZceXVc2cFi9k1eMBW/dvLSA6XSHQd5m6UIhwdMw5qpMxTsJwbUOzJEFZU3dyGy7W mL1h2nMrOEaXky1Q9R7u9/HU7b7a8jVjyjFgiz1QpxC9pNJqoDbiPpJZ/YxV01NIBbPE 40IAbqkIoWrCFVUwkExy++kYDKwHJHjlvNr8hq4783TpT7NYHfoy4J5I7cWpioeRg0ZA kvFeh0GI1yoVh3+4i5+DFE3eEhdNYhL8p4zIfBEITwXKGYodYDZTiuZvILW6HH1uWfh9 Lmf73+nsneAK1go6jbrDof98RRCt9+jk+Wg/gfXXTR4yZkju9zZopWc+v0LMFLcTFcNS GSOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iy9itZlx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si1367185eda.107.2020.12.09.10.44.49; Wed, 09 Dec 2020 10:45:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iy9itZlx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733061AbgLISlw (ORCPT + 99 others); Wed, 9 Dec 2020 13:41:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:40630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732158AbgLISlg (ORCPT ); Wed, 9 Dec 2020 13:41:36 -0500 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/