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 99FC4C77B7A for ; Wed, 24 May 2023 11:24:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27896900003; Wed, 24 May 2023 07:24:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22806900002; Wed, 24 May 2023 07:24:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EFF8900003; Wed, 24 May 2023 07:24:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F341B900002 for ; Wed, 24 May 2023 07:24:56 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B0B9DC0921 for ; Wed, 24 May 2023 11:24:56 +0000 (UTC) X-FDA: 80824916592.13.2AD2EAF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 8CBE514001C for ; Wed, 24 May 2023 11:24:53 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YIiKe4xA; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.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=1684927494; 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=JezC3/zCV/3uGXNDST5b65RHqkXv/8d7bH9CrrN9QfE=; b=SijoXWrLBTRrmLJJCNgDWeLZ7AlV0zvWhH35pgz3p2eWfJ2QjLbBhhKx7yjxczm+oi+yhC bg+sWoSwt0ZkrOci9xVTFhdnmidL34gW8Fwl6af4YBcG8/AAC/ZeOsdPEplf0zlt/GAWw1 4nthWaslkKvvWu6zF0OVkxy9d3y+LAk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684927494; a=rsa-sha256; cv=none; b=nYfxiLb4syOQwNs2rGaUDXuqoVWKMzBWHkHrDTeTnwRNR0oxeOYmNtwATj5WTTsRmNtoSM d1AmPEU9BmKVNqVxBLy9QYCGxoHcozXkyNBoELJ6R/CD8E7lTGTnexunHnjBleu7ieXG8D 6zwV4sxqNTARc67gFtBuimRf0BApTu8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YIiKe4xA; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.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=1684927492; 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=JezC3/zCV/3uGXNDST5b65RHqkXv/8d7bH9CrrN9QfE=; b=YIiKe4xA4sRPUZzsxWD/xfwnM54wVusQWSr14UPeS2KY8aEVXLhyNg2lBoURxA3HZNUWHX P8L4ZCIU+jFYUX4rdm2y3FgcbJyKrRL3TsuNY9KxUEKz6b9DFhW6HUn/pbvXmkruLnwIwt qgPqsy4VIzFpWdRMpG/5jQ0LGM/z4xo= 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-455-VXLSzULwOSGHDdIEOTlBKw-1; Wed, 24 May 2023 07:24:49 -0400 X-MC-Unique: VXLSzULwOSGHDdIEOTlBKw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A2D1811E7F; Wed, 24 May 2023 11:24:48 +0000 (UTC) Received: from localhost (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5AD4492B0A; Wed, 24 May 2023 11:24:47 +0000 (UTC) Date: Wed, 24 May 2023 19:24:43 +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: <87mt1um508.ffs@tglx> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Queue-Id: 8CBE514001C X-Rspam-User: X-Stat-Signature: fr8f6uxzes7qdn8a8c6uodz4w4hwqtzs X-Rspamd-Server: rspam03 X-HE-Tag: 1684927493-522342 X-HE-Meta: U2FsdGVkX1/vG9SEqH74SwSxS/omqqlaG0J74nsBsf8xyRgspUO11kP2mLhDuCkcojpC20qlqyEBeMg9k2RrcaG2RmMfFoAcTvuJYnubIw6duGsr48+8UKoDdK2N4MKq19J9WYThG8pcKhKQYuwkuxbw3k6k/TvcBp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1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 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.