user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/2] syscall debloating
@ 2022-12-23 12:51 Eric Wong
  2022-12-23 12:51 ` [PATCH 1/2] syscall: get rid of epoll_defined() sub Eric Wong
  2022-12-23 12:51 ` [PATCH 2/2] syscall: drop syscall.ph support Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2022-12-23 12:51 UTC (permalink / raw)
  To: meta

syscall.ph has the potential to be dangerously wrong, so I'm
avoiding it.

Preparing to finally add inotify syscall numbers support so I
can get rid of Linux::Inotify2 and the common::sense package it
pulls in.

I'm also tempted to drop some abandoned architectures (e.g.  IA-64)
since there's no cfarm machines to test with.

Eric Wong (2):
  syscall: get rid of epoll_defined() sub
  syscall: drop syscall.ph support

 lib/PublicInbox/DS.pm      |  2 +-
 lib/PublicInbox/Syscall.pm | 36 ++++++------------------------------
 2 files changed, 7 insertions(+), 31 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] syscall: get rid of epoll_defined() sub
  2022-12-23 12:51 [PATCH 0/2] syscall debloating Eric Wong
@ 2022-12-23 12:51 ` Eric Wong
  2022-12-23 12:51 ` [PATCH 2/2] syscall: drop syscall.ph support Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-12-23 12:51 UTC (permalink / raw)
  To: meta

We can just check defined() on the `our' var itself and
save the process several kilobytes of memory.
---
 lib/PublicInbox/DS.pm      | 2 +-
 lib/PublicInbox/Syscall.pm | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 26840662..a6c43b22 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -126,7 +126,7 @@ sub add_uniq_timer { # ($name, $secs, $coderef, @args) = @_;
 
 # caller sets return value to $Epoll
 sub _InitPoller () {
-	if (PublicInbox::Syscall::epoll_defined())  {
+	if (defined $PublicInbox::Syscall::SYS_epoll_create)  {
 		my $fd = epoll_create();
 		die "epoll_create: $!" if $fd < 0;
 		open($ep_io, '+<&=', $fd) or return;
diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm
index ee4c6107..bda9bbb0 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -285,8 +285,6 @@ if ($^O eq "linux") {
 # epoll functions
 ############################################################################
 
-sub epoll_defined { $SYS_epoll_create ? 1 : 0; }
-
 sub epoll_create {
 	syscall($SYS_epoll_create, $no_deprecated ? 0 : 100);
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] syscall: drop syscall.ph support
  2022-12-23 12:51 [PATCH 0/2] syscall debloating Eric Wong
  2022-12-23 12:51 ` [PATCH 1/2] syscall: get rid of epoll_defined() sub Eric Wong
@ 2022-12-23 12:51 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-12-23 12:51 UTC (permalink / raw)
  To: meta

h2ph-generated *.ph files are often wrong or incomplete and IME
they cause more problems than they solve.  Furthermore, we need
knowledge of struct layouts which h2ph-generated files can't get
us.  So trim down some bloat and leave a note for porters.
---
 lib/PublicInbox/Syscall.pm | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm
index bda9bbb0..cecb1247 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -60,21 +60,6 @@ use constant {
 };
 
 my @BYTES_4_hole = BYTES_4_hole ? (0) : ();
-our $loaded_syscall = 0;
-
-sub _load_syscall {
-    # props to Gaal for this!
-    return if $loaded_syscall++;
-    my $clean = sub {
-        delete @INC{qw<syscall.ph asm/unistd.ph bits/syscall.ph
-                        _h2ph_pre.ph sys/syscall.ph>};
-    };
-    $clean->(); # don't trust modules before us
-    my $rv = eval { require 'syscall.ph'; 1 } || eval { require 'sys/syscall.ph'; 1 };
-    $clean->(); # don't require modules after us trust us
-    $rv;
-}
-
 
 our (
      $SYS_epoll_create,
@@ -256,19 +241,12 @@ if ($^O eq "linux") {
 	$FS_IOC_SETFLAGS = 0x80046602;
 	$SIGNUM{WINCH} = 20;
     } else {
-        # as a last resort, try using the *.ph files which may not
-        # exist or may be wrong
-        _load_syscall();
-        $SYS_epoll_create = eval { &SYS_epoll_create; } || 0;
-        $SYS_epoll_ctl    = eval { &SYS_epoll_ctl;    } || 0;
-        $SYS_epoll_wait   = eval { &SYS_epoll_wait;   } || 0;
-
-	# Note: do NOT add new syscalls to depend on *.ph, here.
-	# Better to miss syscalls (so we can fallback to IO::Poll)
-	# than to use wrong ones, since the names are not stable
-	# (at least not on FreeBSD), if the actual numbers are.
+        warn <<EOM;
+machine=$machine ptrsize=$Config{ptrsize} has no syscall definitions
+git clone https://80x24.org/public-inbox.git and
+Send the output of ./devel/syscall-list to meta\@public-inbox.org
+EOM
     }
-
     if ($u64_mod_8) {
         *epoll_wait = \&epoll_wait_mod8;
         *epoll_ctl = \&epoll_ctl_mod8;
@@ -279,7 +257,7 @@ if ($^O eq "linux") {
 }
 # use Inline::C for *BSD-only or general POSIX stuff.
 # Linux guarantees stable syscall numbering, BSDs only offer a stable libc
-# use scripts/syscall-list on Linux to detect new syscall numbers
+# use devel/syscall-list on Linux to detect new syscall numbers
 
 ############################################################################
 # epoll functions

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-23 12:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 12:51 [PATCH 0/2] syscall debloating Eric Wong
2022-12-23 12:51 ` [PATCH 1/2] syscall: get rid of epoll_defined() sub Eric Wong
2022-12-23 12:51 ` [PATCH 2/2] syscall: drop syscall.ph support Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).