From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by dpdk.org (Postfix) with ESMTP id C57EB1BEC1 for ; Tue, 3 Jul 2018 12:44:37 +0200 (CEST) Received: by mail-ed1-f68.google.com with SMTP id l23-v6so1281825edq.0 for ; Tue, 03 Jul 2018 03:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qPd62IJYWSQwaabD6oEGNwpugBE7RgGyKU+3P94gsc0=; b=lXBHk/p9Gm4VARcNWz5I4/ahicTtiC+OUHzl9mzWRXE/o5KiX34e/o7HEx1kvA+BU9 NdELFbjIKcocOM6TcJB8z5PRCD7mf+2tQndK18ztdipo6AMGMm6FoSE4R8dMjeCDEAPC FPZfCj0U54ZAd6gHDTSghhux/mzrNzXOmvaytJOrEYm7xqyrTpDOns+KFSCfrn89DExc Sc1BSmaMiylXJSGmf4zegVW3nheboSerLg4RrQZekVDkM7z+uF+Plr4lv1p9heAvpMyE V+2FaDaQrJln/7NGnfQt/QlgGRj2UfB8pB21FebSp34qy2RrFQcNEsIRaFLt5FWiQpF9 vw8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qPd62IJYWSQwaabD6oEGNwpugBE7RgGyKU+3P94gsc0=; b=Gbyx+eV///VBXKB4GxZycTOd5fSfh/Le0td8rZM39Ms/skdiTQtsgkKDCeOJCGp5bE L8HnmmGe6CF6hNBNIOdpRD91gLvn89oU0xDPiibPUXfPOdZ9+IYyDZtlVrWGci8xBGYd bJHe8HI2pXUjXxsK+JijSK4YnUGD7uB6d21ssCbbLcftMYiBlVKqiF3/hlDtCnz6ANdX luA0abKfva3QQdODDEJlEhxI52ksqdo2YIv24wxUdPXDHwVd6QjlFr+QsA6M1lKXUUaV bNvoOpjJQGe5s7haAQa4EWtmgrJALVj+U76uJlJAM1nmYpaX5vpZiWqMp2XM+ZLbCdBM GVKA== X-Gm-Message-State: APt69E1ZTg1Gaszm8ik78X7H/FAuVP5DwVZ10I3kB6xodscaKbUNblZG YmvuRsCa8S1CzU5WTdzpMyaanekJaaLdrmYHiAnmyA== X-Google-Smtp-Source: AAOMgpexV2HK4ObAVpgtmdwLwmXCYMUzK8x4ty72EPnTecDEZwAcHMQ3yLpz8lWLwYtR/O4aSjGeoR9dd2S+ZWmVZSM= X-Received: by 2002:a50:ec0b:: with SMTP id g11-v6mr24349520edr.299.1530614677476; Tue, 03 Jul 2018 03:44:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:b194:0:0:0:0:0 with HTTP; Tue, 3 Jul 2018 03:44:36 -0700 (PDT) In-Reply-To: References: <1530552423-32301-1-git-send-email-alejandro.lucero@netronome.com> <1530552423-32301-5-git-send-email-alejandro.lucero@netronome.com> From: Alejandro Lucero Date: Tue, 3 Jul 2018 11:44:36 +0100 Message-ID: To: "Burakov, Anatoly" Cc: dev , stable@dpdk.org, Maxime Coquelin Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-stable] [PATCH 4/6] mem: use address hint for mapping hugepages X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jul 2018 10:44:37 -0000 On Tue, Jul 3, 2018 at 10:17 AM, Burakov, Anatoly wrote: > On 02-Jul-18 6:27 PM, Alejandro Lucero wrote: > >> Linux kernel uses a really high address as starting address for >> serving mmaps calls. If there exists addressing limitations and >> IOVA mode is VA, this starting address is likely too high for >> those devices. However, it is possible to use a lower address in >> the process virtual address space as with 64 bits there is a lot >> of available space. >> >> This patch adds an address hint as starting address for 64 bits >> systems. >> >> Signed-off-by: Alejandro Lucero >> --- >> > > > > > long aligned_addr; >> - if (internal_config.base_virtaddr != 0) { >> - addr = (void*) (uintptr_t) (internal_config.base_virtaddr >> + >> - baseaddr_offset); >> - } >> - else addr = NULL; >> - >> RTE_LOG(DEBUG, EAL, "Ask a virtual area of 0x%zx bytes\n", *size); >> fd = open("/dev/zero", O_RDONLY); >> @@ -278,7 +289,22 @@ >> return NULL; >> } >> do { >> - addr = mmap(addr, >> + if (internal_config.base_virtaddr != 0) { >> + addr_hint = (void *) (uintptr_t) >> + (internal_config.base_virtaddr + >> + baseaddr_offset); >> + } >> +#ifdef RTE_ARCH_64 >> + else { >> + addr_hint = (void *) (uintptr_t) (baseaddr + >> + baseaddr_offset); >> + } >> +#else >> + else { >> + addr_hint = NULL; >> + } >> +#endif >> > > If my understanding is correct, calculations are all done on static > variables, only the result is assigned to addr_hint which is local. Can we > move this into a function and put these #ifdefs there, while keeping this > code clean? Ok. > > > + addr = mmap(addr_hint, >> (*size) + hugepage_sz, PROT_READ, >> #ifdef RTE_ARCH_PPC_64 >> MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, >> @@ -286,8 +312,14 @@ >> MAP_PRIVATE, >> #endif >> fd, 0); >> - if (addr == MAP_FAILED) >> + if (addr == MAP_FAILED) { >> + /* map failed. Let's try with less memory */ >> *size -= hugepage_sz; >> + } else if (addr_hint && addr != addr_hint) { >> + /* map not using hint. Let's try with another >> offset */ >> > > Comment is slightly misleading - "map not using hint" implies we are about > to map something without using hint. Suggested rewording: > > suggested address hint was not used, try with another offset What about "hint was not used. Try with another offset" ? By the way, I forgot to unmap the memory in this case. I will fix this in next version. > > > + addr = MAP_FAILED; >> + baseaddr_offset += 0x100000000; >> + } >> } while (addr == MAP_FAILED && *size > 0); >> if (addr == MAP_FAILED) { >> >> > > -- > Thanks, > Anatoly >