From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by dpdk.org (Postfix) with ESMTP id 0A394AFD5 for ; Wed, 30 Apr 2014 16:15:05 +0200 (CEST) Received: by mail-we0-f177.google.com with SMTP id t60so1751366wes.36 for ; Wed, 30 Apr 2014 07:15:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=6tAiocBfea63vH5H2F4EXyVFXAdLxdeh3K12D3Fwuyg=; b=Y+FQhg3fqSIvW+rJbBYli2jm1tTY6pWF5B2tRGqwpMVlJvVQIH5BuzLYH0xdrn27JB jvwuIapH8rBNeoKLl3SSf27ozM585tQ8jaREHk/CrOp/CpR8nrEZXwBl+VAV8uoZUyCR d+38C/Eo5eOamkbU4CCqjsrvyjsICHi6XKBZ9EJd0EX5dyyl1HbplsRhjVm4LLyIVa2F Wh5wqlR3X7+Q4+ooBgQC2s6FPBvxIseonjlt1ippEwufLupvdljy/8jJIiMDnQvY3iLD YL788wc1mBzN5vMN7sq5G3aANTQRszO9FRKRQCg+IMCZGbFDY8PZ77yooKl6Xg/YrmO2 vWfQ== X-Gm-Message-State: ALoCoQlemVLORgqnuvAQ1z841JDRV0/+zHOdezdBVxUa7wESQ18wgZMVDEA0A6+MwiPszNanSmDG X-Received: by 10.194.120.101 with SMTP id lb5mr2168788wjb.74.1398867310060; Wed, 30 Apr 2014 07:15:10 -0700 (PDT) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id v6sm36375518wjv.21.2014.04.30.07.15.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Apr 2014 07:15:09 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Wed, 30 Apr 2014 16:15:04 +0200 Message-Id: <1398867304-21171-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH RFC] eal: change default per socket memory allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2014 14:15:06 -0000 From: Didier Pallard Currently, if there is more memory in hugepages than the amount requested by dpdk application, the memory is allocated by taking as much memory as possible from each socket, starting from first one. For example if a system is configured with 8 GB in 2 sockets (4 GB per socket), and dpdk is requesting only 4GB of memory, all memory will be taken in socket 0 (that have exactly 4GB of free hugepages) even if some cores are configured on socket 1, and there are free hugepages on socket 1... Change this behaviour to allocate memory on all sockets where some cores are configured, spreading the memory amongst sockets using following ratio per socket: N° of cores configured on the socket / Total number of configured cores * requested memory This algorithm is used when memory amount is specified globally using -m option. Per socket memory allocation can always be done using --socket-mem option. Signed-off-by: Didier Pallard --- lib/librte_eal/bsdapp/eal/eal.c | 24 ++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 24 ++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_memory.c | 8 ++++---- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 5c181b3..b6b5f20 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -869,6 +869,30 @@ rte_eal_init(int argc, char **argv) internal_config.memory = eal_get_hugepage_mem_size(); } + /* Automatically spread requested memory amongst detected sockets according */ + /* to number of cores from cpu mask present on each socket */ + if (internal_config.no_hugetlbfs == 0 && + internal_config.process_type != RTE_PROC_SECONDARY && + internal_config.xen_dom0_support == 0 && + internal_config.force_sockets == 0) { + int cpu_per_socket[RTE_MAX_NUMA_NODES]; + unsigned lcore_id, socket_id; + + /* Compute number of cores per socket */ + memset(cpu_per_socket, 0, sizeof(cpu_per_socket)); + RTE_LCORE_FOREACH(lcore_id) { + cpu_per_socket[rte_lcore_to_socket_id(lcore_id)]++; + } + + /* Set memory amount per socket; round up to be sure that sum of all */ + /* sockets allocation is greater than requested memory size */ + for (socket_id=0 ; socket_id 0; socket++) { /* if specific memory amounts per socket weren't requested */ - if (internal_config.force_sockets == 0) { + if (internal_config.force_sockets == 0 && memory[socket] == 0) { /* take whatever is available */ - memory[socket] = RTE_MIN(get_socket_mem_size(socket), + memory[socket] = RTE_MIN((int64_t) get_socket_mem_size(socket), total_mem); } /* skips if the memory on specific socket wasn't requested */ -- 1.7.10.4