From patchwork Sun Jan 31 00:11:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 12057441 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 3D0E7C433DB for ; Sun, 31 Jan 2021 00:16:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD4E764E15 for ; Sun, 31 Jan 2021 00:16:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD4E764E15 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 47B216B0006; Sat, 30 Jan 2021 19:16:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 404206B006C; Sat, 30 Jan 2021 19:16:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 259896B006E; Sat, 30 Jan 2021 19:16:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id 079826B0006 for ; Sat, 30 Jan 2021 19:16:04 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C115F180AD82F for ; Sun, 31 Jan 2021 00:16:03 +0000 (UTC) X-FDA: 77764152606.03.8F0E9FB Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf01.hostedemail.com (Postfix) with ESMTP id 8BE1520001F2 for ; Sun, 31 Jan 2021 00:16:02 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id b145so2281406pfb.4 for ; Sat, 30 Jan 2021 16:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l25hYkMVDoyooYvVfTs7fc3Z+gKHwtM6S7f1RS+25jI=; b=QWgShbAGwg3wKINOtZylfbSTrKZ7qLVxJ9N5IFviem4ZQZbvt3Qb5FGnEFjaJkKWM8 +N59D/2HoNthkC9KM8y5rri2hSwYvZ3PGjWAtGVOTbVKPODJHb+bNvA2CTILAtcpT2eF h2vKj7f18D9utR+WqRIZocdX9KGJMGNpGDq4OAUv3clGITiSokZvfotFKb0au2qJk83H +vQ3E86+C/gXHYcrJ616SNR0zQDCLX573HjZiqIKyq8Skylj6hd55xtbGDdaDulme6bC qkMuGVJdrJXN1VfTQjQkLNTiMdo9yVwgsqXAzyKwt97zZNMt7qYeioV6GYWPf1kFGeIf 5v9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l25hYkMVDoyooYvVfTs7fc3Z+gKHwtM6S7f1RS+25jI=; b=Dy9UeiHRPwB75M8ufqQLxhQ/o6+LEK+YnuEtne5GR5cb8VEACMKCure/JB4P6ss5Yp 7S1lc27jIHIXBPLYECEkTtsWcBy8JqYr2Ku7ecnLQQQdHk3IePrRzejBYYIW+EyNUbOs dPYvR3ALr3xZx/gHEl/jef8EI/yP5L1kdEl1BWCmVLUJeOZ3t7MzEnXj1X1MZ2458XoK 66Es9i+IjildnTSKo+jNV+HcOz1rc/zcrRF07qDiIBuZavZOr09eyg1P8zKDSy5Z2S7A ZolYGre57plWI3SHNWDW9bzxS9xpWnhoi7Q1IBUhv7T1Pg1R64ybxfX6YzjzwvX1l5hy unOg== X-Gm-Message-State: AOAM532okBUA2nJvlkGQ8LbbEEdtzbj8T67Wuyq5cOa6TathktCYonvc mJHOdd2A/1H37ZG191KjzbUGYiSWb7s= X-Google-Smtp-Source: ABdhPJyd6V4GPxAmmHG/IDX8wnqgvmExjPww3NvYNxqdzTjwzAadbhjaaR3aAin7oAYPZWEG51FDXg== X-Received: by 2002:a63:c148:: with SMTP id p8mr10395437pgi.188.1612052161728; Sat, 30 Jan 2021 16:16:01 -0800 (PST) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id e12sm13127365pga.13.2021.01.30.16.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jan 2021 16:16:01 -0800 (PST) From: Nadav Amit X-Google-Original-From: Nadav Amit To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Nadav Amit , Andrea Arcangeli , Andrew Morton , Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Gleixner , Will Deacon , Yu Zhao , Nick Piggin , x86@kernel.org Subject: [RFC 01/20] mm/tlb: fix fullmm semantics Date: Sat, 30 Jan 2021 16:11:13 -0800 Message-Id: <20210131001132.3368247-2-namit@vmware.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210131001132.3368247-1-namit@vmware.com> References: <20210131001132.3368247-1-namit@vmware.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8BE1520001F2 X-Stat-Signature: c31fnuoihpkjho4tikd55bcwchh1jkm6 Received-SPF: none (<>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from="<>"; helo=mail-pf1-f173.google.com; client-ip=209.85.210.173 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612052162-31373 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: From: Nadav Amit fullmm in mmu_gather is supposed to indicate that the mm is torn-down (e.g., on process exit) and can therefore allow certain optimizations. However, tlb_finish_mmu() sets fullmm, when in fact it want to say that the TLB should be fully flushed. Change tlb_finish_mmu() to set need_flush_all and check this flag in tlb_flush_mmu_tlbonly() when deciding whether a flush is needed. Signed-off-by: Nadav Amit Cc: Andrea Arcangeli Cc: Andrew Morton Cc: Andy Lutomirski Cc: Dave Hansen Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Cc: Yu Zhao Cc: Nick Piggin Cc: x86@kernel.org --- include/asm-generic/tlb.h | 2 +- mm/mmu_gather.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 2c68a545ffa7..eea113323468 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -420,7 +420,7 @@ static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) * these bits. */ if (!(tlb->freed_tables || tlb->cleared_ptes || tlb->cleared_pmds || - tlb->cleared_puds || tlb->cleared_p4ds)) + tlb->cleared_puds || tlb->cleared_p4ds || tlb->need_flush_all)) return; tlb_flush(tlb); diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c index 0dc7149b0c61..5a659d4e59eb 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -323,7 +323,7 @@ void tlb_finish_mmu(struct mmu_gather *tlb) * On x86 non-fullmm doesn't yield significant difference * against fullmm. */ - tlb->fullmm = 1; + tlb->need_flush_all = 1; __tlb_reset_range(tlb); tlb->freed_tables = 1; }