Skip to content

Add NetBSD support in htop(1)#603

Merged
BenBE merged 20 commits intohtop-dev:masterfrom
fraggerfox:netbsd-no-procfs
Jun 26, 2021
Merged

Add NetBSD support in htop(1)#603
BenBE merged 20 commits intohtop-dev:masterfrom
fraggerfox:netbsd-no-procfs

Conversation

@fraggerfox
Copy link
Copy Markdown
Contributor

This implementation makes NetBSD use htop(1) without the need of mount_procfs(8).

The implementation has been copied over and modified from the OpenBSD implementation in htop(1).

Make NetBSD no longer masquerade as Linux.

Comment thread netbsd/Platform.c Outdated
Copy link
Copy Markdown
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your implementation to support NetBSD natively for htop.

As there's one bigger change upcoming that affects all current platforms (and thus also all upcoming ones, I took the liberty to remark on the locations where this potentially requires changes to your PR.

Comment thread netbsd/Platform.c Outdated
Comment thread netbsd/NetBSDProcess.c
Comment thread netbsd/NetBSDProcess.c Outdated
Comment thread netbsd/NetBSDProcess.h Outdated
Comment thread netbsd/NetBSDProcess.h Outdated
Comment thread netbsd/NetBSDProcessList.c Outdated
Comment thread netbsd/Platform.c Outdated
Comment thread netbsd/Platform.c Outdated
Comment thread netbsd/Platform.c Outdated
Comment thread netbsd/NetBSDProcessList.c
@BenBE BenBE added BSD 🐡 Issues related to *BSD needs-discussion 🤔 Changes need to be discussed and require consent feature request Completely new feature requested labels Apr 17, 2021
@fraggerfox
Copy link
Copy Markdown
Contributor Author

@BenBE Thank you for going through the code and giving a detailed feedback, let me go through each of them and try to resolve it.

@BenBE
Copy link
Copy Markdown
Member

BenBE commented Apr 17, 2021

@fraggerfox Another point that came up in discussions in the team was the issue of long-term support of the platform. Would you be willing to help mid-/long-term to keep the NetBSD port up-to-date and aid in debugging issues specific to this platform? Or do you know someone who would be willing to take up on this task?

@fraggerfox
Copy link
Copy Markdown
Contributor Author

@fraggerfox Another point that came up in discussions in the team was the issue of long-term support of the platform. Would you be willing to help mid-/long-term to keep the NetBSD port up-to-date and aid in debugging issues specific to this platform? Or do you know someone who would be willing to take up on this task?

Yes, I do not mind putting in my time mid-/long-term to support the NetBSD port. Hopefully, I should have more time to commit to maintenance in the coming months. In case of issues / interruptions I can notify the team ahead of time.

@alarixnia
Copy link
Copy Markdown
Contributor

In general I think there's lots of interest in this, and I'm also able to help. We're also in #netbsd-code on freenode and can answer questions about APIs and offer testing.

@fraggerfox fraggerfox requested a review from BenBE April 24, 2021 04:49
Copy link
Copy Markdown
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM.

Comment thread netbsd/Platform.c Outdated
Comment thread netbsd/NetBSDProcessList.c Outdated
Comment thread Makefile.am Outdated
Comment thread Makefile.am Outdated
Comment thread netbsd/Platform.h Outdated
@fraggerfox fraggerfox requested a review from BenBE April 25, 2021 17:29
Comment thread XUtils.h Outdated
Comment thread netbsd/NetBSDProcessList.c Outdated
Comment thread netbsd/NetBSDProcessList.c Outdated
@BenBE BenBE force-pushed the netbsd-no-procfs branch 2 times, most recently from 39136a8 to 7509af3 Compare April 27, 2021 17:16
@fraggerfox fraggerfox requested a review from cgzones April 27, 2021 19:24
@BenBE BenBE force-pushed the netbsd-no-procfs branch from c68bab1 to 4d0013d Compare April 27, 2021 19:31
Comment thread netbsd/NetBSDProcess.h Outdated
@BenBE BenBE force-pushed the netbsd-no-procfs branch from 4d0013d to 216d12e Compare April 27, 2021 20:19
@fraggerfox fraggerfox requested a review from BenBE May 23, 2021 09:37
Copy link
Copy Markdown
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some details still need refinement.

Also may benefit to include ELAPSED column from #627.

Furthermore PROC_EXE (via KERN_PROC_PATHNAME) and CWD (via KERN_PROC_CWD) might be nice to have.

Comment thread netbsd/Platform.c Outdated
Comment thread netbsd/NetBSDProcess.c
Comment thread netbsd/NetBSDProcessList.c Outdated
Comment thread netbsd/NetBSDProcessList.h Outdated
Comment thread netbsd/NetBSDProcessList.c
Comment thread netbsd/Platform.c
Comment thread netbsd/Platform.h
Comment thread netbsd/Platform.h
Comment thread netbsd/README.md Outdated
@BenBE BenBE removed the needs-discussion 🤔 Changes need to be discussed and require consent label Jun 1, 2021
Comment thread netbsd/NetBSDProcessList.c Outdated
@fraggerfox fraggerfox requested a review from BenBE June 13, 2021 00:16
@BenBE BenBE force-pushed the netbsd-no-procfs branch from 4c67fa4 to a176972 Compare June 13, 2021 14:29
@BenBE
Copy link
Copy Markdown
Member

