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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 918B3C2D0E4 for ; Fri, 20 Nov 2020 19:54:35 +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 179F42224E for ; Fri, 20 Nov 2020 19:54:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="obyuAKI+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="rnN1fS4z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 179F42224E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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-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=Ml9thFs/RHD6JQrR4752x9jlWHajcEWaBhkpbIvRIH8=; b=obyuAKI+pgo8dya5099Csy6ck GnnMeyy0HY996Ds0X9/8197Sl37TQ+MZqZ5kjFRugM3WXVl05fE5m32bN4k2q8MnvbQ/WMr11oekG g+xgQgdZeyG4+wGsTxrdIxKb35tGA0sDPpr7y18+PNvp2xVAniZNvwWUpDD3zSlpCyM/cNgd0Q+tt e5Z9J04HorIUansydH/iNswd7JQ9jWU4Avue2IYFFZSih137cEHPDvPJd3Ep+EUXkvZRcS6fZdhvU GcXxxr0QmyjZrDCOsLpJB+U+TQdvO+eu7xNXyo7hisJqIuGlddw2qMoJfImJVlMgmHHEtU9eyq/FC /jGRRG+MQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgCT9-0006t4-Qk; Fri, 20 Nov 2020 19:53:19 +0000 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kgCT7-0006re-DL for linux-arm-kernel@lists.infradead.org; Fri, 20 Nov 2020 19:53:18 +0000 Received: by mail-io1-xd43.google.com with SMTP id t8so11131184iov.8 for ; Fri, 20 Nov 2020 11:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GxnkL7sBSNoqYoJigqom0+XD1YVRiqS6FwGLG7iJAO4=; b=rnN1fS4zx8lj60uqorsVrI3/bKsdKEpgfxSOWN01UgyAtOLtDXXzTzcw82y7Zwm2jj 4t69K1Pf6kMgoVoH25M4P/QarFk9kkw/yUl2Nc1RM9B97YcnzYowzkrgorLOT0hmE+7f HTZq8pNl9P7i4UdG5dqVikedfi4RgHQtz6AmwvgDvnZQDB5l/TR24hX0yfZQDxFxbffz kEU+8CqQYPWFwmcqTeTQ+qh3f7CTXFHID/R5BPF3kkZJr1QgRO9bQz1x6jFnrN9oExvB Z+bOFim2X686YNJFfO8IQZfgMBjjNc8Zcr2SyO5Md8SRJTBcmk5UTqRMS4boS0ewTmJI dcQQ== 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:references :mime-version:content-disposition:in-reply-to; bh=GxnkL7sBSNoqYoJigqom0+XD1YVRiqS6FwGLG7iJAO4=; b=Js5+CrIJNvK+DczKPBM8dhyUfOWELhHTEYODUYKSbnOJhMqY0tLd79cgK9LsiVuE2j z4Npy4wF8WxGAm/F5Xdtl4UYBuHzY6ki+6zyOT6+HyUvkWUlpEMGHwe9a9RYPHnbTWIl boAs25YyJQ3UbFXnoCHcebkcLAXPT2twC5cxYAX6c9kQkNeGxbusc/N0c8ArgqJAC/cc ZLAOpsJpvduNYOojuBbs6/rjj3PwEholxble1N2nO3bT4JzrEb3MXuNXDHiYbx5hpXvc 9DqJIjtLA5rzfWw58dsO6vxrhtcRvBBBtyoIoezbsbUnyqH793iAm5126mOtNlf7C46r eGig== X-Gm-Message-State: AOAM533iou4kqVqAvEi92y5UdqncdJYQ41Vw1Gb+YKIesu56NHNhBHHu HZ5dw8oim+FWCR9Dg2j++k0vcQ== X-Google-Smtp-Source: ABdhPJxSffGKpVjywoxuXIvCRu/AM8DhpUH1m+P2eYdFRYvfM6wAc7GXcabZRhXBoGj9LwhZ0yGeZQ== X-Received: by 2002:a02:90ca:: with SMTP id c10mr21200448jag.115.1605901993088; Fri, 20 Nov 2020 11:53:13 -0800 (PST) Received: from google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) by smtp.gmail.com with ESMTPSA id k26sm1937993iom.32.2020.11.20.11.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 11:53:12 -0800 (PST) Date: Fri, 20 Nov 2020 12:53:08 -0700 From: Yu Zhao To: Will Deacon Subject: Re: [PATCH 1/6] arm64: pgtable: Fix pte_accessible() Message-ID: <20201120195308.GA1303870@google.com> References: <20201120143557.6715-1-will@kernel.org> <20201120143557.6715-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201120143557.6715-2-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201120_145317_490521_C64CDA3D X-CRM114-Status: GOOD ( 20.61 ) 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: kernel-team@android.com, Anshuman Khandual , Peter Zijlstra , Catalin Marinas , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-mm@kvack.org, Minchan Kim , Linus Torvalds , linux-arm-kernel@lists.infradead.org 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 Fri, Nov 20, 2020 at 02:35:52PM +0000, Will Deacon wrote: > pte_accessible() is used by ptep_clear_flush() to figure out whether TLB > invalidation is necessary when unmapping pages for reclaim. Although our > implementation is correct according to the architecture, returning true > only for valid, young ptes in the absence of racing page-table > modifications, this is in fact flawed due to lazy invalidation of old > ptes in ptep_clear_flush_young() where we elide the expensive DSB > instruction for completing the TLB invalidation. > > Rather than penalise the aging path, adjust pte_accessible() to return > true for any valid pte, even if the access flag is cleared. The chance of a system hitting reclaim is proportional to how long it's been running, and that of having mapped but yet to be accessed PTEs is reciprocal, so to speak. I don't reboot my devices everyday, and therefore: Acked-by: Yu Zhao > Cc: > Fixes: 76c714be0e5e ("arm64: pgtable: implement pte_accessible()") > Reported-by: Yu Zhao > Signed-off-by: Will Deacon > --- > arch/arm64/include/asm/pgtable.h | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 4ff12a7adcfd..1bdf51f01e73 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -115,8 +115,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; > #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID)) > #define pte_valid_not_user(pte) \ > ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID) > -#define pte_valid_young(pte) \ > - ((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF)) > #define pte_valid_user(pte) \ > ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) > > @@ -126,7 +124,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; > * remapped as PROT_NONE but are yet to be flushed from the TLB. > */ > #define pte_accessible(mm, pte) \ > - (mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid_young(pte)) > + (mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid(pte)) > > /* > * p??_access_permitted() is true for valid user mappings (subject to the > -- > 2.29.2.454.gaff20da3a2-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel