From patchwork Sun Dec 4 01:30:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13063708 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 B1E78C352A1 for ; Sun, 4 Dec 2022 01:31:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 214398E0008; Sat, 3 Dec 2022 20:31:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C36F8E0001; Sat, 3 Dec 2022 20:31:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 064F28E0008; Sat, 3 Dec 2022 20:31:31 -0500 (EST) 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 EA4BE8E0001 for ; Sat, 3 Dec 2022 20:31:30 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BCEBDC06BC for ; Sun, 4 Dec 2022 01:31:30 +0000 (UTC) X-FDA: 80202896340.08.4E4CD46 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 6988B20015 for ; Sun, 4 Dec 2022 01:31:30 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eB3a1cCK; spf=pass (imf03.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=1670117490; 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=wKUFea3iuo2ZSUdXWfK1liYiDAjCBI6QYsheARET57w=; b=tE0/2vWPPzMfCk55GKKeUPQWESOOMPez1ahNMsEMs8wm6+YtAmC0Na7fOMVhA2Nk3joMzJ 2BWmydkkPGh0p2ZpuCg5q15okCholuvfGfvXNsuXsRAZUTZawMeKIkd8uIBEbO0asFN5p8 8hizSg28DKoZLNkIaje/4pBg/9bNUTY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eB3a1cCK; spf=pass (imf03.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670117490; a=rsa-sha256; cv=none; b=qrHrPpA/OCE49dHUUUozzIWno2L0kulDEXFdQSzJjuFrfyZL/FsYVoaY0qCREP6c8+FmSO LTqdYXjXNzVrBFXJ1Bt9Scj3MIHDJP8pmgY6TGEvY80uhdiyLs6pOtJezJiwM6KbTo6xiB E5NDzSeEj/58lzFTkgd53vGvYlsCbcI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117489; 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=wKUFea3iuo2ZSUdXWfK1liYiDAjCBI6QYsheARET57w=; b=eB3a1cCKMXaGBsXXifR1aNuTB/EdaLObj+uO2GUMS7rcUyLu0JwZQRGG6GcLcEoEZ9U94S saIwcMr/zJgERff4J91JhlP0sOyva6GvGuuiXncoDuqh7ywB6L8MpkaN67dmd0egLfc2VJ rXSYtCP52S7gkbxAMUmzJThSfD8DVwo= 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-447-tQnrB-I0MgKTwkmoyLoYDg-1; Sat, 03 Dec 2022 20:31:25 -0500 X-MC-Unique: tQnrB-I0MgKTwkmoyLoYDg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C08B29AB41A; Sun, 4 Dec 2022 01:31:25 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 157391410DDA; Sun, 4 Dec 2022 01:31:20 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v1 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Sun, 4 Dec 2022 09:30:44 +0800 Message-Id: <20221204013046.154960-6-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6988B20015 X-Stat-Signature: 44dx6ay7j7gxdir331dqpbmoe6h6prpm X-Spamd-Result: default: False [2.59 / 9.00]; R_MISSING_CHARSET(2.50)[]; MID_CONTAINS_FROM(1.00)[]; DMARC_POLICY_ALLOW(-0.50)[redhat.com,none]; R_DKIM_ALLOW(-0.20)[redhat.com:s=mimecast20190719]; R_SPF_ALLOW(-0.20)[+ip4:170.10.129.0/24]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAYES_HAM(-0.01)[43.76%]; RCPT_COUNT_SEVEN(0.00)[8]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[redhat.com:+]; RCVD_COUNT_THREE(0.00)[4]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_SOME(0.00)[]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; ARC_NA(0.00)[] X-Rspam-User: X-HE-Tag: 1670117490-258292 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 --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 3c60026fb162..3e7b7d2766f6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3616,6 +3616,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm->flags & VM_UNINITIALIZED) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = flags ? va_size(va) : get_vm_area_size(vm);