From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EF2B3FD1 for ; Thu, 19 Dec 2024 02:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734574592; cv=none; b=qi8LkK2h3B5ctMa9SCNHdG555OcRP09F2SzJVEwLg1hm8EnjAzWZOGVqwSRE/v+Of9BkR2OFe0F87nnawJQdUPGXsN9oGsWCK1QfBPB9tuqkGzavVVQA7eQBvoSFF9KYNmbk+B8J6/5k12D99v5FjWC/Vxuge5gxFEbtuCIYwds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734574592; c=relaxed/simple; bh=aaUfN7bfWoQ+x6wd7BNlZdsKQr4ApY+udju/pQBjV/I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=I62fu2pZikyI3bz5jVxcP26S4PR2M+jrp6f1dCe4kU7vt3Tc6OkbdRQc0qqcFWMoAtkWwWB8DkraKE9BvelRrkT9D9T3H8OxKrgr2q47Rsw5QtVeLQ+fIXM8OhO0v8qEkQMaR5phN3H0kdX9/hiSUSJHu8O+7OhhOwLXz0+CuY8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=S3wu+8vw; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="S3wu+8vw" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-7242f559a9fso406378b3a.1 for ; Wed, 18 Dec 2024 18:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734574590; x=1735179390; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TPHcpjogGQj9DePuy7spX/y295la8GYaw9su0y/02+A=; b=S3wu+8vw42rgFvg+G6mDUsPZlCI3G9QMcQWqClIgQNP6lj7GQ5LOheJFAzwnP0qbpQ gYHxq3bq/d84vtVZ7vL3FnNzRQJI6CFPq8YhynG+43mNIZNcQT5ab/WnrQTYDWkomlJC j15QRBYLWNj+iMot3uMCcaRJuc93jSF06qK/0PVrf01nwEkgEHb61KTPlys1CUVcOI4D eYe5nlQ8KmXvraLjLFzjOkxtFBClzDUJUbAe6nb5b/ce5cVGB7HKRaKrcF3U2JOwSfxK XhOvLQHuVjHnf+F41fmyTFRIdQDrZ9lkznSDqYWwtlw9SM8u2rt/ifpVyeB6lVtETS1m boFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734574590; x=1735179390; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TPHcpjogGQj9DePuy7spX/y295la8GYaw9su0y/02+A=; b=KIB6ZC7MXczMP50lWkJSSQWIqvzueZt71/1utg2Rm24lLthxB6AelVUD3T2gbhzzP7 sOtSVn27YnoLi/IgyNQVa+v9a4kD6ITm8y1BTluwmJtcOo/dX3MqNFy2sCwK8fUTxhz4 h6nQhoSZDNcdJt0maXuuT8Pg3RKXnxJUQDqsLTMvdyaomUQwp1pOHp89/zzZzWj3FMDU muJH2Wj7mJMyo0MyCmQ2V6WWf9vRTJEZuBPVt7zv6dPaTgg/xzxJprFnFl532J7uvpU4 bt+avq9ZsPM7gJt/6IKTmSyXcMtM6lRjCZ9prmBquyWQDya+L2z7OuAiN+3q4YC5Tu3l rJAg== X-Forwarded-Encrypted: i=1; AJvYcCXAShAYXhNAFVBAQhIuYHW/tGskURNL2lldr+JMjAJzflo7XkeaH47DbZTtgzw4XdryzYfZraKkRQqeKU8=@vger.kernel.org X-Gm-Message-State: AOJu0YxAzKtAEqR4SgPUp9ESd7xU1pnAC/UnkjGv7J0GPdHyDp7zaA9c mcNBxzy4cQYyzZuLnlkdpe/ib9pGFjOBFuOc6f43y5qyxH/fq7JOnM5PkN7Lci4= X-Gm-Gg: ASbGncugv2L0G6oMTIPdYoyZz6XZbWq2sOiv7WRnsxj4U3iA1edbNQORszZnAvrE+PO kJ/clNymi5J8tkfT0puHBxRWPWDXYFfpajNI54oIg6N2Ekikvz7lWAlN0rmdV5NEitafpND9tDd vLgBITI9ExF0jKvx2I7hj8gp5+kqzbbOAu1yZckN8jWEMpnWIEEo60VvUwmVCNTEVAihYwWZpds dM1Thre2qhathN7XLwqA4TaNEX0JGNo0YBO61gKIWv/sc3xO2aUC8XSupa3jjMH27YTAJ7XlxAp cPGdQQ== X-Google-Smtp-Source: AGHT+IFLYrk32OU9BOJtO6zl5+zT0AdHTY2cVdyB6k7rUp54q9vmbXzu/VTil7IQTKGZsZRW61fYyQ== X-Received: by 2002:a05:6a00:2356:b0:728:e1e3:3d88 with SMTP id d2e1a72fcca58-72a8d227287mr7273859b3a.7.1734574589752; Wed, 18 Dec 2024 18:16:29 -0800 (PST) Received: from [10.4.194.102] ([139.177.225.238]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm161520b3a.45.2024.12.18.18.16.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Dec 2024 18:16:29 -0800 (PST) Message-ID: <3f9a5475-930d-4f45-8fc8-8d2e8a6a08cc@bytedance.com> Date: Thu, 19 Dec 2024 10:16:22 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 14/15] mm: pgtable: remove tlb_remove_ptdesc() Content-Language: en-US To: Peter Zijlstra Cc: tglx@linutronix.de, david@redhat.com, jannh@google.com, hughd@google.com, yuzhao@google.com, willy@infradead.org, muchun.song@linux.dev, vbabka@kernel.org, lorenzo.stoakes@oracle.com, akpm@linux-foundation.org, rientjes@google.com, vishal.moola@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <79b20df78eb81a9cd07e3048f2d4d63d98759b4a.1734526570.git.zhengqi.arch@bytedance.com> <20241218164520.GK2354@noisy.programming.kicks-ass.net> From: Qi Zheng In-Reply-To: <20241218164520.GK2354@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/12/19 00:45, Peter Zijlstra wrote: > On Wed, Dec 18, 2024 at 09:04:50PM +0800, Qi Zheng wrote: >> diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h >> index 7052780740349..fba11949dd2ea 100644 >> --- a/arch/s390/include/asm/tlb.h >> +++ b/arch/s390/include/asm/tlb.h >> @@ -86,7 +86,7 @@ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, >> tlb->cleared_pmds = 1; >> if (mm_alloc_pgste(tlb->mm)) >> gmap_unlink(tlb->mm, (unsigned long *)pte, address); >> - tlb_remove_ptdesc(tlb, pte); >> + tlb_remove_table(tlb, pte); >> } >> >> /* >> @@ -105,7 +105,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, >> tlb->mm->context.flush_mm = 1; >> tlb->freed_tables = 1; >> tlb->cleared_puds = 1; >> - tlb_remove_ptdesc(tlb, pmd); >> + tlb_remove_table(tlb, pmd); >> } >> >> /* >> @@ -123,7 +123,7 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, >> tlb->mm->context.flush_mm = 1; >> tlb->freed_tables = 1; >> tlb->cleared_p4ds = 1; >> - tlb_remove_ptdesc(tlb, pud); >> + tlb_remove_table(tlb, pud); >> } >> >> /* >> @@ -141,7 +141,7 @@ static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, >> __tlb_adjust_range(tlb, address, PAGE_SIZE); >> tlb->mm->context.flush_mm = 1; >> tlb->freed_tables = 1; >> - tlb_remove_ptdesc(tlb, p4d); >> + tlb_remove_table(tlb, p4d); >> } >> >> #endif /* _S390_TLB_H */ > > AFAICT these are all virtual addresses (still) Oops, I forgot to fix [PATCH v2 11/15]. It should be fixed like below: diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h index 7052780740349..da4a7d175f69c 100644 --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h @@ -86,7 +86,7 @@ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, tlb->cleared_pmds = 1; if (mm_alloc_pgste(tlb->mm)) gmap_unlink(tlb->mm, (unsigned long *)pte, address); - tlb_remove_ptdesc(tlb, pte); + tlb_remove_ptdesc(tlb, virt_to_ptdesc(pte)); } /* @@ -105,7 +105,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; tlb->cleared_puds = 1; - tlb_remove_ptdesc(tlb, pmd); + tlb_remove_ptdesc(tlb, virt_to_ptdesc(pmd)); } /* @@ -123,7 +123,7 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; tlb->cleared_p4ds = 1; - tlb_remove_ptdesc(tlb, pud); + tlb_remove_ptdesc(tlb, virt_to_ptdesc(pud)); } /* @@ -141,7 +141,7 @@ static inline void p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, __tlb_adjust_range(tlb, address, PAGE_SIZE); tlb->mm->context.flush_mm = 1; tlb->freed_tables = 1; - tlb_remove_ptdesc(tlb, p4d); + tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d)); } #endif /* _S390_TLB_H */ Then in [PATCH v2 14/15], just convert virt_to_ptdesc() to virt_to_page(). Will fix it in v3. Thanks! > > >> diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h >> index 8d6cfe5058543..583e95568f52b 100644 >> --- a/include/asm-generic/tlb.h >> +++ b/include/asm-generic/tlb.h >> @@ -211,7 +211,7 @@ struct mmu_table_batch { >> #ifndef __HAVE_ARCH_TLB_REMOVE_TABLE >> static inline void __tlb_remove_table(void *table) >> { >> - struct ptdesc *ptdesc = (struct ptdesc *)table; >> + struct ptdesc *ptdesc = page_ptdesc((struct page *)table); > > And here you're assuming they're page pointers. > >> pagetable_dtor(ptdesc); >> pagetable_free(ptdesc);