From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D95E6C77B7A for ; Wed, 24 May 2023 11:26:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 732D4900003; Wed, 24 May 2023 07:26:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E183900002; Wed, 24 May 2023 07:26:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AAC0900003; Wed, 24 May 2023 07:26:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4AB54900002 for ; Wed, 24 May 2023 07:26:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0D2041407A7 for ; Wed, 24 May 2023 11:26:43 +0000 (UTC) X-FDA: 80824921086.21.80E0550 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 303A714000F for ; Wed, 24 May 2023 11:26:39 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Vyqf6Q2I; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684927600; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vZec4XIKJOVsW5kd9joo7grDyZUdpAAW0LYDqaDK8Pc=; b=LulnWgIkdv1Gqv+3hIXyECMMQbQpHSRmTvEZeZDW/Pw6behlsyKsilA8/BUvO/VVXa8bRj XVEqUedINKR01lih2WcIc5PSV3epbLwgo+eTbzEUPCT8PXRbhLPQ2FqwtOoFyFRXcLtg3w DoQDvIAef6/LGoukxGWPagfvuPsDyJ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684927600; a=rsa-sha256; cv=none; b=gUtlli6YKC3onAwGJZYZNcMelb+yNhkk6l4hZ7Gr3eG8Vj5Dd1rHhoZoeEiUh9XvGvSMNI cQNAeRn307isHRETECCPmRl2+6cH8V/mSGp7ynLSyRhERtQSWfZheb7uMHW1xXQuNA9VXN ouNuMOcFCPL4mLxEOPvPU0zqEEJqjC0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Vyqf6Q2I; spf=pass (imf09.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684927599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vZec4XIKJOVsW5kd9joo7grDyZUdpAAW0LYDqaDK8Pc=; b=Vyqf6Q2ItkZLm71KPolYN6RLY6Wl9BujrOlkGW/r/CKc7DTUhpzhuuCmI/wAyr/HCp5s4U EMt2F94lF5aSs40fC+WgyaVNnw1/5PzvJVOWa0BmbN3AgodZCYBYmBSE9WjpXa11OQz5/n O+MgjwP2Eqz+KaDl6JiCpTeCdPuOvwE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134-m51HNZ7bNSChxpDk7IkoJg-1; Wed, 24 May 2023 07:26:36 -0400 X-MC-Unique: m51HNZ7bNSChxpDk7IkoJg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B382F85A5BA; Wed, 24 May 2023 11:26:35 +0000 (UTC) Received: from localhost (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15143400F17; Wed, 24 May 2023 11:26:34 +0000 (UTC) Date: Wed, 24 May 2023 19:26:32 +0800 From: Baoquan He To: Thomas Gleixner Cc: linux-mm@kvack.org, Andrew Morton , Christoph Hellwig , Uladzislau Rezki , Lorenzo Stoakes , Peter Zijlstra Subject: Re: [patch 1/6] mm/vmalloc: Prevent stale TLBs in fully utilized blocks Message-ID: References: <20230523135902.517032811@linutronix.de> <20230523140002.575854344@linutronix.de> <87mt1um508.ffs@tglx> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Queue-Id: 303A714000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 4d4qwh63bc5tywo3b1wr817uiqzgk3gk X-HE-Tag: 1684927599-952667 X-HE-Meta: U2FsdGVkX18NbTqsIdahygNW0iKr2n3GP89qHrXKoo63QA+yaKRSwF1Y9KbF3n6f3+mj3h2VHHqn1tAazYgXITXSO25+ZIIY0/GbomgaJ61FyqSmlHvtQ/Pc5a3q81tVmt0ocvZRcajiBcT6ZwksVe8OUgPr/reKHrHzwGO3wbC7mFjSYPpsJ4BPPM17sr/bGNimEyYIcdhxsjYU4c844C8w6ZiYFHzvgHMxVpoJ+JdKvzRLlQAvIgwKLhHsj0p2WG+vU3HxOirhb0O/ehg82x8CkiUI8KaynIMjlzB30pkb4baOqC0bDFG7q+FGvzYaiuTWM/fNDQ+/IrZUQ+AaWbq7TF2Nu/Kork1acUurAl7g5u/Sp4yYczLcZDxxMsDg9qtIFT04Jh1AQ0MBcjbI6IVI7MPUvS6/3m4/64qASgAPAbR9RTLTuHPJcKj7VRXdaaauq2Rl78ZyaIjT52ooixqxWQ1K5nRH/8AP1olQtw6Kz04+9QWziJRX2Tj/5h96DK4niZqO9uF8vjH3B2sOskWj6q+tMkoEk0GZagks92OYTnhOapWveAmjgr56Ldv8CefM4dZZEqvbRIqQQygL7TdREhghw3zhYflQ/ShjtQ1rlns/uoDWWPLhZYp2nsMVpugR69TbgBqtuBQj3GnqWrX43OwKuTuXuMSQtvvLD8yw0FL8OYHPnRjDmXGeP10q4YxRecYGAVs7X0lkASRLX1wg0mUcZR0cTRm9bJjWzzPDt4y5E5EFRiCxJhBxDBRU33TnURxlC+3XB0f3sMZH0fNF1l8Ucf9Argl4mtHtHS+5L7C44pfxZxdpQ0LADuLAvSFC0InvYU/NJiVJs2cyRz9rlTCL46C6oaucONu58CBXuvqEJ6uqVGpNqhyElbjPoOmNclf3L4PtK+mVJUakhRRJ+WruE3n3weCc/VUCiDHEdBz0Qd2CzYqUXoHpb7TURi8gVNSqthYZKOGCU4Y Mr5LNsrA 0Urko3UTivvEo97b/BIM3ZBBchC0tg/p/aOaaQx3L61SqDiEmDLzogWljWrrth5E1XVR1dKwIsqlXuoMZqIHhTnYRb4HGviTfZEjICpmnhJvOA8wwI7JVMv2wL+KOub7wIw2oI2YIOzw1babu6ISQj8jzpEyIoiln0fq4bh1JrDHTV17wSbWtt446r23MXAzjdg8bSkGvMxO9NCk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 05/24/23 at 07:24pm, Baoquan He wrote: > On 05/24/23 at 11:51am, Thomas Gleixner wrote: > > On Wed, May 24 2023 at 17:25, Baoquan He wrote: > > > On 05/23/23 at 04:02pm, Thomas Gleixner wrote: > > >> _vm_unmap_aliases() is used to ensure that no unflushed TLB entries for a > > >> page are left in the system. This is required due to the lazy TLB flush > > >> mechanism in vmalloc. > > >> > > >> This is tried to achieve by walking the per CPU free lists, but those do > > >> not contain fully utilized vmap blocks because they are removed from the > > >> free list once the blocks free space became zero. > > > > > > The problem description is not accurate. This is tried to achieve for > > > va associated with vmap_block by walking the per CPU free lists, those > > > fully utilized vmap blocks can still be flushed in __purge_vmap_area_lazy() > > > by calculating the [min:max] of purge_vmap_area_list, because va of > > > vmap_blocks will be added to purge_vmap_area_list too via vb_free(). > > > > No. The fully utilized block cannot be purged when there are still > > active mappings on it. Again: > > > > X = vb_alloc() > > ... > > Y = vb_alloc() > > vb->free -= order; > > if (!vb->vb_free) > > list_del(vb->free_list); > > ... > > vb_free(Y) > > vb->dirty += order; > > if (vb->dirty == VMAP_BBMAP_BITS) // Condition is _false_ > > free_block(); > > > vb_free(Y) > vb->dirty += order; > if (vb->dirty == VMAP_BBMAP_BITS) // Condition is _false_ > free_vmap_block(); > -->free_vmap_area_noflush() > -->merge_or_add_vmap_area(va, > &purge_vmap_area_root, &purge_vmap_area_list); > > The last mapped region will be freed and added to purge list via > vb_free(), it will be flushed with other va in purge list. When it's > mapped via vb_alloc(), it's detached from vbq->free list. When it's > freed via vb_alloc(), it's added to purge list, and flushed, the thing ~~~~~~~~vb_free(), typo, > is duplicated flushing, no missing flush seen here? > > > > > So because $X is not yet unmapped the block is neither on the free list > > nor on purge_vmap_area_list. > > Yeah, because $X is not yet unmapped, the block could have unmapped part > flushed, or unflushed. For unflushed part, it's got flushed with $X > altogether in the purge list. >