From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 371B6A0566; Tue, 10 Mar 2020 15:55:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D8681BF7F; Tue, 10 Mar 2020 15:55:54 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id A96582BE6 for ; Tue, 10 Mar 2020 15:55:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583852152; 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=/7I2ecXd3rkHPFsEvPhTARuqatFygW2pJyqOgYGVDaM=; b=TU+AhBdQ3IzZWdu3KbP7OtVKXp7wpifwLz6S/SGqzv2zYxj0xI329lfFcCUk6M+NnKaMA7 YBWxnsvUAqs012IIOrcfAgo7Pxz/RdE/jlieiCafuk0gX4sKcKvIvlnlZSL+h/FlEH6Oq+ 3M3evlulbttZRmuS2sN6cSwijo0uHhA= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-8IAIljkFOd2SgyPHxvoebA-1; Tue, 10 Mar 2020 10:55:48 -0400 X-MC-Unique: 8IAIljkFOd2SgyPHxvoebA-1 Received: by mail-vk1-f198.google.com with SMTP id v24so138559vkn.4 for ; Tue, 10 Mar 2020 07:55:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5POBZI8xHmy9AhKU5x3NUHa7YnYmcm2H9FxmzgHBDLo=; b=YaNIfIAvHwMIR7UFFEz4HknQLzTlB0bHNClM2WrIfmpoqAV0gP195o0IFdhPw4dVU2 j9s5gM/heJ0nBpivGVRgqBZ3M5jUB8bkmWLwa/O+oWHKigpUfMTTJ0X4x0KMPaHApN0Q aunL3yIElIifaIOMkr9sv60M8J6jU1rnZ/hKejFlA7xMokcTW5KaCOBCWUivfAm6Q13t Kn2Cl3LdBE3rP445q/u1Bzr2Bhg7IvJJGFi0okM5lXf31YYY8S3os5hr+AFSZ5NJvsZu Y2GhUnVdjO9cXR+dixxL+T4fLoHV/D7zc1u5LH+GsW/DQDpanbVdTORUicfm8wodzxsy XXFA== X-Gm-Message-State: ANhLgQ3eaMxrRMszTSslct2OWTiSAVC0dE4ESzpsJAH11VhVIO+S8nm8 pN8yJrMW1n/IKHXk4i/xOs3YlCpwDGyu+n6hLT5aqtEElxtrrXzRaqG1wVwW6NTNRv98nPaYTZi aZ/9V1DL4NvpNmqUOwSU= X-Received: by 2002:a67:643:: with SMTP id 64mr13882191vsg.180.1583852148251; Tue, 10 Mar 2020 07:55:48 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuxc8irouM5Okqa1VTf/7aJaqzOzeD89m7WqAxLqj4mymu3+e9YH+BZdTxpfsW4/QE/GKSk7nObw2nongn5IuE= X-Received: by 2002:a67:643:: with SMTP id 64mr13882167vsg.180.1583852147906; Tue, 10 Mar 2020 07:55:47 -0700 (PDT) MIME-Version: 1.0 References: <20200306144844.27255-1-david.marchand@redhat.com> <3393023e-4596-5f85-0b3d-b603b6394bf8@intel.com> In-Reply-To: <3393023e-4596-5f85-0b3d-b603b6394bf8@intel.com> From: David Marchand Date: Tue, 10 Mar 2020 15:55:36 +0100 Message-ID: To: Ferruh Yigit Cc: dev , Eelco Chaudron , Aaron Conole , Maxime Coquelin , "Burakov, Anatoly" , Wenzhuo Lu , Jingjing Wu , Bernard Iremonger X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [RFC PATCH] app/testpmd: only lock text pages 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" On Tue, Mar 10, 2020 at 3:49 PM Ferruh Yigit wrote= : > > On 3/6/2020 2:48 PM, David Marchand wrote: > > Since 18.05 and the memory subsystem rework, EAL reserves some big > > (unused) mappings. > > > > In testpmd, we have been locking all pages to avoid page faults during > > benchmark/performance regression tests [1]. > > However, asking for locking all the pages triggers issues on FreeBSD [2= ] > > and becomes really heavy in some Linux configurations (see [3], [4]). > > > > This patch changes the behavior so that testpmd only lock pages > > containing .text by default. > > > > 1: https://git.dpdk.org/dpdk/commit/?id=3D1c036b16c284 > > 2: https://git.dpdk.org/dpdk/commit/?id=3Dfb7b8b32cd95 > > 3: https://bugzilla.redhat.com/show_bug.cgi?id=3D1786923 > > 4: http://mails.dpdk.org/archives/dev/2020-February/158477.html > > > > Signed-off-by: David Marchand > > <...> > > > @@ -3455,6 +3456,42 @@ signal_handler(int signum) > > } > > } > > > > +static void > > +lock_pages(const void *_addr, size_t _len, const char *prefix) > > +{ > > + const void *addr; > > + size_t pagesize; > > + size_t len; > > + > > + /* While Linux does not care, FreeBSD mlock expects page aligned > > + * address (according to the man). > > + */ > > + pagesize =3D sysconf(_SC_PAGESIZE); > > + addr =3D RTE_PTR_ALIGN_FLOOR(_addr, pagesize); > > + len =3D _len + ((uintptr_t)_addr & (pagesize - 1)); > > + if (mlock(addr, len)) { > > + TESTPMD_LOG(NOTICE, "%s: mlock %p (0x%zx) aligned to %p (= 0x%zx) failed with error \"%s\"\n", > > + prefix, _addr, _len, addr, len, strerror(errno)); > > + } > > +} > > + > > +static int > > +lock_text_cb(struct dl_phdr_info *info, __rte_unused size_t size, > > + __rte_unused void *data) > > +{ > > + int i; > > + > > + for (i =3D 0; i < info->dlpi_phnum; i++) { > > + void *addr; > > + > > + if (info->dlpi_phdr[i].p_memsz =3D=3D 0) > > + continue; > > + addr =3D (void *)(info->dlpi_addr + info->dlpi_phdr[i].p_= vaddr); > > + lock_pages(addr, info->dlpi_phdr[i].p_memsz, info->dlpi_n= ame); > > + } > > + return 0; > > +} > > +1 to the idea, testpmd initialization was taking too lock without > '--no-mlockall', but this code looks complex for the application level. > > We can do this for testpmd but does all applications need to do something > similar? If so can we have a solution on eal level instead? I submitted a patch on the EAL side. This makes mlockall way lighter, since it skips pages marked with PROT_NONE= . http://patchwork.dpdk.org/patch/66469/ --=20 David Marchand