From patchwork Mon Mar 9 14:54:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 66469 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3E3BAA052E; Mon, 9 Mar 2020 15:55:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C6EA51C08E; Mon, 9 Mar 2020 15:55:42 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 359AA1C0B3 for ; Mon, 9 Mar 2020 15:55:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583765740; 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; bh=jE+RjU9pOuVC1wqofvLSbIlQCdzPDgoOqxHknGMg/+8=; b=DyyLBMaFzX1abWNcEU6EMjpZfZD/GHDzYqLZc8p/1R6MRwfmRji8Y3T5glSChCKIxu4dyJ JBDEoAnz63znJonrtIB907VGUiPvs+hDE0fho4XtkHa3cE4SzVpbXC5DKXKd1rL8KMQgco sbRQlMU6Mqcaaayk9aqvENTmqB6Neas= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-SlIrKS3KPpC-a4ucKWQ8Lg-1; Mon, 09 Mar 2020 10:55:37 -0400 X-MC-Unique: SlIrKS3KPpC-a4ucKWQ8Lg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14D328017CC; Mon, 9 Mar 2020 14:55:36 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-36.brq.redhat.com [10.40.204.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E12865E80; Mon, 9 Mar 2020 14:55:31 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: echaudro@redhat.com, aconole@redhat.com, maxime.coquelin@redhat.com, stable@dpdk.org, Andrea Arcangeli , Anatoly Burakov Date: Mon, 9 Mar 2020 15:54:42 +0100 Message-Id: <20200309145442.28926-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH] mem: mark pages as not accessed when reserving VA X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When the memory allocator reserves virtual addresses, it still does not know what they will be used for. Besides, huge areas are reserved for memory hotplug in multiprocess setups. But most of the pages are unused in the whole life of the processes. Change protection mode to PROT_NONE when only reserving VA. The memory allocator already switches to the right mode when making use of it. It also has the nice effect of getting those pages skipped by the kernel when calling mlockall() or when a coredump gets generated. Cc: stable@dpdk.org Suggested-by: Andrea Arcangeli Signed-off-by: David Marchand Reviewed-by: Maxime Coquelin Acked-by: Aaron Conole Acked-by: Anatoly Burakov Reviewed-by: Maxime Coquelin Acked-by: Aaron Conole Acked-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index 4a9cc1f19..cc7d54e0c 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -97,7 +97,7 @@ eal_get_virtual_area(void *requested_addr, size_t *size, return NULL; } - mapped_addr = mmap(requested_addr, (size_t)map_sz, PROT_READ, + mapped_addr = mmap(requested_addr, (size_t)map_sz, PROT_NONE, mmap_flags, -1, 0); if (mapped_addr == MAP_FAILED && allow_shrink) *size -= page_sz;