From patchwork Mon Feb 6 08:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129481 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 AF1AAC05027 for ; Mon, 6 Feb 2023 08:40:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DF446B0074; Mon, 6 Feb 2023 03:40:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 467786B0078; Mon, 6 Feb 2023 03:40:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DFAF6B007B; Mon, 6 Feb 2023 03:40:58 -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 1E4CE6B0074 for ; Mon, 6 Feb 2023 03:40:58 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EF1B2A0C02 for ; Mon, 6 Feb 2023 08:40:57 +0000 (UTC) X-FDA: 80436221754.09.C100448 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 3E0EF100008 for ; Mon, 6 Feb 2023 08:40:56 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hfVRuB9T; spf=pass (imf14.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=1675672856; a=rsa-sha256; cv=none; b=pcooAvAmve4uK0BBWPmXtoWeNSVM/psAJzN/fsNDrbaExJzm73Op8puiLn2kiqSDC3G+C6 Xv9tBZVKVAJkDHzs0QwzxgQyVUhJr0sWrWzMu1jvvAyv+FIZtdH62xo0zzpKWdm9b9VkWm bjj87njdA8bs+sorTmSh75z0DGCJCco= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hfVRuB9T; spf=pass (imf14.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=1675672856; 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=hiVEWJoEN/c7PwG6FQD6hYWxpoLbbmsKmDjpAMaWIR0=; b=rk9d0oKlv7xheSwucaRoP2juMCmzjMhrXiY+i25R+aovzg9WIFiPyBHOJkL8iS8YkPmOmr ssz3gAJRQUkNZqR9vRIWHXYgNsayxHdgH7JH89jyCF/f/DxY/YFyY6NB+bJ9lF2t1Hhoqk ra0mM2ubT5ywaBvqjaK857Zae4CuiCc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672855; 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=hiVEWJoEN/c7PwG6FQD6hYWxpoLbbmsKmDjpAMaWIR0=; b=hfVRuB9TydLfrNl3i3xkdaqU07V6Khh1f/x9sO006at9OWOrfPrZOBLbf6gBR0QAZBd/Z/ SY7RDetPhp07dPaPZr2H4cVvl9MX2gcBe0t2hoZJ5hFi6U95m7TQWkFKEvf/PvfU6VwzjC eKFeIrnKkhk4ccDSqg6UjSCezjf7Ulo= 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-622-GSAZ0BOoM8aVUFekIGNdrA-1; Mon, 06 Feb 2023 03:40:52 -0500 X-MC-Unique: GSAZ0BOoM8aVUFekIGNdrA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 120E687B2A0; Mon, 6 Feb 2023 08:40:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFD372166B2A; Mon, 6 Feb 2023 08:40:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Mon, 6 Feb 2023 16:40:18 +0800 Message-Id: <20230206084020.174506-6-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Queue-Id: 3E0EF100008 X-Rspamd-Server: rspam01 X-Stat-Signature: 6cztka15p6mdagr4rrmtygioeqiks499 X-HE-Tag: 1675672856-641491 X-HE-Meta: U2FsdGVkX1/L28hhFFofA59H6Fg20VcDolnHfWN5d9h//+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RM3Nl3+wJVpETn5h3hexJPZQa/tISDxkeX2LO5olxRQ9M58QFxpxwhyiWWiHzENm8ptJQj4mQCFWpcn9hNoeEQfIZaocA== 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 VM_UNINITIALIZED. 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: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index dea76e73e57c..8037527774db 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3668,6 +3668,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);