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=unavailable 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 8B0AFC4361B for ; Wed, 9 Dec 2020 18:42:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2798723B85 for ; Wed, 9 Dec 2020 18:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733167AbgLISlw (ORCPT ); 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/ 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=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 27DB7C433FE for ; Wed, 9 Dec 2020 18:42:12 +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 AB25B23B77 for ; Wed, 9 Dec 2020 18:42:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB25B23B77 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=jjUypNpB0yOABg9AMU+lqmRm8yr9Rma1qkRnoxng5QQ=; b=ALRJOAEOumxaZJDZAyG9VjNB6 UaizUiMOwb2rOnnhmoNwGSMyZnZumlrtowUbu+bkdEHAepYFf5fUk//nM+a/sus5lMVjC7vT1osPC cYxnKTrChY3Ks6kd3LAvqDm3OkJLHS/nbmFP9F+ZAv0Wf9xca61KyrsNxWSDEJAbt8gpZBt3hoAGm Yu+KOk0UQEhI92hken6RKm8SpfBua3UkUkp68eQqaENlC/2GX3Pq5A2lXd6JIl2XhVppv56BRvGEp HjyHEd1irXyIhV7oVuN/++XCUwKg+rZPa6bmr3zycO/w78onRcmODDTZ0n1jSylcert8bKKUg+ptl HXLKIY1nA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn4OY-0007Yo-RF; Wed, 09 Dec 2020 18:40:58 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn4OW-0007Xo-AE for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 18:40:57 +0000 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 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_134056_463308_72B270E2 X-CRM114-Status: GOOD ( 22.43 ) 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: Jan Kara , Minchan Kim , Catalin Marinas , Linux Kernel Mailing List , Linux-MM , Vinayak Menon , "Kirill A . Shutemov" , Andrew Morton , Android Kernel Team , Linux ARM 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 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/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel