Skip to content

Implement ReadMemInfo on FreeBSD#1239

Merged
rhatdan merged 1 commit intocontainers:mainfrom
dfr:freebsd-meminfo
May 13, 2022
Merged

Implement ReadMemInfo on FreeBSD#1239
rhatdan merged 1 commit intocontainers:mainfrom
dfr:freebsd-meminfo

Conversation

@dfr
Copy link
Copy Markdown
Contributor

@dfr dfr commented May 12, 2022

Signed-off-by: Doug Rabson dfr@rabson.org

total int64 = 0
used int64 = 0
)
for i := 0; ; i++ {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a question: Can you get number of swap devices using nswapdev instead infinite loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea - I was kind of following the algorithm used in the base system's swapinfo command but this is better.

Copy link
Copy Markdown
Collaborator

@flouthoc flouthoc May 12, 2022

Choose a reason for hiding this comment

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

@dfr I am not aware about BSD a lot so i am not even sure about it. It was just a question or rather a discussion, you can feel free to discuss more about that as there is no requirement to change code right away :). Could you help checking if it does not breaks anything else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I re-tested using 'podman info' and verified that it still reads the swap details. I also noticed that it mixed up used and free totals for swap so I fixed that.

@flouthoc
Copy link
Copy Markdown
Collaborator

Two questions above.

@dfr dfr force-pushed the freebsd-meminfo branch from 68e18dc to 9404e56 Compare May 12, 2022 14:02
Comment on lines +68 to +74
if MemTotal < 0 || MemFree < 0 || SwapTotal < 0 || SwapFree < 0 {
return nil, fmt.Errorf("error getting system memory info %v\n", err)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think any of these can be negative if the two calls above succeed. Perhaps this can change to an assert?

@dfr dfr force-pushed the freebsd-meminfo branch 3 times, most recently from 1c49f8d to c2c7936 Compare May 13, 2022 07:10
Signed-off-by: Doug Rabson <dfr@rabson.org>
Copy link
Copy Markdown
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM @containers/storage-maintainers PTAL

@rhatdan
Copy link
Copy Markdown
Member

rhatdan commented May 13, 2022

LGTM

@rhatdan rhatdan merged commit eb4f1bd into containers:main May 13, 2022
@dfr dfr deleted the freebsd-meminfo branch June 13, 2023 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants