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 2EB7BC77B73 for ; Wed, 24 May 2023 13:41:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF795280001; Wed, 24 May 2023 09:41:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8015900002; Wed, 24 May 2023 09:41:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96EDF280001; Wed, 24 May 2023 09:41:21 -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 86241900002 for ; Wed, 24 May 2023 09:41:21 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2CD711A09BE for ; Wed, 24 May 2023 13:41:21 +0000 (UTC) X-FDA: 80825260362.09.0AE5157 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 417E8120021 for ; Wed, 24 May 2023 13:41:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PVTt1bT+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684935679; 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=9XIpXixyZYGeEJs3S63swdMZWokL47dJTGsR6etuCwY=; b=rm8PMvIDwyREAgFaCXHUPibuRGnh6/N3nD+/LOttBn1PIiw8jMVgFl32zy706xUPhOQmgm pO4mFT9iAwfgl6P49NiSRR4mAoonBJYEp1dslhVJYWhw12cKZNmWZgtF4bRFHN4WQpzxv4 nNeXKEDR/ujqi9v76zqtD0C0lMzhGw4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PVTt1bT+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684935679; a=rsa-sha256; cv=none; b=xwXdbFtma6DBpCEw/ZM3MzMAnrAPPmq8qUf2oUXFF2zOLUeILjVgzScEvS6iSfs6Hcj8Kc dArGQe2zcMZz/cYC3aykSBYQXSjrrqryqLeFBgd7N/l3vYR9VrCrj9EcMvY/gBikM/3ii4 Qk6ykJMV1dXBV++1pECteE4y8lyM4w0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684935678; 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=9XIpXixyZYGeEJs3S63swdMZWokL47dJTGsR6etuCwY=; b=PVTt1bT+cTXk82uBJs4kEgXmfTfypGltZA3q9oOaIeevS9fIysXYxma2h3O65SikyYYyS7 DCRG5oZIcK7xAQsIhvRYEmX4s4ZDLQLWLaFlHBWGVw7orGJjDj3kuNM8MDEAN6Z8POy8Te GZe4+ywtUNxbkwwBDyCPQlvRV2OIiFE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-g-3MG0scM2G1s7gGqlUUvQ-1; Wed, 24 May 2023 09:41:16 -0400 X-MC-Unique: g-3MG0scM2G1s7gGqlUUvQ-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 6E414282CCB6; Wed, 24 May 2023 13:41:14 +0000 (UTC) Received: from localhost (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A6D8401026; Wed, 24 May 2023 13:41:13 +0000 (UTC) Date: Wed, 24 May 2023 21:41:09 +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> <87fs7lnbko.ffs@tglx> MIME-Version: 1.0 In-Reply-To: <87fs7lnbko.ffs@tglx> 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: 417E8120021 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jnrid9pfkxgn7zoxx6tte3nsqr7n3b16 X-HE-Tag: 1684935679-226525 X-HE-Meta: U2FsdGVkX1/ZJzn59ntqYRnyc8SLSeflRJt+7mz8QAzvdEnKl06OkqqJHZ4v95ZfPdzzNQfI0kPkblfAo/UXyssLxaTGl2LrtHT6Z7w42bYPmgKx+vT75T1Yt4SyERsFupKUJ6BYv9/N0EDSS8DmH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icity=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 02:44pm, Thomas Gleixner wrote: > On Wed, May 24 2023 at 19:24, Baoquan He wrote: > > On 05/24/23 at 11:51am, Thomas Gleixner wrote: > > 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); > > This is irrelevant. The path is _NOT_ taken. You even copied the > comment: Ah, just copied the whole, didn't notice that. I am not a scrupulous person. > > if (vb->dirty == VMAP_BBMAP_BITS) // Condition is _false_ > > Did you actually read what I wrote? > > Again: It _CANNOT_ be on the purge list because it has active mappings: > > 1 X = vb_alloc() > ... > Y = vb_alloc() > vb->free -= order; // Free space goes to 0 > if (!vb->vb_free) > 2 list_del(vb->free_list); // Block is removed from free list > ... > vb_free(Y) > vb->dirty += order; > 3 if (vb->dirty == VMAP_BBMAP_BITS) // Condition is _false_ > // because #1 $X is still mapped > // so block is _NOT_ freed and > // _NOT_ put on the purge list So what if $X is unmapped via vb_free($X)? Does the condition satisfied and can the vb put into purge list? In your above example, $Y's flush is deferred, but not missed? > > 4 unmap_aliases() > walk_free_list() // Does not find it because of #2 > walk_purge_list() // Does not find it because of #3 > > If the resulting flush range is not covering the $Y TLBs then stale TLBs > stay around. OK, your mean the TLB of $Y will stay around after vb_free() until the whole vb becomes dirty, and fix that in this patch, you are right. vm_unmap_aliases() may need try to flush all unmapped ranges in this case but failed on $Y, while the page which is being reused has the old alias of $Y. My thought was attracted to the repeated flush of vmap_block va on purge list. By the way, you don't fix issue that in vm_reset_perms(), the direct map range will be accumulated with vb va and purge va and could produce flushing range including huge gap, do you still plan to fix that? I remember you said you will use array to gather ranges and flush them one by one. > > The xarray walk finds it and guarantees that the TLBs are gone when > unmap_aliases() returns, which is the whole purpose of that function. > > Thanks, > > tglx >