BenBE commented Jun 13, 2021

@fraggerfox Did some commit mashing ;-) No functional changes.

@fraggerfox
Copy link
Copy Markdown
Contributor Author

@fraggerfox Did some commit mashing ;-) No functional changes.

Looks good.

Copy link
Copy Markdown
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-wise it LGTM. Haven't tested to run this though.

@alarixnia
Copy link
Copy Markdown
Contributor

alarixnia commented Jun 13, 2021

fraggerfox asked me to test his code, but unfortunately htop fails to configure with NetBSD libcurses.

checking for ncursesw/curses.h... no
checking for ncurses/ncurses.h... no
checking for ncurses/curses.h... no
checking for ncurses.h... no
configure: error: can not find required ncurses header file

this should be unnecessary, as NetBSD libcurses should be good enough.

so, I re-ran configure with export CFLAGS="-I/usr/pkg/include" and export LDFLAGS="-L/usr/pkg/lib -Wl,-R/usr/pkg/lib" so it would find a copy of ncurses I installed.

after this it appears to work fine, although the output is still less useful than top(1) - it groups the file cache together with active memory used by applications, and it does not show kernel threads. it is definitely not a regression from previous htop on netbsd, though

@BenBE
Copy link
Copy Markdown
Member

BenBE commented Jun 13, 2021

@fraggerfox asked me to test his code, but unfortunately htop fails to configure with NetBSD libcurses.

checking for ncursesw/curses.h... no
checking for ncurses/ncurses.h... no
checking for ncurses/curses.h... no
checking for ncurses.h... no
configure: error: can not find required ncurses header file

this should be unnecessary, as NetBSD libcurses should be good enough.

so, I re-ran configure with export CFLAGS="-I/usr/pkg/include" and export LDFLAGS="-L/usr/pkg/lib -Wl,-R/usr/pkg/lib" so it would find a copy of ncurses I installed.

Looking through configure.ac we only ever look for the ncurses headers, but not for any headers only called curses.h. Can you have a shot at updating configure.ac to also look for curses.h as a last resort? Also have a look at ProvideCurses.h to see if this needs any updates. That's the only place in htop that directly includes any of the ncurses/curses headers.

after this it appears to work fine, although the output is still less useful than top(1) - it groups the file cache together with active memory used by applications,

This looks like when reading the memory stats some details are still missing. Actually there's a second open point (regarding shared memory) … @Niacat Could you have a look at that?

and it does not show kernel threads. It is definitely not a regression from previous htop on netbsd, though

Can you see if the check for kernel threads in netbsd/NetBSDProcessList.c (here) is done properly?

@fraggerfox
Copy link
Copy Markdown
Contributor Author

fraggerfox commented Jun 13, 2021

fraggerfox asked me to test his code, but unfortunately htop fails to configure with NetBSD libcurses.

checking for ncursesw/curses.h... no
checking for ncurses/ncurses.h... no
checking for ncurses/curses.h... no
checking for ncurses.h... no
configure: error: can not find required ncurses header file

this should be unnecessary, as NetBSD libcurses should be good enough.

so, I re-ran configure with export CFLAGS="-I/usr/pkg/include" and export LDFLAGS="-L/usr/pkg/lib -Wl,-R/usr/pkg/lib" so it would find a copy of ncurses I installed.

@Niacat When running the build via the pkgsrc infrastructure these flags are passed in, I guess this is because of USE_NCURSES= yes . When I was building it outside pkgsrc I passed in the flags manually as you have described above.

after this it appears to work fine, although the output is still less useful than top(1) - it groups the file cache together with active memory used by applications, and it does not show kernel threads. it is definitely not a regression from previous htop on netbsd, though

Regarding the memory usage I mostly referred to top(1)'s code and uvm((9)' sysctl interface to get the necessary values.

For the kernel threads, yes I agree, it pretty much does what the current htop(1) does in NetBSD, is there a better way to process this information?

@alarixnia
Copy link
Copy Markdown
Contributor

We should probably get this merged and improve things further later.

In particular getting it to build with X/Open Curses seems difficult - it is peeking into ncurses-specific structs.

@BenBE BenBE added the NetBSD 🎏 NetBSD related issues label Jun 17, 2021
@BenBE
Copy link
Copy Markdown
Member

BenBE commented Jun 17, 2021

Could you open issues for the remaining items on your list? What I see is:

@fasterit fasterit added this to the 3.1.0 milestone Jun 18, 2021
@fraggerfox
Copy link
Copy Markdown
Contributor Author

I opened a couple more tickets for the issues raised.

@BenBE BenBE merged commit 3bed682 into htop-dev:master Jun 26, 2021
@fraggerfox fraggerfox deleted the netbsd-no-procfs branch August 4, 2021 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSD 🐡 Issues related to *BSD feature request Completely new feature requested NetBSD 🎏 NetBSD related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants