DPDK patches and discussions
 help / color / mirror / Atom feed
From: Natanael Copa <ncopa@alpinelinux.org>
To: dev@dpdk.org
Cc: Natanael Copa <ncopa@alpinelinux.org>
Subject: [dpdk-dev] [PATCH 15/15] eal/linux: use gettid(2) for debug message in sigbus_handler
Date: Mon, 11 Mar 2019 18:37:02 +0100	[thread overview]
Message-ID: <20190311173702.24471-16-ncopa@alpinelinux.org> (raw)
In-Reply-To: <20190311173702.24471-1-ncopa@alpinelinux.org>

There is no guarantee that pthread_self() returns the thread id or that
pthread_t is an integer. Use gettid(2) to get the kernel thread id
instead.

This fixes the following warning when building with musl libc:

../lib/librte_eal/linuxapp/eal/eal_dev.c: In function 'sigbus_handler':
../lib/librte_eal/linuxapp/eal/eal_dev.c:70:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   (int)pthread_self(), info->si_addr);
   ^

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---

This is not reallly a compile error, but the warning looked a bit scary, and
code looked wrong, so I fixed it.

 lib/librte_eal/linuxapp/eal/eal_dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_dev.c b/lib/librte_eal/linuxapp/eal/eal_dev.c
index 2830c8687..9ad6650cf 100644
--- a/lib/librte_eal/linuxapp/eal/eal_dev.c
+++ b/lib/librte_eal/linuxapp/eal/eal_dev.c
@@ -7,6 +7,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/socket.h>
+#include <sys/types.h>
 #include <linux/netlink.h>
 
 #include <rte_string_fns.h>
@@ -30,6 +31,11 @@ static bool hotplug_handle;
 #define EAL_UEV_MSG_LEN 4096
 #define EAL_UEV_MSG_ELEM_LEN 128
 
+#if !defined(__GLIBC__)
+#include <sys/syscall.h>
+#define gettid() syscall(SYS_gettid)
+#endif
+
 /*
  * spinlock for device hot-unplug failure handling. If it try to access bus or
  * device, such as handle sigbus on bus or handle memory failure for device
@@ -67,7 +73,7 @@ static void sigbus_handler(int signum, siginfo_t *info,
 	int ret;
 
 	RTE_LOG(DEBUG, EAL, "Thread[%d] catch SIGBUS, fault address:%p\n",
-		(int)pthread_self(), info->si_addr);
+		(int)gettid(), info->si_addr);
 
 	rte_spinlock_lock(&failure_handle_lock);
 	ret = rte_bus_sigbus_handler(info->si_addr);
-- 
2.21.0

  parent reply	other threads:[~2019-03-11 17:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 17:36 [dpdk-dev] [PATCH 00/15] Build fixes for musl libc Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 01/15] app/testpmd: replace uint with unsigned int Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 02/15] net/cxgbe: " Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc Natanael Copa
2019-03-12 10:16   ` [dpdk-dev] [PATCH v2 " Natanael Copa
2019-03-13 11:13     ` Ferruh Yigit
2019-03-13 17:08       ` Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 04/15] bus/pci: factor out various ifdefs in pci_uio_ioport_{read, write} Natanael Copa
2019-03-12 10:18   ` [dpdk-dev] [PATCH v2 " Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 05/15] bus/fslmc: fix compile error with musl libc Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 06/15] bus/fslmc: remove unused include of error.h Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 07/15] net/nfp: build fix for musl libc Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 08/15] app/test: include fcntl.h due to use of O_RDONLY Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 09/15] app/test: fix setting of -D_GNU_SOURCE with meson Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 10/15] bus/dpaa: use warn(3) instead of error(3) to improve portability Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 11/15] bus/dpaa: fix warning: "__WORDSIZE" is not defined, evaluates to 0 Natanael Copa
2019-03-11 17:36 ` [dpdk-dev] [PATCH 12/15] crypto/dpaa2_sec: build fix for musl libc Natanael Copa
2019-03-12 10:20   ` [dpdk-dev] [PATCH v2 " Natanael Copa
2019-03-11 17:37 ` [dpdk-dev] [PATCH 13/15] crypto/dpaa2_sec: simplify pr_{debug, err, warn} macros Natanael Copa
2019-03-11 17:37 ` [dpdk-dev] [PATCH 14/15] net/netvsc: fix compile warning for fcntl.h include Natanael Copa
2019-03-11 18:17   ` Stephen Hemminger
2019-03-11 17:37 ` Natanael Copa [this message]
2019-03-11 18:21   ` [dpdk-dev] [PATCH 15/15] eal/linux: use gettid(2) for debug message in sigbus_handler Stephen Hemminger
2019-03-12 10:22     ` [dpdk-dev] [PATCH v2 15/15] eal/linux: simplify " Natanael Copa
2019-03-13 11:45 ` [dpdk-dev] [PATCH 00/15] Build fixes for musl libc Sirvys, Andrius
2019-03-13 16:53   ` Natanael Copa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190311173702.24471-16-ncopa@alpinelinux.org \
    --to=ncopa@alpinelinux.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).