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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19ECAC433EF for ; Mon, 25 Oct 2021 16:42:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BDFFE60E8C for ; Mon, 25 Oct 2021 16:42:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BDFFE60E8C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 56CBB940008; Mon, 25 Oct 2021 12:42:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51D63940007; Mon, 25 Oct 2021 12:42:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40B98940008; Mon, 25 Oct 2021 12:42:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id 30471940007 for ; Mon, 25 Oct 2021 12:42:23 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DCF761812D462 for ; Mon, 25 Oct 2021 16:42:22 +0000 (UTC) X-FDA: 78735527724.34.946206E Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf13.hostedemail.com (Postfix) with ESMTP id 45B83104781A for ; Mon, 25 Oct 2021 16:42:17 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id n11so8336714plf.4 for ; Mon, 25 Oct 2021 09:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=iPzF+A6NoX41v6pK//WT1W0ZPIsuHXZBTwEsrnM3MlU=; b=Y0U1eOkDCwJTXM/GrxZTHoIbmclC0xAZSkUyKSyso9O6uaeaS3PJGkFnxElICX0Gdo 2yOeu9tljUkdEJcFxPTvr8bTQ6+ryd4xgJIOwlXToiggRyY5oq6iKAOUeekLrURu9bUJ MRMajRCZ4IRQfB5zoD4du6b6+vAXrXCKG1ToPicPuE7b+ajoGSmTAIuzgJMN1mOV7ACu BE08vrDRBl1avmEreQ/hdCD3gxLBT2tiomgsxuSFIUKkBSiK5BpWDZQS9CW7NCyYSLou yV4X6GNrcowp0a3uHuG60rHZ9IX3T58HZ/D9XOW2eMJ9MPMFJ56Kz01wwydfSIO0Q8S3 yxqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=iPzF+A6NoX41v6pK//WT1W0ZPIsuHXZBTwEsrnM3MlU=; b=UBWPwXP9wRdvSHBNph5Z81xLvY906UDq4q/HW4asX5eepU8vSLn4HJsBGESVerSlki 8HSwTaDSZ9qDGRqu3NJ+j90MazBXJcaWenUFrwXY6W5isvVFx7YTmeaA0N5YY9pP+drC GAwkwYg7XumwgNchsH+36mVKZvGjVnaFqmZe/BOgOQgjJfkIY8NgQWIU0pnG2TxTsVku HphlA/BhA+eVmjoK+cZDBk73eQp74v07NlX8bJx5M5dS4Jbjy5LbfFkWeOt3d41Btvxz lI+QtwANDWvC8h58zyi/XUEwrpNO65IE91B6aacQ/ppRHhkhisQr6HyqFQkUZRz0wquu KC3A== X-Gm-Message-State: AOAM533gy4mtC/FHnjiY71/fhOp4XalsEHTWWnyrZ4WxjrEBnt4f7N5z CPQUcXJPNCDxaPsjfq0hlQA= X-Google-Smtp-Source: ABdhPJxdkVpu75I/cabI5BY3n/50hbKO50PUzlcUHyjrTmm+sOEQpFzsrVOBlOrcnGs69Bfe0tfkGA== X-Received: by 2002:a17:90b:17c9:: with SMTP id me9mr22110765pjb.197.1635180141420; Mon, 25 Oct 2021 09:42:21 -0700 (PDT) Received: from smtpclient.apple (c-24-6-216-183.hsd1.ca.comcast.net. [24.6.216.183]) by smtp.gmail.com with ESMTPSA id b6sm22238132pfv.171.2021.10.25.09.42.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Oct 2021 09:42:20 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [PATCH v2 0/5] mm/mprotect: avoid unnecessary TLB flushes From: Nadav Amit In-Reply-To: Date: Mon, 25 Oct 2021 09:42:19 -0700 Cc: Andrew Morton , Linux-MM , LKML , Andi Kleen , Andrea Arcangeli , Andrew Cooper , Andy Lutomirski , Dave Hansen , Peter Xu , Thomas Gleixner , Will Deacon , Yu Zhao , Nick Piggin , x86@kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20211021122112.592634-1-namit@vmware.com> <20211021200450.b13499c379a27dbfefe9f5e3@linux-foundation.org> To: Peter Zijlstra X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Stat-Signature: ujinspn5crsbb9x7sdpszydy7czqag5b Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Y0U1eOkD; spf=pass (imf13.hostedemail.com: domain of nadav.amit@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=nadav.amit@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 45B83104781A X-HE-Tag: 1635180137-206977 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: > On Oct 25, 2021, at 3:50 AM, Peter Zijlstra = wrote: >=20 > On Thu, Oct 21, 2021 at 08:04:50PM -0700, Andrew Morton wrote: >> On Thu, 21 Oct 2021 05:21:07 -0700 Nadav Amit = wrote: >>=20 >>> This patch-set is intended to remove unnecessary TLB flushes. It is >>> based on feedback from v1 and several bugs I found in v1 myself. >>>=20 >>> Basically, there are 3 optimizations in this patch-set: >>> 1. Avoiding TLB flushes on change_huge_pmd() that are only needed to >>> prevent the A/D bits from changing. >>> 2. Use TLB batching infrastructure to batch flushes across VMAs and >>> do better/fewer flushes. >>> 3. Avoid TLB flushes on permission demotion. >>>=20 >>> Andrea asked for the aforementioned (2) to come after (3), but this >>> is not simple (specifically since change_prot_numa() needs the = number >>> of pages affected). >>=20 >> [1/5] appears to be a significant fix which should probably be >> backported into -stable kernels. If you agree with this then I = suggest >> it be prepared as a standalone patch, separate from the other four >> patches. With a cc:stable. >=20 > I am confused, 1/5 doesn't actually do *anything*. I also cannot find > any further usage of the introduced X86_BUG_PTE_LEAK. >=20 > I'm thinking patch #2 means to have something like: >=20 > if (cpu_feature_enabled(X86_BUG_PTE_LEAK)) > flush_pmd_tlb_range(vma, address, address + = HPAGE_PMD_SIZE); >=20 > In the newly minted: pmdp_invalidate_ad(), but alas, nothing there. This change was only intended for pmdp_invalidate_ad() but somehow got lost. I will add it there. I eventually did not add the optimization to avoid TLB flushes on (!dirty|write)->!write so I did not use it for the first case that you mentioned. I am too afraid, although I think this is correct. Perhaps I will add it as a separate patch.