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=-3.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS 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 674CDC04AB1 for ; Thu, 9 May 2019 12:45:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34BAE21479 for ; Thu, 9 May 2019 12:45:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34BAE21479 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BC5FF6B0007; Thu, 9 May 2019 08:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B008B6B0008; Thu, 9 May 2019 08:45:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9793C6B000A; Thu, 9 May 2019 08:45:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 6A5B16B0007 for ; Thu, 9 May 2019 08:45:02 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id v3so2408773qtp.23 for ; Thu, 09 May 2019 05:45:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:message-id:in-reply-to:references:subject:mime-version :content-transfer-encoding:thread-topic:thread-index; bh=+phK1cVXiJnNn5EyClT7CUVOqZ4BhMstBmQ1KciQlp0=; b=cn7Q4+dO4ymvdvmuRQDPCjOGc/VR8F0h5DSq1mH3BPEWlvXTgq1LCxi+yTt5InuhZV D3W8AWIDEIBza3oCrbWmEJpCwRzYrN03kdpyRRnWQaGj/bVfrxKuSEKIwExdBeESH//r ed27ZVvDQ6P++O939Tb4Ps/ECmUge5i8VZnZ/WpFZOcNCYij3qBHX9hxTpXo/ttw6/6b NPGD0lc21jai2Xy377UDZF8YbVW4J7RQz71iEkEIyPwN7yIZ+UHaaxy6JAsXsdt02LEy U31Let59walfjiCZ4n7efB9mLgIUcae3Yk1sapfI+VapO4jGixZZUTj/DBmMum0ppVgf mD0g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstancek@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jstancek@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAUU9z6Si06zX74dTJq+9qLFEdcTroHQXWWG6o1TPri6lPxb7lvQ oA3R2LKr4DpbfflYzVaVuuP54qWhbtQ8CUbEpAOcxVrZ8fOnpf9eMbauL80qZH0d2yq34tVUQVY 52lRl0bQBSMJojRekn1P/mkKY1o5GhdDNfFIRsKO8a1oLLrrsDOJmiANXvmn+dUzoxw== X-Received: by 2002:aed:23d5:: with SMTP id k21mr3417494qtc.191.1557405902121; Thu, 09 May 2019 05:45:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+2nP/fOzwtM0X8FLM16ouzlWj8+5YVlQQuk9ro03ZHiBglci4bPlaLLJZtiR0IloJZbU0 X-Received: by 2002:aed:23d5:: with SMTP id k21mr3417436qtc.191.1557405901379; Thu, 09 May 2019 05:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557405901; cv=none; d=google.com; s=arc-20160816; b=WFbTGQV+Y6sRL1HBnRjyq02Pz/qNXlcVKgtbn9P5wcs6jGz/1Fz09NZWL3a2xlaJJy 1GmFVyYzsBGFlUhPVMiekJgRdwaqKzAsVHZwINogaf+C7swcUYx1cT6eyKIHlW7WmObt HJL8G0gp1Q9IyYvv4EWuGJzgHRLFhXh/pZluBEVoTgNBVJlU9+04AyX74leOxsL7VgOQ WbClfy63AW8jCvb+MuOPv6DK/W8bi/E1Zm5+keaoY8hAdbKEbS+7p2F9jpM+exIVtFAF 6HSIu5rXjfQGNu+i39kZVab7mSfaN3c1xrI55fBoobB6YWZ7gqoeuoCtu3FYs7HQig2T gpqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=thread-index:thread-topic:content-transfer-encoding:mime-version :subject:references:in-reply-to:message-id:cc:to:from:date; bh=+phK1cVXiJnNn5EyClT7CUVOqZ4BhMstBmQ1KciQlp0=; b=tGVVxqqjeQ/IH+7GfIKg6d2E7CydP8BDVPWGr0ASoqL1tDXXz1KLm1kCRe0KevHsKJ ZIbLKkumiLxLZr20dY3PQ5udhTYPuJEg66R/PnB9xhPufUsUq0IvJX9dSfb0qgW2kjFT yYy8YaO5NZxIoJThp8hdzhKPfJOe5OTCJnIGEgxjuC/xrlilwZWLAB30o0kTezlaZy2Z A6thoJ6UgdDberwAte31fpFI4tG0nSn5/Jh9VyY9fsBuuVtpf44iJd1J4/iG9gjZn0bi l3MNKtyhGQxax6H2dMkTNDImxvZtr5dR1GHvJ+GI36BtyAZPVkTbwIU1go8tlDJP5m/m yK5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jstancek@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jstancek@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id u90si1523523qvu.24.2019.05.09.05.45.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 05:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of jstancek@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstancek@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jstancek@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75C62369D2; Thu, 9 May 2019 12:45:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FDE64F84; Thu, 9 May 2019 12:45:00 +0000 (UTC) Received: from zmail17.collab.prod.int.phx2.redhat.com (zmail17.collab.prod.int.phx2.redhat.com [10.5.83.19]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 31EFE3FAF4; Thu, 9 May 2019 12:45:00 +0000 (UTC) Date: Thu, 9 May 2019 08:44:57 -0400 (EDT) From: Jan Stancek To: Peter Zijlstra Cc: Will Deacon , Yang Shi , akpm@linux-foundation.org, stable@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, aneesh kumar , npiggin@gmail.com, namit@vmware.com, minchan@kernel.org, Mel Gorman , Jan Stancek Message-ID: <436298752.21855393.1557405897147.JavaMail.zimbra@redhat.com> In-Reply-To: <20190509103813.GP2589@hirez.programming.kicks-ass.net> References: <1557264889-109594-1-git-send-email-yang.shi@linux.alibaba.com> <20190509083726.GA2209@brain-police> <20190509103813.GP2589@hirez.programming.kicks-ass.net> Subject: Re: [PATCH] mm: mmu_gather: remove __tlb_reset_range() for force flush MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.204.125, 10.4.195.27] Thread-Topic: mmu_gather: remove __tlb_reset_range() for force flush Thread-Index: DI/vebM+Rldg1xz41Sw2XzYn9lA53w== X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 09 May 2019 12:45:00 +0000 (UTC) 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: > > I don't think we can elide the call __tlb_reset_range() entirely, since I > > think we do want to clear the freed_pXX bits to ensure that we walk the > > range with the smallest mapping granule that we have. Otherwise couldn't we > > have a problem if we hit a PMD that had been cleared, but the TLB > > invalidation for the PTEs that used to be linked below it was still > > pending? > > That's tlb->cleared_p*, and yes agreed. That is, right until some > architecture has level dependent TLBI instructions, at which point we'll > need to have them all set instead of cleared. > > > Perhaps we should just set fullmm if we see that here's a concurrent > > unmapper rather than do a worst-case range invalidation. Do you have a > > feeling > > for often the mm_tlb_flush_nested() triggers in practice? > > Quite a bit for certain workloads I imagine, that was the whole point of > doing it. > > Anyway; am I correct in understanding that the actual problem is that > we've cleared freed_tables and the ARM64 tlb_flush() will then not > invalidate the cache and badness happens? That is my understanding, only last level is flushed, which is not enough. > > Because so far nobody has actually provided a coherent description of > the actual problem we're trying to solve. But I'm thinking something > like the below ought to do. I applied it (and fixed small typo: s/tlb->full_mm/tlb->fullmm/). It fixes the problem for me. > > > diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c > index 99740e1dd273..fe768f8d612e 100644 > --- a/mm/mmu_gather.c > +++ b/mm/mmu_gather.c > @@ -244,15 +244,20 @@ void tlb_finish_mmu(struct mmu_gather *tlb, > unsigned long start, unsigned long end) > { > /* > - * If there are parallel threads are doing PTE changes on same range > - * under non-exclusive lock(e.g., mmap_sem read-side) but defer TLB > - * flush by batching, a thread has stable TLB entry can fail to flush > - * the TLB by observing pte_none|!pte_dirty, for example so flush TLB > - * forcefully if we detect parallel PTE batching threads. > + * Sensible comment goes here.. > */ > - if (mm_tlb_flush_nested(tlb->mm)) { > - __tlb_reset_range(tlb); > - __tlb_adjust_range(tlb, start, end - start); > + if (mm_tlb_flush_nested(tlb->mm) && !tlb->full_mm) { > + /* > + * Since we're can't tell what we actually should have > + * flushed flush everything in the given range. > + */ > + tlb->start = start; > + tlb->end = end; > + tlb->freed_tables = 1; > + tlb->cleared_ptes = 1; > + tlb->cleared_pmds = 1; > + tlb->cleared_puds = 1; > + tlb->cleared_p4ds = 1; > } > > tlb_flush_mmu(tlb); >