Message ID | 1432571266-25840-1-git-send-email-adrien.mazarguil@6wind.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 9BF69B6AB; Mon, 25 May 2015 18:27:57 +0200 (CEST) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by dpdk.org (Postfix) with ESMTP id D05ABB3D6 for <dev@dpdk.org>; Mon, 25 May 2015 18:27:55 +0200 (CEST) Received: by wicmc15 with SMTP id mc15so44219956wic.1 for <dev@dpdk.org>; Mon, 25 May 2015 09:27:55 -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:subject:date:message-id; bh=AwUa60xN/8d/6W+knhQmmJagebFCt+kfi8fcwSTdSbQ=; b=UXHNCse5kYi9coILDoUhzpFcMXtcwbK5tgEPAG1jE5TuManil4XKCmpcJ+wvOi+qXU V2fjvKMl7SVxsqLLhn4ZB9q+6MkjbMa4YBOEn1D9vk+ioc6sO/VLJmQy3YQQn1NffISV YG0jL/xBLpKqCXHphux5gDiciJE3lMULLGQ/zZB7yvK+pXjfdfKr2TD2tJPd/6rtkRwD mtrZZzQNSh929ELOhjcUfWAiNkOIwtFTudlWjUsMwGVOvXYU59sh9DeahIWDFxdozPw1 iX7K2r7LxEBSvP6EhkZosU7+5ffnNjjLB9ZVgUNkdQO6ksdAyVdO3rp3SK0/pevXyhha 8jeQ== X-Gm-Message-State: ALoCoQlUENnIiw68KoHgzZU5A8CnXcf2mm0xJbr8fFu2xdssUtQ4YWDDytS6svEerNDKBE2sAveJ X-Received: by 10.180.14.193 with SMTP id r1mr32341629wic.47.1432571275710; Mon, 25 May 2015 09:27:55 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id w11sm16943094wjr.48.2015.05.25.09.27.54 for <dev@dpdk.org> (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 May 2015 09:27:54 -0700 (PDT) From: Adrien Mazarguil <adrien.mazarguil@6wind.com> To: dev@dpdk.org Date: Mon, 25 May 2015 18:27:45 +0200 Message-Id: <1432571266-25840-1-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 Subject: [dpdk-dev] [PATCH 1/2] mempool: fix returned value on 64 bit after counting objects X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Adrien Mazarguil
May 25, 2015, 4:27 p.m. UTC
rte_mempool_xmem_usage()'s return type is ssize_t which has the same
architecture-dependent width as size_t but is signed.
On 64-bit architectures, returning a negative uint32_t value without casting
to ssize_t first does not work as intended, the sign bit is lost and the
returned value is garbage.
This commit fixes an assertion failure in testpmd on 64 bit architectures
when combining --no-huge and --mp-anon outside of Xen Dom0:
PANIC in mempool_anon_create():
line 170 assert "elt_num == mp->size" failed
Fixes: 148f963fb532 ("xen: core library changes")
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_mempool/rte_mempool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
> -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil > Sent: Monday, May 25, 2015 5:28 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH 1/2] mempool: fix returned value on 64 bit after counting objects > > rte_mempool_xmem_usage()'s return type is ssize_t which has the same > architecture-dependent width as size_t but is signed. > > On 64-bit architectures, returning a negative uint32_t value without casting > to ssize_t first does not work as intended, the sign bit is lost and the > returned value is garbage. > > This commit fixes an assertion failure in testpmd on 64 bit architectures > when combining --no-huge and --mp-anon outside of Xen Dom0: > > PANIC in mempool_anon_create(): > line 170 assert "elt_num == mp->size" failed > > Fixes: 148f963fb532 ("xen: core library changes") > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > --- > lib/librte_mempool/rte_mempool.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index 01972ba..d1a02a2 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -361,7 +361,7 @@ rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t elt_sz, > if ((n = rte_mempool_obj_iter(vaddr, elt_num, elt_sz, 1, > paddr, pg_num, pg_shift, mempool_lelem_iter, > &uv)) != elt_num) { > - return (-n); > + return (-(ssize_t)n); > } > > uv = RTE_ALIGN_CEIL(uv, pg_sz); > -- Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com> > 2.1.0
2015-05-27 00:43, Ananyev, Konstantin: > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil > > rte_mempool_xmem_usage()'s return type is ssize_t which has the same > > architecture-dependent width as size_t but is signed. > > > > On 64-bit architectures, returning a negative uint32_t value without casting > > to ssize_t first does not work as intended, the sign bit is lost and the > > returned value is garbage. > > > > This commit fixes an assertion failure in testpmd on 64 bit architectures > > when combining --no-huge and --mp-anon outside of Xen Dom0: > > > > PANIC in mempool_anon_create(): > > line 170 assert "elt_num == mp->size" failed > > > > Fixes: 148f963fb532 ("xen: core library changes") > > > > Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> > > Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Applied, thanks
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 01972ba..d1a02a2 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -361,7 +361,7 @@ rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t elt_sz, if ((n = rte_mempool_obj_iter(vaddr, elt_num, elt_sz, 1, paddr, pg_num, pg_shift, mempool_lelem_iter, &uv)) != elt_num) { - return (-n); + return (-(ssize_t)n); } uv = RTE_ALIGN_CEIL(uv, pg_sz);