stgt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: FUJITA Tomonori <fujita.tomonori@gmail.com>
To: andreas@canonical.com
Cc: stgt@vger.kernel.org, sergio.durigan@canonical.com
Subject: Re: tgt on arm64 and USE_SIGNALFD
Date: Thu, 15 Feb 2024 09:26:33 +0900 (JST)	[thread overview]
Message-ID: <20240215.092633.419504594582279426.fujita.tomonori@gmail.com> (raw)
In-Reply-To: <CANYNYEGR=8vV4JFicnWZ=MDwMc9zjPxHJ8tNj=zSner30UpeXg@mail.gmail.com>

Hi,

On Wed, 14 Feb 2024 17:14:42 -0300
Andreas Hasenack <andreas@canonical.com> 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?


diff --git a/usr/bs.c b/usr/bs.c
index 8171a32..8da5a9b 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, 0);
 	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).

  reply	other threads:[~2024-02-15  0:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 20:14 tgt on arm64 and USE_SIGNALFD Andreas Hasenack
2024-02-15  0:26 ` FUJITA Tomonori [this message]
2024-02-15 13:39   ` Andreas Hasenack
2024-02-16 10:01     ` FUJITA Tomonori

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=20240215.092633.419504594582279426.fujita.tomonori@gmail.com \
    --to=fujita.tomonori@gmail.com \
    --cc=andreas@canonical.com \
    --cc=sergio.durigan@canonical.com \
    --cc=stgt@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).