Re: tgt on arm64 and USE_SIGNALFD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 15 Feb 2024 10:39:43 -0300
Andreas Hasenack <andreas@xxxxxxxxxxxxx> wrote:

> Hello,
> 
> On Wed, Feb 14, 2024 at 9:26 PM FUJITA Tomonori
> <fujita.tomonori@xxxxxxxxx> wrote:
>>
>> Hi,
>>
>> On Wed, 14 Feb 2024 17:14:42 -0300
>> Andreas Hasenack <andreas@xxxxxxxxxxxxx> wrote:
>>
>> > is USE_SIGNALFD meant to be supported on arm64? The check in
>> > bs/util.h[1] is looking for __NR_signalfd, but arm64 only has the
>> > newer __NR_signalfd4[2]:
>> >
>> > #if defined(__NR_signalfd) && defined(USE_SIGNALFD)
>> > ...
>> > #else
>> > #define __signalfd(fd, mask, flags) (-1)
>> > struct signalfd_siginfo {
>> > };
>> > #endif
>>
>> I think that we don't need this hack anymore (it was necessary when
>> the signalfd feature was introduced). I've not tested on arm64 but
>> I guess that simply using sys/signalfd.h works like the following?
> 
> Yes, thank you, that worked just fine!

Thanks!

I've added O_NONBLOCK flag and merged the following:

-
From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
Date: Fri, 16 Feb 2024 09:35:38 +0900
Subject: [PATCH] fix arm64 compile breakage

This removes the hack for signalfd, which uses __NR_signalfd to check
whether a system supports signalfd or not. arm64 uses _NR_signalfd4 so
tgt wrongly assumes that arm64 doesn't support signalfd.

This hack was introduced when some distributions doesn't have a header
file for signalfd. Now all the distributions should have so we can
simply use sys/signalfd.h

Reported-by: Andreas Hasenack <andreas@xxxxxxxxxxxxx>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
---
 usr/bs.c   |  2 +-
 usr/util.h | 43 +++----------------------------------------
 2 files changed, 4 insertions(+), 41 deletions(-)

diff --git a/usr/bs.c b/usr/bs.c
index 8171a32..21547d5 100644
--- a/usr/bs.c
+++ b/usr/bs.c
@@ -311,7 +311,7 @@ static int bs_init_signalfd(void)
 	sigaddset(&mask, SIGUSR2);
 	sigprocmask(SIG_BLOCK, &mask, NULL);
 
-	sig_fd = __signalfd(-1, &mask, 0);
+	sig_fd = signalfd(-1, &mask, O_NONBLOCK);
 	if (sig_fd < 0)
 		return 1;
 
diff --git a/usr/util.h b/usr/util.h
index c709f9b..8aef6ab 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -14,11 +14,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <linux/fs.h>
 #include <linux/types.h>
 #include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <sys/types.h>
+#include <sys/signalfd.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 #include "be_byteshift.h"
 
@@ -103,44 +104,6 @@ static inline int between(uint32_t seq1, uint32_t seq2, uint32_t seq3)
 
 extern unsigned long pagesize, pageshift;
 
-#if defined(__NR_signalfd) && defined(USE_SIGNALFD)
-
-/*
- * workaround for broken linux/signalfd.h including
- * usr/include/linux/fcntl.h
- */
-#define _LINUX_FCNTL_H
-
-#include <linux/signalfd.h>
-
-static inline int __signalfd(int fd, const sigset_t *mask, int flags)
-{
-	int fd2, ret;
-
-	fd2 = syscall(__NR_signalfd, fd, mask, _NSIG / 8);
-	if (fd2 < 0)
-		return fd2;
-
-	ret = fcntl(fd2, F_GETFL);
-	if (ret < 0) {
-		close(fd2);
-		return -1;
-	}
-
-	ret = fcntl(fd2, F_SETFL, ret | O_NONBLOCK);
-	if (ret < 0) {
-		close(fd2);
-		return -1;
-	}
-
-	return fd2;
-}
-#else
-#define __signalfd(fd, mask, flags) (-1)
-struct signalfd_siginfo {
-};
-#endif
-
 /* convert string to integer, check for validity of the string numeric format
  * and the natural boundaries of the integer value type (first get a 64-bit
  * value and check that it fits the range of the destination integer).
-- 
2.34.1





[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux