Skip to content

systemd: support max for memory.zswap.max - #103

Open
lifubang wants to merge 1 commit into
opencontainers:mainfrom
lifubang:fix-max-memory.zswap.max
Open

lifubang wants to merge 1 commit into
opencontainers:mainfrom
lifubang:fix-max-memory.zswap.max

Conversation

@lifubang

Copy link
Copy Markdown
Member

Previously, memory.zswap.max only accepted explicit byte values.
This commit adds support for the max keyword.

Fixes: #102

@lifubang
lifubang requested a review from a team as a code owner November 23, 2026 03:46
@lifubang

Copy link
Copy Markdown
Member Author

/cc @MKrupauskas

Comment thread systemd/v2.go
num, err := strconv.ParseUint(v, 10, 64)
if err != nil {
return nil, fmt.Errorf("invalid %s=%q, expected a number", k, v)
num := uint64(math.MaxUint64)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: should we pass "max" to the kernel instead of Go's max unsigned int?

The kernel default is max already but I am open to supporting the max value as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also, if we decide to do that extracting the value selection logic into a small function would probably help with readability and have less if condition depth

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nit: should we pass "max" to the kernel instead of Go's max unsigned int?

Unfortunately, the kernel supports it, but not systemd.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

also, if we decide to do that extracting the value selection logic into a small function would probably help with readability and have less if condition depth

I think both are ok, I copy them from pids.max.
https://github.com/lifubang/cgroups/blob/f953ddf15856d4c315a56e4207f0357d2af21e41/systemd/v2.go#L215-L223

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah id systemd doesn't support it can't do much

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, systemd accepts a numeric type only (and have a constant for max). It's unfortunate but that's how things are.

@MKrupauskas

Copy link
Copy Markdown
Contributor

lgtm though i can’t approve

Previously, memory.zswap.max only accepted explicit byte values.
This commit adds support for the 'max' keyword.
Fixes: 009e461 ("systemd: support zswap unified resources")

Signed-off-by: lifubang <lifubang@acmcoder.com>
Comment thread systemd/systemd_test.go
expError: true,
expProps: []systemdDbus.Property{
newProp("MemoryZSwapMax", uint64(math.MaxUint64)),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should add
minVer: zswapMaxSupportedVersion,
or the test will fail on older systemd (which, apparently, we don't have in CI here)

@kolyshkin kolyshkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one comment about the test case, also can you add

Fixes: 009e4617f2a2 ("systemd: support zswap unified resources")

to commit message footers?

@lifubang
lifubang force-pushed the fix-max-memory.zswap.max branch 3 times, most recently from cff75b5 to d130fb8 Compare November 24, 2026 00:45
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.

[regression] can't support max for memory.zswap.max

3 participants