Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2765427pxb; Sun, 3 Oct 2021 05:14:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxetpi9FJBh1UWIgpfj49sfE34FQl4cjFNXkb+TUHyyxWLzRbm5WiskrtJSdlglwcGKWZze X-Received: by 2002:a17:902:7e88:b0:13e:91ec:4114 with SMTP id z8-20020a1709027e8800b0013e91ec4114mr9124428pla.30.1633263280887; Sun, 03 Oct 2021 05:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633263280; cv=none; d=google.com; s=arc-20160816; b=IyK+dg5t2yOsy9S0XAH7ifA2ZtZaFysXHaj6FXE42npmSrxpXTE+bSjUI36lyoFnj7 hWEnEfXwAF9Lqjd3ATNZj8LmRTBxZLrPX189A+xKmOphg2tXKi2Rp16JaWh8RDPpTOn9 fedCXYTvSQ66InGV6q0V5uWO0JnuIMKaUIqH9og2enrGhnd7T9iBCzCdFMNihea7zXSS Dxk9nkWDflYLQdOOwqbyCOqlczmrvkc8LB5RA3fqYGH1H4gEeYTKSL5VAu6gyfPd0eKz MVb5AuFaOFLhZa4CQuHSrqLm2sc6nSlgm+xtrVDv51KaZy4Sk4ZvnNY2XAALi+mB5rKu AUbQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/yJMhw3wPQSlyKaEi+lnBPfgzZ18ON2DTC2x75zIHa0=; b=PyjnL7S8KU2UCHWrcSe5v/760OkXE1mluVnsumz1m9JLeyNERqTATwNajhiT9XsOUq DokOayrREtSrr5tvdubP45lLxtnBU7jH6vL7wJzZB/1K05wYOicnNz4J6o031k5DVwkp hmzvN7QJFVwz8s+rZBdXj0veLkOCjh0CGX9dfIf6n5MWDZ+WoJQdABsu7O3rsQo78fJe +h5BrMqx7mo5kyJU6Jq/vw7e09+IYxGige/5cmR8na1tnTz0vOWvMXLAt3LpTC7nEfty /9JtIMwJgldl1mGfIFYjrU/YC0SguunAxlpxGoT1bESUuhET2+bO7fDOlxa7Vt5DxsLE J7Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Z/3qakIc"; 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 o11si20538101pgu.41.2021.10.03.05.14.27; Sun, 03 Oct 2021 05:14:40 -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="Z/3qakIc"; 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 S230195AbhJCMN5 (ORCPT + 99 others); Sun, 3 Oct 2021 08:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhJCMN5 (ORCPT ); Sun, 3 Oct 2021 08:13:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 021D2C0613EC for ; Sun, 3 Oct 2021 05:12:09 -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-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/yJMhw3wPQSlyKaEi+lnBPfgzZ18ON2DTC2x75zIHa0=; b=Z/3qakIcDJeLpgvVAHld4Swu0L 2ZRyHoY1CSgsQSiX2/o9b3Dhr37N2z0Fg+Bf6cIjz2JY/wy9rMpUNfgLs+XESSEyZeklyiqmnmfQ8 yVNXsce+LInTB002JXsZk8AtSl9l/VEYBYOcX6VxnPsHSlMOvr2Pknu00fnsPJqJxGezk9qIugd1G 6ZP5z2SnHBNTiKLn3ogL9BL3zq2ZL89aRqruXT06YPExcvdkutVzYJl8t7inCuQ1FF+HMzps69JYW lVwvJlMl0JwGxuoIMBWIsTOEe5wtGInNwYObBmkEtsXuoBi6hDR7fK+SvFCBAF/cI1ewgiWEETLFh 36LknG7A==; 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 1mX0Jw-00Ftb6-KR; Sun, 03 Oct 2021 12:10:42 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 1CC12981431; Sun, 3 Oct 2021 14:10:19 +0200 (CEST) Date: Sun, 3 Oct 2021 14:10:19 +0200 From: Peter Zijlstra To: Nadav Amit Cc: Andrew Morton , LKML , Linux-MM , Peter Xu , Nadav Amit , 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: <20211003121019.GF4323@worktop.programming.kicks-ass.net> References: <20210925205423.168858-1-namit@vmware.com> <20210925205423.168858-2-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210925205423.168858-2-namit@vmware.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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... > + 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. > + tlb_end_vma(&tlb, vma); > + tlb_finish_mmu(&tlb); > > return pages; > } > -- > 2.25.1 >