Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4093887rwb; Sat, 3 Dec 2022 17:35:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4RKBBQ+bHMq9G8RWKuVMfogpl6YLVTqt8oc+gzwllVBCL1dKBbXNCySJwTwSF4F7LopiqL X-Received: by 2002:a17:906:a147:b0:7b2:7b45:2cd2 with SMTP id bu7-20020a170906a14700b007b27b452cd2mr65058948ejb.615.1670117715522; Sat, 03 Dec 2022 17:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670117715; cv=none; d=google.com; s=arc-20160816; b=dChG7dpxSygUQ6NmjjAQp9qBJ5nec/SAO53+Cef2Lqc/YFTrPEOwsmpj6mCOSSETbj J7WvD+quM1wsJNBitKNaIchgMmKmPX2e9eDBEknZC3xm+GXUggQCojwY0vG84DhWmnhI QMUDIxFfJzovYjVMv4aMhXAJMlupJ96lp0k8MzfJv7TTVEdyEn0MCBQDIXB1FOBcmKTk jbvNsbf3Bmv1kvzxQwmVJKhkUgCE85BsO6+wc6utYF2sqkMym5kTSMq0U3zFy3Mn0a0O PCfXsUWx+uvZEGEckJ1tevFt1eW7V5vM3M2NLD0BW+nrHRR9bAnv61NWM1GtBjrU99u7 a9Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wKUFea3iuo2ZSUdXWfK1liYiDAjCBI6QYsheARET57w=; b=sUK6TZGyBM7KAx+Aepj40CBaZI86vfCOWwokSoI5dInAjo/VuM2bbXxONgVclgjlVj qYiu5oV9r/6MzwqEm5FJd25Udwarn+z81Je64FIjDKisoKT/5AmP1z8+BO8TSyPYllmT Yfg3y5VDBYm0e5JRZvNL5gEwgo5+dB1S7cV8pqWl8iMJ1EP1OelIxcNJ+9cs+l6zoQB9 Hq+xohfuly38jZI6OANC0kuOoPDqDCtwABjEBXYBqFIFOT0JV+sfgK8ep1FZDH2A8tNL xMSOqRFK89zR/L7LBqPq3mDuRdJCGmTj9eXAfKFC4dmZ5Ss9mhQVztrMKjQ1dn0HhrDG UcWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bG3j35fF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg11-20020a170907a40b00b0078df3bd80b9si9493166ejc.46.2022.12.03.17.34.54; Sat, 03 Dec 2022 17:35:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bG3j35fF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiLDBch (ORCPT + 84 others); Sat, 3 Dec 2022 20:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiLDBc1 (ORCPT ); Sat, 3 Dec 2022 20:32:27 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA5F1A205 for ; Sat, 3 Dec 2022 17:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117491; 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=bG3j35fFY1fkG/rY/+x+XSLyjdMBS6e8ghRh+ZTHQfNOdb1M+vNChZG9aYGcAgXE88nJqP uBCEhOHHVChqFidRcpujYCKPM245WDjBihS0Dx53HcQcfR3jAc5Pfb0Cit6WZjsHh1i8I8 DOxKnAkc1yeph1O2ZAwIyA3JRAhtDxA= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.34.1