Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp418059ybz; Wed, 15 Apr 2020 11:12:11 -0700 (PDT) X-Google-Smtp-Source: APiQypJhJx1ayh0BADn4q7v/iYRhq1kfcqD54ibQbG/lu1BK0CnwBbdY3jHiq4FUKPJGSvP5dUK5 X-Received: by 2002:a50:f61b:: with SMTP id c27mr10275493edn.256.1586974331695; Wed, 15 Apr 2020 11:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586974331; cv=none; d=google.com; s=arc-20160816; b=uwp+tNz0TjPTMTl6O2sCM4gOMJp4Jy+p+QvWDbsbPkkRFci78By1flTbRKdQXl3MIQ VJleiKuJXJLxwHA5NvS0hWnYfyTmIytLoNRF96291zCbAFFPS1D2F2EG8YQ8c6YYm0JV zb6qZz/7/qlIqdTLApNzC3DjfwUPJuN9xWNs1PKh6hoi7X5Dgb2Sav6g1NxAakAGPcft 6kfn1iJ9AzoNHMbODzboamOkNUe0stNIaOZqbZEVrMeY2cCUrbECmjj4gNx7qFNAlXF1 dIb5E4f5u71mYS+RFRxl7wpRrsrColl7Emtz9bjwCpTvBdsyqpGqMn/HUMGCf41acwS4 FS+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:autocrypt :from:references:cc:to:subject; bh=FnTDsWS0V/vkeLXW1TJz/CGP15fy5qWzgLB4iKq2wL0=; b=XKgSssadXD2ucoB4gQXjdv56IMF2yI2vGMlfV3stCT4YD2V5CLUUD0roK591gXvS6G kUfyjtEzFQUjW2D2A37m69aVft9KLzxdQ888fcD5NZ38/jqMf8sp0j+GzOaN+ZE8BK06 +b0MoaEPm4urOcB4TpfjzjO3OK7jvgII4iVkDuWf/exBi/hRing/ihG4Ot+YJghAXmvp 28HuIPAVNQ2QPw/z1khvGbcE/+i3SNQlKbIpJfZqQqHRNZS+pideiZMk47+ZOvFNMy2N +VuMUlqq322YTw7qDPPnrnLlGem2H2T1VlPI5K7geS25/pFtsbaN3DWpBVFyY+/T+TPz 755Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c22si10568291eja.230.2020.04.15.11.11.46; Wed, 15 Apr 2020 11:12:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406412AbgDNHGN (ORCPT + 99 others); Tue, 14 Apr 2020 03:06:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40576 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729537AbgDNHGI (ORCPT ); Tue, 14 Apr 2020 03:06:08 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03E74soA026452 for ; Tue, 14 Apr 2020 03:06:06 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 30d4kuwgdn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 14 Apr 2020 03:06:05 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Apr 2020 08:05:59 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 14 Apr 2020 08:05:54 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03E75vC858720506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 07:05:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A288311C04A; Tue, 14 Apr 2020 07:05:57 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE11211C054; Tue, 14 Apr 2020 07:05:56 +0000 (GMT) Received: from oc7455500831.ibm.com (unknown [9.145.80.86]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 14 Apr 2020 07:05:56 +0000 (GMT) Subject: Re: [RFC][Qusetion] the value of cleared_(ptes|pmds|puds|p4ds) in struct mmu_gather To: Peter Zijlstra , Zhenyu Ye , Gerald Schaefer 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 References: <20200330121654.GL20696@hirez.programming.kicks-ass.net> From: Christian Borntraeger Autocrypt: addr=borntraeger@de.ibm.com; prefer-encrypt=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azd9uGzVMTz6lFjVtH7YkeW/NZrP6znAwv5P1a DdQfiB5F63AX++NlTiyA+GD/ggfRl68LheSskOcxDwgI5TqmaKtX1/8RkrLpnzO3evzkfJb1 D5qh3wM1t7PZ+JWTluSX8W25ABEBAAHCwV8EGAECAAkFAk6cPPgCGwwACgkQEXu8gLWmHHz8 2w//VjRlX+tKF3szc0lQi4X0t+pf88uIsvR/a1GRZpppQbn1jgE44hgF559K6/yYemcvTR7r 6Xt7cjWGS4wfaR0+pkWV+2dbw8Xi4DI07/fN00NoVEpYUUnOnupBgychtVpxkGqsplJZQpng v6fauZtyEcUK3dLJH3TdVQDLbUcL4qZpzHbsuUnTWsmNmG4Vi0NsEt1xyd/Wuw+0kM/oFEH1 4BN6X9xZcG8GYUbVUd8+bmio8ao8m0tzo4pseDZFo4ncDmlFWU6hHnAVfkAs4tqA6/fl7RLN JuWBiOL/mP5B6HDQT9JsnaRdzqF73FnU2+WrZPjinHPLeE74istVgjbowvsgUqtzjPIG5pOj cAsKoR0M1womzJVRfYauWhYiW/KeECklci4TPBDNx7YhahSUlexfoftltJA8swRshNA/M90/ i9zDo9ySSZHwsGxG06ZOH5/MzG6HpLja7g8NTgA0TD5YaFm/oOnsQVsf2DeAGPS2xNirmknD jaqYefx7yQ7FJXXETd2uVURiDeNEFhVZWb5CiBJM5c6qQMhmkS4VyT7/+raaEGgkEKEgHOWf ZDP8BHfXtszHqI3Fo1F4IKFo/AP8GOFFxMRgbvlAs8z/+rEEaQYjxYJqj08raw6P4LFBqozr nS4h0HDFPrrp1C2EMVYIQrMokWvlFZbCpsdYbBI= Date: Tue, 14 Apr 2020 09:05:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200330121654.GL20696@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20041407-0028-0000-0000-000003F7EAAB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20041407-0029-0000-0000-000024BD9629 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-14_02:2020-04-13,2020-04-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=2 mlxscore=0 phishscore=0 spamscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=855 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140052 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gerald, can you have a look? On 30.03.20 14:16, Peter Zijlstra wrote: > 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? >