From patchwork Sat Dec 17 01:54:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075750 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 1260AC4332F for ; Sat, 17 Dec 2022 01:55:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7A318E0008; Fri, 16 Dec 2022 20:55:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2AE68E0001; Fri, 16 Dec 2022 20:55:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F31B8E0008; Fri, 16 Dec 2022 20:55:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7E4678E0001 for ; Fri, 16 Dec 2022 20:55:18 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9E4D7406FD for ; Sat, 17 Dec 2022 01:55:17 +0000 (UTC) X-FDA: 80250130674.06.F5A3DA3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 18A75140005 for ; Sat, 17 Dec 2022 01:55:15 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FXnjIuSn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1671242116; 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=04/RfLLW+utGDl2gGNjOPJkeYdkxOAnoWfhoc+UAnVc=; b=592K7uPMCdksMBIkYywPD3N0hQJUPRCVMwQ49gH/RyrR0rKOv/0GKdm6zVmgP/xeSiohJe fLfi81sK+bBxXPa0jia2zTOXYQIlmQ3Yoi/249ms1DGThbkG5fRbROlMfoOqeyIVKB9B30 sG9rH2HU5iCfe3XbmUSQh/cnqrOsvoA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FXnjIuSn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1671242116; a=rsa-sha256; cv=none; b=1kOBaQ9jyr3xETs0FrsHHJMZ/VD7nNFi5GDauMri9dk4ijE3sQ/wN9lIgD9y4f4u5D1gLQ s8wIr0XIBLlZtw7UE5OkmB2mJ+ER8jOZbDRaM4MnvnQaNB6lRis+EEte3L+foZjWf63csU x9JOmwn+8gVMLarnHuAaIz2adWk5rLE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242115; 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=04/RfLLW+utGDl2gGNjOPJkeYdkxOAnoWfhoc+UAnVc=; b=FXnjIuSnPGp2pOf7rrzr8eshP158nf5LsZorzsKHgk/4psPRw9sJRIghsyab3f7AsbvGqW NFSuBzqsyVxHy/kthPaFLectMBHt+u91jZ89WGr+k/3gT6F7qBZHkMfcQ2gs6nkym9fTH/ bLH6zY7WFRBPiqAdFTVizqmGDfSQ+tw= 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-646-p7aGxOkiMEGk7SjP7CbKLQ-1; Fri, 16 Dec 2022 20:55:12 -0500 X-MC-Unique: p7aGxOkiMEGk7SjP7CbKLQ-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 78BBA811E6E; Sat, 17 Dec 2022 01:55:11 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 752AF49BB6A; Sat, 17 Dec 2022 01:55:06 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Sat, 17 Dec 2022 09:54:33 +0800 Message-Id: <20221217015435.73889-6-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 18A75140005 X-Stat-Signature: rqaybwqxotipfjm56bo6bmm4dxiyj1bp X-HE-Tag: 1671242115-13228 X-HE-Meta: U2FsdGVkX1+vRSYE71YxUHkV36tmncxHv/oeeZ0yc1BqsKYJNm2Qm7kC6ma8W4FdJzfT0E9u1FMuXLMbA19jZXrBKUQXcg63YvbuTHXwc6w8YWWfGgnpVUNUgAHm9VbmXwwThRIGtGuK+hv/8UexNffzDc4JcUygy9Wf9eJhJxBQyxSgbkLF2VQh6APP/oiNmR3/dbPymGdj3755PzOeiinRiqTmOLdCiLfir0tI7CkAMyynq88Izpn2mJPvr5VB6Z3Gb/dzlumdaGGXazdMi0X+5U2uIzUAglb3Byx2b2NXVE1JhpiwAnh6sRWtmzOob4xi7R6T8AlbSM+SMUAYeR/KALmpGYjBaM8DkS47pkVYTacSuREf2p4FuRxMxURqN50nYGdKigVfL8xSbRGxgk2QHarlz/XpUEDQ1gIPzECHSYAqhk6Dx0q8nzJle8rF11NrtaEYIWH2K6VlMG7o9hrIEEd7236FnrNyVLmXqqVAoQbIo5DJ0Tsh9MzJPVd+MHe5s07XGyADOVXN7lBcMy2IcnHzpJxPftS/AJFQp4GkqjSq2mJg4mULNuVzTn20R3w8qcdkB7VyA9rpnkGMqbvv5AywO8IHJCizom85iaVq1SgCflktvo4qu5gMxUfcxu48hSraYztKO6xrR0se/MSD7p/2RItrDhGtlBjXYzh8ll0H9qyetOI47BvjltmmwnJnk+mn2m25Kf/Bg06gYlr2DFOkN9npA6XkWopCFXiBaDDRvwEd2gVwGZ7Q4zZxaJrv6p8vKrsfRHDHpNQhshglusiFfRPBT4julUFX3xgqkkmKL1+E6qc9uKIPmLHaA1hGRDXDDTt5W+8i706Itvll13BECpsHw/fjlLmS4GzBBJnZizPBo1UCV+ITr8lp/xUsQ7EBcGuy+9k7nLksUVI2DRYxpOVd 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 3bfa872a4513..bdaceda1b878 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3617,6 +3617,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);