Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4318464pxb; Mon, 4 Oct 2021 23:57:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5SXIP0Qo13bIuYcov8gmW2cOYZnn85FPmhcwpWbkdWQvG6fL8gmsCzSo6LlqTcQwVoVMh X-Received: by 2002:a05:6402:42d4:: with SMTP id i20mr24046686edc.348.1633417034123; Mon, 04 Oct 2021 23:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633417034; cv=none; d=google.com; s=arc-20160816; b=lLEjvjAfwEoRbtr8rQv5o9Ht1Vqlgcrl7DmOrzDHV3i318atLcXoTv3PHnxDDxgQKS GBf9RvgDgy4JYUdhLDl5jrIPncf9NeqN09a5CnIx8I5mO1SrMln60osoC3zVeFAjK5Nl 2xuzRZ7RPmJjCgkn8rFwi6bgpCwtnN7EfosJnagVL2a6ry+bSN94zCLMqOlm0Uzw5IKe E3wkAwgdx/gYbkfN4wVGv2AnGoZO9Xrpib9nSEDpNeuFOESNR/EQC0y8VzTaFJ4kYTHQ 60zJUnUkbWc2WeU+VAFp2qwmgJJobDvWHNOVQapTUWR4ZbzoMnjZSmzt7MWXVd+u1css DyPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Qr22602shIdzzG2+Obu3zaMUVwn4jZ1NQIj+6vzc1lo=; b=F4LBqKXwOBSg7rwSK3/Tl+xnkY99J1jeZ1CaeoBv3Y/7ELbeh1It0F3C6y85M2R54p PvMikt7vfjcoSmpR82o8gZwR6/zLEapl9+pH/VdMkEVC5gA55IlSk/D/xB9+06/FHQPr 9g17dV1hZXfE6TwJ2Myg9fyEAi8W+UJ7WRENF6s1DNEpa8Wd7+af1YbpcgXnDdRHdWSP LMEItxLiuOmHIuHXLsKDRJxc/sial4kS8fUIibqWPZPCy1eF63EsOYSD7bXI9tsasp1X +oOzG0KuroZmxuPUSQ/U1W7HorJHtA779p2+0eg4ttroiOcqEN2p0ARBKjYFX6vb0bhg qFdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=P4J3v3j7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo9si21290193ejb.690.2021.10.04.23.56.50; Mon, 04 Oct 2021 23:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=P4J3v3j7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbhJEG4r (ORCPT + 99 others); Tue, 5 Oct 2021 02:56:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231816AbhJEG4p (ORCPT ); Tue, 5 Oct 2021 02:56:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99637C061745 for ; Mon, 4 Oct 2021 23:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=Qr22602shIdzzG2+Obu3zaMUVwn4jZ1NQIj+6vzc1lo=; b=P4J3v3j7xLp7hyJWqzhO0yGpj8 Xjzn5UPhR+dBYwUCMfMEpEY6kBEZfZIf7h9GQU6M5KlPR4T3E9t4zWarsuxneRlYJ2WAnE9934EZa 4AME/jedTwabAuyHP8YltPfLh7l6Qjb/cLFH1TNgqIgP7p31I4jnYJVNs50AQXgRkyaasqpWcb/oq 493+ts8zxHuPj3/qjhZRsjUqrKKiupnBEv5Zw6IeKIcTNEMksRcmpYAEpuiqJw7zSueaE0dI4AGge UihAu33VdZ47vO4EhFDIY7i7rGi2o7FhFz13HZSdQ6nXlrpdS1nMWGTOFQeECFxmNE5BuxKWtBV6r i6QUTB4Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXeKW-0004jQ-1X; Tue, 05 Oct 2021 06:53:40 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id DE3739811EE; Tue, 5 Oct 2021 08:53:35 +0200 (CEST) Date: Tue, 5 Oct 2021 08:53:35 +0200 From: Peter Zijlstra To: Nadav Amit Cc: Andrew Morton , LKML , Linux-MM , Peter Xu , Andrea Arcangeli , Andrew Cooper , Andy Lutomirski , Dave Hansen , Thomas Gleixner , Will Deacon , Yu Zhao , Nick Piggin , x86@kernel.org Subject: Re: [PATCH 1/2] mm/mprotect: use mmu_gather Message-ID: <20211005065335.GG4323@worktop.programming.kicks-ass.net> References: <20210925205423.168858-1-namit@vmware.com> <20210925205423.168858-2-namit@vmware.com> <20211003121019.GF4323@worktop.programming.kicks-ass.net> <620B1A38-1457-4F77-8666-E73A318392B6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <620B1A38-1457-4F77-8666-E73A318392B6@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 04, 2021 at 12:24:14PM -0700, Nadav Amit wrote: > > > > On Oct 3, 2021, at 5:10 AM, Peter Zijlstra wrote: > > > > On Sat, Sep 25, 2021 at 01:54:22PM -0700, Nadav Amit wrote: > > > >> @@ -338,25 +344,25 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, > >> struct mm_struct *mm = vma->vm_mm; > >> pgd_t *pgd; > >> unsigned long next; > >> - unsigned long start = addr; > >> unsigned long pages = 0; > >> + struct mmu_gather tlb; > >> > >> BUG_ON(addr >= end); > >> pgd = pgd_offset(mm, addr); > >> flush_cache_range(vma, addr, end); > >> inc_tlb_flush_pending(mm); > > > > That seems unbalanced... > > Bad rebase. Thanks for catching it! > > > > >> + tlb_gather_mmu(&tlb, mm); > >> + tlb_start_vma(&tlb, vma); > >> do { > >> next = pgd_addr_end(addr, end); > >> if (pgd_none_or_clear_bad(pgd)) > >> continue; > >> - pages += change_p4d_range(vma, pgd, addr, next, newprot, > >> + pages += change_p4d_range(&tlb, vma, pgd, addr, next, newprot, > >> cp_flags); > >> } while (pgd++, addr = next, addr != end); > >> > >> - /* Only flush the TLB if we actually modified any entries: */ > >> - if (pages) > >> - flush_tlb_range(vma, start, end); > >> - dec_tlb_flush_pending(mm); > > > > ... seeing you do remove the extra decrement. > > Is it really needed? We do not put this comment elsewhere for > tlb_finish_mmu(). But no problem, I’ll keep it. -ENOPARSE, did you read decrement as comment? In any case, I don't particularly care about the comment, and tlb_*_mmu() imply the inc/dec thingies. All I tried to do is point out that removing the dec but leaving the inc is somewhat inconsistent :-)