Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1361394imm; Sun, 23 Sep 2018 02:23:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZAHxoswA3W4N73o/S01Uxf8kvpheXkp6T+YstKcTQaMv4KPG6U+lbog0MXe3rHOX7u/aPq X-Received: by 2002:a62:68c3:: with SMTP id d186-v6mr5649524pfc.70.1537694624566; Sun, 23 Sep 2018 02:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537694624; cv=none; d=google.com; s=arc-20160816; b=Yycrq8bUGVYFOfs2duAK60iIdjSBZEEyAa1A0PS1DZOwQDAQ9U70Rs8yJWcfHm2Pwp FwT3hG+zzjnrHdspjY+GkN9NSLMKAR2znnzxnUBbuovAPJarnw0P40jwsLpzXbOYI9Ms H7S9BuwO/U99l+NTA867P1ZC7i9S6J5+MOPH99FOFLxSbuzXSvh+zp+h4hEa8AdDyRRt 3SQo6APj9LLRlZ0tIGn8EeILPNsHhCHbXBPpesdb9uHUvvK8CK9cM4xv/0eGxCNggwIU k0z6u0r1zT6R68aYKPI/Fqf2O9aMdMvgtJAVQP8g4DXlRceNnhUoMX0zvBoMbMpHax2A 2ToQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=HTp/UI3ZNNsXvQvkOEXt+YcwGy265tVijee0umcwmNc=; b=U6ptwOLSGDO7Qgk+SRxkXiEWVWmtqwPhm8aJDQdB3x3NN3o4WN1T47hIWDVX6j0VdD cqBhSbYbET4hHAC03KU7kOJrtHmnA5JpsWRx/jjnrWTb6F0HxfKX6VNJikxVjuvLbvai bOCO5gjHQCkO0zlXq57XPviDCSPz867cPv33EkdhNmNKAe0T87l5pGwZayb3d5Qv8vVg s7m5tJMnvQBofbOjvtyDMnDso2rRBZyjo4z2QIVOMgtuLLYlsZWdIxsPuaMJZ7P2Xth6 1X5wC5H/w212kE8QEzdIrmLUfb4jRuAa1ShS7PokFxZWZMX451cnP84FJPYLiZHwbmwO 5oCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tHlcU1hz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6-v6si31049656pgh.569.2018.09.23.02.23.28; Sun, 23 Sep 2018 02:23:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tHlcU1hz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbeIWPUL (ORCPT + 99 others); Sun, 23 Sep 2018 11:20:11 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37172 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726087AbeIWPUL (ORCPT ); Sun, 23 Sep 2018 11:20:11 -0400 Received: by mail-pl1-f195.google.com with SMTP id q1-v6so2345969plr.4; Sun, 23 Sep 2018 02:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HTp/UI3ZNNsXvQvkOEXt+YcwGy265tVijee0umcwmNc=; b=tHlcU1hzz0nUH4e2K2epN6LmLDt1pt0pT/9g7QctX+iVhiBdCPVFO3/ocOnwawf0gU YKqw9uQUi2PbLbu+jUs7ftQqubQJjNjn1ways3RVk1bzycHnsxfd1OAo4uK3nkgU0GHQ 4zxrzBHnNNCcvGnGrb326hOBXepBVpCg2VOZKrMlUcdiuuNZmyux97jCHVEF6fvAdVel jRibKXTnudUxSYTVYZnX/pObq7H7v6ahzINGJipTLbVA4p8pgMEu5vrQveOEcKJjvJcA VxbtxcLujyPoVFyyAoixRgEB43S9mhLSukQoFT731ccpyNYrBM7lLQNSXdpVmi+/Zp0e 5mQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HTp/UI3ZNNsXvQvkOEXt+YcwGy265tVijee0umcwmNc=; b=NTOGIcfgSycTrgbh5lmzaACN5OH6EEEBRin7ESXvUsVvGI6ZWDrvZ/uCo7i6zg6UCi pw0/N6MlRRpaDJKA9VY2No08bYSYD1YViGl6f9oMa7K4q0dacRYZ/rKXM1Uqg0mgqSK9 LlKnHxQQkvHfyJ10KhgR52AWR8SRBt3WCaJCdKoIGf4rSaDvQWHj2RzvOcA2SBrX6A4Y G8RKa6aksIDNCsEM28FF5ERCs/2YnBeyIG3QY8zlQtl+u++zUHJyl7tqFSu2bwNxVVhp 4bEtF6af7C6NAJrPVkMPFMGYl9H2xPr56l9hTtzQNzNpx6sCQXGUb4pUD7phPyMuQFkm vztQ== X-Gm-Message-State: ABuFfohgPdkFEFnxonYlwNfbpLGSLzb+Br8tfgG1Cpm8RtRNBeB8mJJn fVjMiIovg0O03oxejIj63Pw= X-Received: by 2002:a17:902:a507:: with SMTP id s7-v6mr5667059plq.303.1537694602832; Sun, 23 Sep 2018 02:23:22 -0700 (PDT) Received: from roar.ozlabs.ibm.com (59-102-83-213.tpgi.com.au. [59.102.83.213]) by smtp.gmail.com with ESMTPSA id 143-v6sm48835281pfy.156.2018.09.23.02.23.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Sep 2018 02:23:21 -0700 (PDT) Date: Sun, 23 Sep 2018 19:23:15 +1000 From: Nicholas Piggin To: Ley Foon Tan Cc: Guenter Roeck , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Andrew Morton , Linus Torvalds , Ley Foon Tan , nios2-dev@lists.rocketboards.org Subject: Re: [PATCH 3/3] mm: optimise pte dirty/accessed bit setting by demand based pte insertion Message-ID: <20180923192315.13cb4114@roar.ozlabs.ibm.com> In-Reply-To: <1537519325.19048.0.camel@intel.com> References: <20180828112034.30875-1-npiggin@gmail.com> <20180828112034.30875-4-npiggin@gmail.com> <20180905142951.GA15680@roeck-us.net> <20180918035337.0727dad0@roar.ozlabs.ibm.com> <1537519325.19048.0.camel@intel.com> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 Sep 2018 16:42:05 +0800 Ley Foon Tan wrote: > On Tue, 2018-09-18 at 03:53 +1000, Nicholas Piggin wrote: > > On Wed, 5 Sep 2018 07:29:51 -0700 > > Guenter Roeck wrote: > > > > > > > > Hi, > > > > > > On Tue, Aug 28, 2018 at 09:20:34PM +1000, Nicholas Piggin wrote: > > > > > > > > Similarly to the previous patch, this tries to optimise > > > > dirty/accessed > > > > bits in ptes to avoid access costs of hardware setting them. > > > > > > > This patch results in silent nios2 boot failures, silent meaning > > > that > > > the boot stalls. > > Okay I just got back to looking at this. The reason for the hang is > > I think a bug in the nios2 TLB code, but maybe other archs have > > similar > > issues. > > > > In case of a missing / !present Linux pte, nios2 installs a TLB entry > > with no permissions via its fast TLB exception handler (software TLB > > fill). Then it relies on that causing a TLB permission exception in a > > slower handler that calls handle_mm_fault to set the Linux pte and > > flushes the old TLB. Then the fast exception handler will find the > > new > > Linux pte. > > > > With this patch, nios2 has a case where handle_mm_fault does not > > flush > > the old TLB, which results in the TLB permission exception > > continually > > being retried. > > > > What happens now is that fault paths like do_read_fault will install > > a > > Linux pte with the young bit clear and return. That will cause nios2 > > to > > fault again but this time go down the bottom of handle_pte_fault and > > to > > the access flags update with the young bit set. The young bit is seen > > to > > be different, so that causes ptep_set_access_flags to do a TLB flush > > and > > that finally allows the fast TLB handler to fire and pick up the new > > Linux pte. > > > > With this patch, the young bit is set in the first handle_mm_fault, > > so > > the second handle_mm_fault no longer sees the ptes are different and > > does not flush the TLB. The spurious fault handler also does not > > flush > > them unless FAULT_FLAG_WRITE is set. > > > > What nios2 should do is invalidate the TLB in update_mmu_cache. What > > it > > *really* should do is install the new TLB entry, I have some patches > > to > > make that work in qemu I can submit. But I would like to try getting > > these dirty/accessed bit optimisation in 4.20, so I will send a > > simple > > path to just do the TLB invalidate that could go in Andrew's git > > tree. > > > > Is that agreeable with the nios2 maintainers? > > > > Thanks, > > Nick > > > Hi > > Do you have patches to test? I've been working on some, it has taken longer than I expected, I'll hopefully have something to send out by tomorrow. Thanks, Nick