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 7C125A0093; Mon, 18 May 2020 02:17:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5A5111D536; Mon, 18 May 2020 02:17:08 +0200 (CEST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id A6EDC1D43F for ; Mon, 18 May 2020 02:17:06 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id 202so6472454lfe.5 for ; Sun, 17 May 2020 17:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uq3L8Z0IbXVC0kiXt0hSWN6PwdUwf6D43sfv+GS7874=; b=Jxl0eNnb053PthzSoBfwPaGn1mNBBi3AdY9gD8xWi9PtInrtROU52rCh6BOPsJzRSQ Dx1BqE7GxX6SVneYT1gy7oqsbxxk3D8FRRuQnuIkDgEXLN1WViGj+XV5a2ddhoCygb1P kWN8hwrCaCy4SBcycH2/0J9NJIVan2fCd8yozXFZTqqjkhPWJ1Qcz2lUb9FPVH0Y+dMl g9K+WsyizmOO6GYmfJNMzGgLD1nCrBJ97gxKuf8ujJjwApgUypN8hGAIg5k/DaauOow0 lfNWxqIXz6OkqHjcVyx9ZFxQ03E0hNGYb0qELlftnHt3+2CmJq84TmjgBeYSTgZ0jtn7 FqiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uq3L8Z0IbXVC0kiXt0hSWN6PwdUwf6D43sfv+GS7874=; b=k8SPAzmDRN10QnBRwggMDxTtvGiIYseOhkgVgINiiBfACzb3RJEnMuO1ArgOdN/5II RqI0S6FZG+dlgr7mQASP6JIDlhDU9El9SXtqxk+jReFlf/EkRmn2sZKP8Fmd+PqQrBxg 4rCWxBfG5dfFyWxiazKvy+kQ6ChCBY42oc7s1OQWyVaLprRTTSlXYpP+ulehUlCKybzS eEyVbNwkQHihx6l+vrIhgjwc8U83rF7koobdtHh2kHfazwWXKguQ4reLaffsZF+pVRhf WkJAUFGxr9t9r1m+fFE6AUJxJ6+nugKiXUtaPsaTbazmfQVZ4f/eVe1mvMzEvj4WSX8w j88Q== X-Gm-Message-State: AOAM531nChI3iaHcBpEmlg0YhChamyzZQlJFrWlIxllpRN3jJlj1wwfy aFVk5CDRKPuYcLgpQ6qsRBI= X-Google-Smtp-Source: ABdhPJzVWYHsl3vtzgbOtdOxFaOEiV1xYxNgd0Gk0pCeSvRg//GflFj2uNwgU961MpgAt8M6nOd9kg== X-Received: by 2002:ac2:55b2:: with SMTP id y18mr2561668lfg.55.1589761026056; Sun, 17 May 2020 17:17:06 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id v17sm4778520ljd.76.2020.05.17.17.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 17:17:05 -0700 (PDT) Date: Mon, 18 May 2020 03:17:04 +0300 From: Dmitry Kozlyuk To: Fady Bader Cc: "dev@dpdk.org" , "Dmitry Malloy (MESHCHANINOV)" , Narcisa Ana Maria Vasile , Tal Shnaiderman , Thomas Monjalon , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon , John McNamara , Marko Kovacevic , Anatoly Burakov Message-ID: <20200518031704.0859171a@sovereign> In-Reply-To: References: <20200410164342.1194634-1-dmitry.kozliuk@gmail.com> <20200428235015.2820677-1-dmitry.kozliuk@gmail.com> <20200428235015.2820677-9-dmitry.kozliuk@gmail.com> <20200513114248.6183d14f@sovereign> <20200513123844.618b79f2@sovereign> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 8/8] eal/windows: implement basic memory management 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 Wed, 13 May 2020 12:25:10 +0000 Fady Bader wrote: [snip] > > > > I meant the code of the application that calls > > rte_mempool_create(). Or is it one of the DPDK test applications? > > I got it from dpdk\app\test\test_mempool > > Line 496: > /* create a mempool (without cache) */ > mp_nocache = rte_mempool_create("test_nocache", MEMPOOL_SIZE, > MEMPOOL_ELT_SIZE, 0, 0, > NULL, NULL, > my_obj_init, NULL, > SOCKET_ID_ANY, 0); > For building this code you must have enabled librte_ring, librte_mempool, and drivers/mempool, and I assume you build test code without librte_cmdline somehow. This are nontrivial changes, so I can't be sure to reproduce them exactly. Can you please share a complete patch? Meanwhile, I observe a similar issue where rte_mempool_create() fails to allocate memory and hangs when compiled with Clang, succeeds with native MinGW, but still hangs with cross MinGW. I'm investigating it. Testing patch follows, the snippet added is in examples/helloworld/main. --- diff --git a/config/meson.build b/config/meson.build index b6d84687f..018726f75 100644 --- a/config/meson.build +++ b/config/meson.build @@ -117,7 +117,7 @@ if not is_windows endif # use pthreads if available for the platform -if not is_ms_linker +if cc.find_library('pthread', required: false).found() add_project_link_arguments('-pthread', language: 'c') dpdk_extra_ldflags += '-pthread' endif diff --git a/drivers/meson.build b/drivers/meson.build index dc293b270..ee565bc19 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -2,8 +2,8 @@ # Copyright(c) 2017-2019 Intel Corporation if is_windows - subdir_done() -endif + dpdk_driver_classes = ['mempool'] +else # Defines the order in which the drivers are buit. dpdk_driver_classes = ['common', @@ -16,7 +16,7 @@ dpdk_driver_classes = ['common', 'vdpa', # depends on common, bus and mempool. 'event', # depends on common, bus, mempool and net. 'baseband'] # depends on common and bus. - +endif disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'), ).stdout().split() @@ -78,13 +78,13 @@ foreach class:dpdk_driver_classes shared_deps = ext_deps static_deps = ext_deps foreach d:deps - if not is_variable('shared_rte_' + d) + if not is_variable('static_rte_' + d) build = false reason = 'Missing internal dependency, "@0@"'.format(d) message('Disabling @1@ [@2@]: missing internal dependency "@0@"' .format(d, name, 'drivers/' + drv_path)) else - shared_deps += [get_variable('shared_rte_' + d)] + # shared_deps += [get_variable('shared_rte_' + d)] static_deps += [get_variable('static_rte_' + d)] endif endforeach @@ -110,6 +110,7 @@ foreach class:dpdk_driver_classes dpdk_extra_ldflags += pkgconfig_extra_libs + if host_machine.system() != 'windows' # generate pmdinfo sources by building a temporary # lib and then running pmdinfogen on the contents of # that lib. The final lib reuses the object files and @@ -126,7 +127,7 @@ foreach class:dpdk_driver_classes '@OUTPUT@', pmdinfogen], output: out_filename, depends: [pmdinfogen, tmp_lib]) - + endif version_map = '@0@/@1@/@2@_version.map'.format( meson.current_source_dir(), drv_path, lib_name) @@ -178,31 +179,31 @@ foreach class:dpdk_driver_classes output: lib_name + '.sym_chk') endif - shared_lib = shared_library(lib_name, - sources, - objects: objs, - include_directories: includes, - dependencies: shared_deps, - c_args: cflags, - link_args: lk_args, - link_depends: lk_deps, - version: lib_version, - soversion: so_version, - install: true, - install_dir: driver_install_path) - - # create a dependency object and add it to the global dictionary so - # testpmd or other built-in apps can find it if necessary - shared_dep = declare_dependency(link_with: shared_lib, - include_directories: includes, - dependencies: shared_deps) + # shared_lib = shared_library(lib_name, + # sources, + # objects: objs, + # include_directories: includes, + # dependencies: shared_deps, + # c_args: cflags, + # link_args: lk_args, + # link_depends: lk_deps, + # version: lib_version, + # soversion: so_version, + # install: true, + # install_dir: driver_install_path) + + # # create a dependency object and add it to the global dictionary so + # # testpmd or other built-in apps can find it if necessary + # shared_dep = declare_dependency(link_with: shared_lib, + # include_directories: includes, + # dependencies: shared_deps) static_dep = declare_dependency(link_with: static_lib, include_directories: includes, dependencies: static_deps) dpdk_drivers += static_lib - set_variable('shared_@0@'.format(lib_name), shared_dep) + # set_variable('shared_@0@'.format(lib_name), shared_dep) set_variable('static_@0@'.format(lib_name), static_dep) dependency_name = ''.join(lib_name.split('rte_')) message('drivers/@0@: Defining dependency "@1@"'.format( diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c index 968045f1b..cf895c840 100644 --- a/examples/helloworld/main.c +++ b/examples/helloworld/main.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include static int lcore_hello(__rte_unused void *arg) @@ -29,11 +31,30 @@ main(int argc, char **argv) { int ret; unsigned lcore_id; + struct rte_mempool *pool; + + rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG); ret = rte_eal_init(argc, argv); if (ret < 0) rte_panic("Cannot init EAL\n"); + pool = rte_mempool_create( + "test_mempool", + (1 << 18) - 1, + (1 << 12), + 1 << 9, + 0, + NULL, NULL, NULL, NULL, + SOCKET_ID_ANY, + 0); + if (!pool) { + RTE_LOG(ERR, USER1, "cannot create mempool: %d\n", rte_errno); + return EXIT_FAILURE; + } + + rte_mempool_free(pool); + /* call lcore_hello() on every slave lcore */ RTE_LCORE_FOREACH_SLAVE(lcore_id) { rte_eal_remote_launch(lcore_hello, NULL, lcore_id); diff --git a/examples/meson.build b/examples/meson.build index 3b540012f..407322dec 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -83,7 +83,7 @@ foreach example: examples includes = [include_directories(example)] deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] if is_windows - deps = ['eal'] # only supported lib on Windows currently + deps = ['eal', 'mempool', 'ring'] # only supported lib on Windows currently endif subdir(example) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 0bde995b5..017eebba5 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -148,7 +147,7 @@ get_min_page_size(int socket_id) rte_memseg_list_walk(find_min_pagesz, &wa); - return wa.min == SIZE_MAX ? (size_t) getpagesize() : wa.min; + return wa.min == SIZE_MAX ? (size_t) rte_get_page_size() : wa.min; } @@ -526,7 +525,7 @@ rte_mempool_get_page_size(struct rte_mempool *mp, size_t *pg_sz) else if (rte_eal_has_hugepages() || alloc_in_ext_mem) *pg_sz = get_min_page_size(mp->socket_id); else - *pg_sz = getpagesize(); + *pg_sz = rte_get_page_size(); rte_mempool_trace_get_page_size(mp, *pg_sz); return 0; @@ -686,7 +685,7 @@ get_anon_size(const struct rte_mempool *mp) size_t min_chunk_size; size_t align; - pg_sz = getpagesize(); + pg_sz = rte_get_page_size(); pg_shift = rte_bsf32(pg_sz); size = rte_mempool_ops_calc_mem_size(mp, mp->size, pg_shift, &min_chunk_size, &align); @@ -710,7 +709,7 @@ rte_mempool_memchunk_anon_free(struct rte_mempool_memhdr *memhdr, if (size < 0) return; - munmap(opaque, size); + rte_mem_unmap(opaque, size); } /* populate the mempool with an anonymous mapping */ @@ -740,20 +739,20 @@ rte_mempool_populate_anon(struct rte_mempool *mp) } /* get chunk of virtually continuous memory */ - addr = mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_ANONYMOUS, -1, 0); - if (addr == MAP_FAILED) { - rte_errno = errno; + addr = rte_mem_map(NULL, size, RTE_PROT_READ | RTE_PROT_WRITE, + RTE_MAP_SHARED | RTE_MAP_ANONYMOUS, -1, 0); + if (addr == NULL) { return 0; } /* can't use MMAP_LOCKED, it does not exist on BSD */ - if (mlock(addr, size) < 0) { - rte_errno = errno; - munmap(addr, size); + if (rte_mem_lock(addr, size) < 0) { + ret = rte_errno; + rte_mem_unmap(addr, size); + rte_errno = ret; return 0; } - ret = rte_mempool_populate_virt(mp, addr, size, getpagesize(), + ret = rte_mempool_populate_virt(mp, addr, size, rte_get_page_size(), rte_mempool_memchunk_anon_free, addr); if (ret == 0) /* should not happen */ ret = -ENOBUFS; diff --git a/lib/meson.build b/lib/meson.build index d190d84ef..77da5216f 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -36,7 +36,12 @@ libraries = [ 'flow_classify', 'bpf', 'graph', 'node'] if is_windows - libraries = ['kvargs','eal'] # only supported libraries for windows + libraries = [ + 'kvargs', + 'eal', + 'ring', + 'mempool', + ] endif default_cflags = machine_args @@ -56,6 +61,7 @@ foreach l:libraries use_function_versioning = false sources = [] headers = [] + headers_compat = {} includes = [] cflags = default_cflags objs = [] # other object files to link against, used e.g. for @@ -77,11 +83,11 @@ foreach l:libraries shared_deps = ext_deps static_deps = ext_deps foreach d:deps - if not is_variable('shared_rte_' + d) + if not is_variable('static_rte_' + d) error('Missing internal dependency "@0@" for @1@ [@2@]' .format(d, name, 'lib/' + dir_name)) endif - shared_deps += [get_variable('shared_rte_' + d)] + # shared_deps += [get_variable('shared_rte_' + d)] static_deps += [get_variable('static_rte_' + d)] endforeach endif @@ -94,6 +100,12 @@ foreach l:libraries dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1) install_headers(headers) + if is_windows and (name == 'eal') + foreach dir, header : headers_compat + install_headers(header, subdir: dir) + endforeach + endif + libname = 'rte_' + name includes += include_directories(dir_name) @@ -171,29 +183,29 @@ foreach l:libraries output: name + '.sym_chk') endif - shared_lib = shared_library(libname, - sources, - objects: objs, - c_args: cflags, - dependencies: shared_deps, - include_directories: includes, - link_args: lk_args, - link_depends: lk_deps, - version: lib_version, - soversion: so_version, - install: true) - shared_dep = declare_dependency(link_with: shared_lib, - include_directories: includes, - dependencies: shared_deps) - - dpdk_libraries = [shared_lib] + dpdk_libraries + # shared_lib = shared_library(libname, + # sources, + # objects: objs, + # c_args: cflags, + # dependencies: shared_deps, + # include_directories: includes, + # link_args: lk_args, + # link_depends: lk_deps, + # version: lib_version, + # soversion: so_version, + # install: true) + # shared_dep = declare_dependency(link_with: shared_lib, + # include_directories: includes, + # dependencies: shared_deps) + + # dpdk_libraries = [shared_lib] + dpdk_libraries dpdk_static_libraries = [static_lib] + dpdk_static_libraries if libname == 'rte_node' dpdk_graph_nodes = [static_lib] endif endif # sources.length() > 0 - set_variable('shared_rte_' + name, shared_dep) + # set_variable('shared_rte_' + name, shared_dep) set_variable('static_rte_' + name, static_dep) message('lib/@0@: Defining dependency "@1@"'.format( dir_name, name)) -- Dmitry Kozlyuk