Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2390398ybb; Mon, 30 Mar 2020 05:20:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsL1FcTWSdRS8yvC8Cdwoe53hQ/LBKi2KU19XoDxXlNGN5M14SosENGPXvlFoyBeNsowJU9 X-Received: by 2002:a05:6830:1aee:: with SMTP id c14mr8493491otd.141.1585570835403; Mon, 30 Mar 2020 05:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585570835; cv=none; d=google.com; s=arc-20160816; b=iKzRLwabi+wM6bxPB1mlQa9TmTUZv0xw4z1Fe5upEZrXskM5xtYjNnP+E+XG8ReD1X NtT5mxJybtLO2PS09028/wuBGmo1kbYB8DsyVX8lxQHOcMdq6YCV2WD3fCBQBfiObqqJ S/NG3goL2b/81ab9UIIMyrY+CKH5u/2eLOtY2XZqsl7WSWOGem8sYTGq0dtV5r7qQW1W tuIuP2p+kgrRi6AoBZs9X+z3OnujJmklVoSdWw0W6rLsjyHTA892KhRthjoF7DX/z0Ik JCNqj8laKveJJGZw5sW55n/uxHNBa6pTAtb0ab1i0OjearvKOrA9U01UBnWpX/fLyP5U 1ddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=1TmVSV9PEicpV15saljgYzRTqRrIyUodG1iYOZDlCEw=; b=dJ0vQUDV8TIRJwgXcxNxGGyHFIyTVTqqZkLAtfiHuHbqaH5BIu48PZKZoopMzgUGT+ eIMZ0o0+3wijumrvvXqEIFK3L6EOn7RrA+huPCMgcDs09ZGRkTsqHOYyfCG/tSQCu2S3 G6/B95949TEjOLqDSt0Ir2P0r3u7YdjN6eBILS7GSgv/Li6Y4HqsQTdRI8uuJcxvsZod kuboKGfV38NecXLnsZ/CFrGTddUsm6W+A+kh5RQu9sR4lAFgBLSGSVDmwxlHCf9aQZH5 TGVEO8hPJK5Sk231VQy3iVL7ZtShzk7zOGyr0qBX/KZ/JqGwkNYYjyORdqJYRBwRYoSJ W/aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jug3rhOD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si6327267ood.66.2020.03.30.05.20.22; Mon, 30 Mar 2020 05:20:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jug3rhOD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730130AbgC3MRN (ORCPT + 99 others); Mon, 30 Mar 2020 08:17:13 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51342 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729705AbgC3MRM (ORCPT ); Mon, 30 Mar 2020 08:17:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=1TmVSV9PEicpV15saljgYzRTqRrIyUodG1iYOZDlCEw=; b=jug3rhODTJBTFOCabmEpKv3Ciy OQM9n6+JLCgJaVH13pLjAddV5iCyN6VkzJewzO5/zEWXS0jthSH5yZe4C+fBjXhYKc8qcHxnPjBJ2 3k0FhnMmnjUl6Z8PZwD0cHVa8+QzePq02+E7Qr1bv4keJir+bSI1/esyOwt5AYFDjDetGBu2r2CHQ 8ZDHvI7evDFQxiGZK2RtBJ6wCGAZsIN5cGaqdjOtB85vmkkhbKSeK2gMBqRRNxfr1+aFDoj104nQq QuwEtQdU3Cqt+u9I7HuSEBBq2KVdHmPuVh1ef2y2D7+8la/4B4ZcASgg37TwV3AIfzXRHcYGJfC6B abEyRCXA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jItLd-0004XC-Ka; Mon, 30 Mar 2020 12:16:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id EAFAE303C41; Mon, 30 Mar 2020 14:16:54 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CDA5F29D04D6E; Mon, 30 Mar 2020 14:16:54 +0200 (CEST) Date: Mon, 30 Mar 2020 14:16:54 +0200 From: Peter Zijlstra To: Zhenyu Ye Cc: npiggin@gmail.com, will.deacon@arm.com, mingo@kernel.org, torvalds@linux-foundation.org, schwidefsky@de.ibm.com, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, Marc Zyngier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, arm@kernel.org, xiexiangyou@huawei.com Subject: Re: [RFC][Qusetion] the value of cleared_(ptes|pmds|puds|p4ds) in struct mmu_gather Message-ID: <20200330121654.GL20696@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 28, 2020 at 12:30:50PM +0800, Zhenyu Ye wrote: > Hi all, > > commit a6d60245 "Track which levels of the page tables have been cleared" > added cleared_(ptes|pmds|puds|p4ds) in struct mmu_gather, and the values > of them are set in some places. For example: > > In include/asm-generic/tlb.h, pte_free_tlb() set the tlb->cleared_pmds: > ---8<--- > #ifndef pte_free_tlb > #define pte_free_tlb(tlb, ptep, address) \ > do { \ > __tlb_adjust_range(tlb, address, PAGE_SIZE); \ > tlb->freed_tables = 1; \ > tlb->cleared_pmds = 1; \ > __pte_free_tlb(tlb, ptep, address); \ > } while (0) > #endif > ---8<--- > > > However, in arch/s390/include/asm/tlb.h, pte_free_tlb() set the tlb->cleared_ptes: > ---8<--- > static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, > unsigned long address) > { > __tlb_adjust_range(tlb, address, PAGE_SIZE); > tlb->mm->context.flush_mm = 1; > tlb->freed_tables = 1; > tlb->cleared_ptes = 1; > /* > * page_table_free_rcu takes care of the allocation bit masks > * of the 2K table fragments in the 4K page table page, > * then calls tlb_remove_table. > */ > page_table_free_rcu(tlb, (unsigned long *) pte, address); > } > ---8<--- > > > In my view, the cleared_(ptes|pmds|puds) and (pte|pmd|pud)_free_tlb > correspond one-to-one. So we should set cleared_ptes in pte_free_tlb(), > then use it when needed. So pte_free_tlb() clears a table of PTE entries, or a PMD level entity, also see free_pte_range(). So the generic code makes sense to me. The PTE level invalidations will have happened on tlb_remove_tlb_entry(). > I'm very confused about this. Which is wrong? Or is there something > I understand wrong? I agree the s390 case is puzzling, Martin does s390 need a PTE level invalidate for removing a PTE table or was this a mistake?