From patchwork Fri Jan 13 03:19:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13099678 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 B54E7C54EBE for ; Fri, 13 Jan 2023 03:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56D93900005; Thu, 12 Jan 2023 22:20:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 51E02900003; Thu, 12 Jan 2023 22:20:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40D2A900005; Thu, 12 Jan 2023 22:20:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 34ADE900003 for ; Thu, 12 Jan 2023 22:20:11 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EFBA8A025B for ; Fri, 13 Jan 2023 03:20:10 +0000 (UTC) X-FDA: 80348322180.05.CDD760F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 6A9241C000A for ; Fri, 13 Jan 2023 03:20:09 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b0nT3xUG; spf=pass (imf18.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=1673580009; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VSIbSzL2bxKjEoqavrvpRp0pIuSz+KbDY87ApaDwMng=; b=Rm2xqEymQrr+DhZlEsP3qiR3IxldBnav72HUOOHYjBq0TE6QrJMGgUOwu7n5BrY8H2sMWM rJmD7aUpwPawuvmoK2p4c03QIJKoD98IR8RUzPnoc0EGGTYjf1wuzPmR3ZZ3b5fhvf6hIb +LQeuiL+CNUwTuisLO0HrdfU4Ak/VAU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b0nT3xUG; spf=pass (imf18.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673580009; a=rsa-sha256; cv=none; b=kU5f/4NOasai8XJXGiJsyi0BbGRDedzDUtltMkc1W5yZIfQOR/GYjbhdEG4Pmc9kFca040 xvfZ15n4zEw4dvRub2HSr/DU2/P6YgcvN4mtrjVgdGzPwAOndbQ7oVgaNJOD6XUzfoO23U 1ogl8un0PRhAKqzCsRSLuRFV7/T/FGg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580008; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VSIbSzL2bxKjEoqavrvpRp0pIuSz+KbDY87ApaDwMng=; b=b0nT3xUG9Z6yydesUr25j9yqUBiXZJgqCXfc0nEamPjR3VJ9QRFdhLaemjhEzoQgW0zep6 vY/n+vr8o9N/sQjdJFQlVCNz0xK0sFiB0dNRr9wlXCSQdUdURTfwqFnx18N1wp15N0pWnG E/tsJFFiFS2Lvv4qtG+XPax/BvKueB8= 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-610-QVWkk8okPcyjXl0ZR1WrbQ-1; Thu, 12 Jan 2023 22:20:03 -0500 X-MC-Unique: QVWkk8okPcyjXl0ZR1WrbQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8544E85C069; Fri, 13 Jan 2023 03:20:02 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31AFB4078903; Fri, 13 Jan 2023 03:19:56 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Fri, 13 Jan 2023 11:19:19 +0800 Message-Id: <20230113031921.64716-6-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 6A9241C000A X-Stat-Signature: uwriodakx8myaddwe8qpyf5dxqhm5zin X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1673580009-644620 X-HE-Meta: U2FsdGVkX19aqyvPw7PE6JtDSd1D0aFiySbkxPsXxcWg/XEvsGEMB1rafBWXMCCA90YHJ30Kjw/7+YkbzniwWoegIBA0RtIj4STxPKuvFQ4kXTmQiC2rii9kZfheDtRu0v6xseBawIMqZHXnqj6umTbI5PuEJgg9f1gB8+DfntttzEc26UYEnJUFHbrcZzejU8cK7riwjN9Dq68/je7JxRTnD6HFdcHLc5U+/PJkvjrPgBmiqNB3MVNvgSCwZstD9/cVC5Z75kt/wm2Ex00N1PqOvbzLTJQWQ7RXqOP7lsG/FgktEPhjnIsXJ3akwWsHNiBPFFQXHfvXaRxSyxUno05FonWcaOLFVA/eI7IVG/6crGCrhKKndxCrscA7xbLIxWv5bbSBQtn2aX1LcO1KPxaotEVcmKc09lni+IhE0fbZEec0q06KOL30K/EzRRbvO8ZQhb1gYkR0WpeYJW6hcDEswOYwtP+7IgwUXOtNR9bTs29a2vaw8NQYOnFgCvNz95vKqVSRELsNbFKxZ3YA4VeSUVVBoaW1KTh2eThbMHCj/cFFRLgPB+dJ6WElJ1t1x8XdRZKxNOiMp+u7ppWpQXQ643c7J9DQFFojxNMDVWDGljMjuQ4vzI6LB8+gR3rlvrdZ2MxovXs6oVYvz6bgpT1rnFM/FJS4izb29cAOVFxNwoaTnml5lr4TrdtdDc422Q7oJL+Q8TvdQMoyTPIoPAgE6p22vU+SEtbLMjKMJnIA1ZCHu5qctQWVj65McNeW5/ajJdxWA/UeHtzJiJBi/y+bM1amZNmDQ+BqenUb9EQOpD4fHqBNuamNQA6ZeK4TSpOl2BkUClpA3tS6iD+4pHYpCOvt7UirfRapeiq/h3ARDQ0RmUTxjyS//f0pWmulXXdRYbHDnI4WasDyWduEBANy5yu9bw0z 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: For areas allocated via vmalloc_xxx() APIs, it searches for unmapped area to reserve and allocates new pages to map into, please see function __vmalloc_node_range(). During the process, flag VM_UNINITIALIZED is set in vm->flags to indicate that the pages allocation and mapping haven't been done, until clear_vm_uninitialized_flag() is called to clear it. For this kind of area, if VM_UNINITIALIZED is still set, let's ignore it in vread() because pages newly allocated and being mapped in that area only contains zero data. reading them out by aligned_vread() is wasting time. Signed-off-by: Baoquan He Reviewed-by: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4a10b3b692fa..dbcdcad2276b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3660,6 +3660,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm && (vm->flags & VM_UNINITIALIZED)) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = vm ? get_vm_area_size(vm) : va_size(va);