Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit* should allow setting soft and hard limits to different values #1769

Closed
davide125 opened this issue Nov 3, 2015 · 11 comments
Closed
Labels
pid1 RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@davide125
Copy link
Contributor

Using the Limit* options (e.g. LimitAS) there is no way to set the soft and the hard limit to different values (e.g., set soft to 1G and hard to 5G). It'd be useful to extend these options to that an extra optional argument to set the hard limit to a different value; e.g.
LimitAS=1G,5G

@poettering
Copy link
Member

Hmm, what's the precise usecase for this? So far I was reluctant to support this, in order to avoid having too many redudant options, as I didn't see a strong usecase for this... Do you have one?

@poettering poettering added RFE 🎁 Request for Enhancement, i.e. a feature request pid1 needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Nov 9, 2015
@kcbraunschweig
Copy link

Well as an example, we have an app where we set a low soft limit and a higher hard limit. The app can also set and modify the soft limit later with the hard limit being a final safety. So why set the soft limit externally too? Because we've had the internal configuration code that manages the soft limit fail to apply at all due to bugs in the code which went uncaught until it hit production. This failure mode is much less severe when starting from a properly set low limit.

That's one use case, there are probably others. It seems like adding this changes almost nothing about the interface (you still have one option that can now take 1 argument or optionally 2) that allows folks to migrate existing settings you'd expect to exist having looked at man setrlimit and the rlimit struct. I don't see a lot of redundancy here.

@karelzak
Copy link
Contributor

Note that prlimit(1) uses this convention:

   soft:hard  Specify both limits.
   soft:         Specify only the soft limit.
   :hard        Specify only the hard limit.
   value        Specify both limits to the same value.

(it would be nice to use the same in case you decide we really need it for systemd)

@poettering
Copy link
Member

@karelzak yes, that syntax looks useful, makes sense to adopt.

@poettering
Copy link
Member

@kcbraunschweig that's not really a concise usecase description.

@poettering poettering removed the needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer label Nov 10, 2015
@poettering
Copy link
Member

Either way, I see no problem adding this, if somebody sends a patch that implements the syntax @karelzak suggested, hence leaving this as an RFE bug.

@karelzak
Copy link
Contributor

I'll try to prepare a patch.

@karelzak
Copy link
Contributor

@poettering

My suggestion has been to support "value", "soft:hard", "soft:" and ":hard". The last two possibilities are a little bit tricky. What default value is expected when incomplete rlimit range (e.g. "soft:") is specified in the unit files? For example

LimitAS=1G:

to specify 1 GiB soft limit, what is the hard limit for this resource?

It would be possible to use the global DefaultLimitAS or we can keep it simple and support "value" and "soft:hard" syntax only (it means require always complete range).

Comments?

@karelzak
Copy link
Contributor

OK, I have decided that "value" and "soft:hard" syntax is enough. We do not need to support incomplete ranges like "soft:" and ":hard".

@davide125
Copy link
Contributor Author

"value" and "soft:hard" would work well for our usecase, I don't see a need for incomplete ranges either.

karelzak added a commit to karelzak/systemd that referenced this issue Nov 23, 2015
The new parser supports:

 <value>       - specify both limits to the same value
 <soft:hard>   - specify both limits

the size or time specific suffixes are supported, for example

  LimitRTTIME=1sec
  LimitAS=4G:16G

The patch introduces parse_rlimit_range() and rlim type (size, sec,
usec, etc.) specific parsers. No code is duplicated now.

References: systemd#1769
karelzak added a commit to karelzak/systemd that referenced this issue Nov 25, 2015
The new parser supports:

 <value>       - specify both limits to the same value
 <soft:hard>   - specify both limits

the size or time specific suffixes are supported, for example

  LimitRTTIME=1sec
  LimitAS=4G:16G

The patch introduces parse_rlimit_range() and rlim type (size, sec,
usec, etc.) specific parsers. No code is duplicated now.

The patch also sync docs for DefaultLimitXXX= and LimitXXX=.

References: systemd#1769
@poettering
Copy link
Member

Closing, as #1994 got merged.

lnykryn pushed a commit to lnykryn/systemd-rhel that referenced this issue Jul 12, 2016
The new parser supports:

 <value>       - specify both limits to the same value
 <soft:hard>   - specify both limits

the size or time specific suffixes are supported, for example

  LimitRTTIME=1sec
  LimitAS=4G:16G

The patch introduces parse_rlimit_range() and rlim type (size, sec,
usec, etc.) specific parsers. No code is duplicated now.

The patch also sync docs for DefaultLimitXXX= and LimitXXX=.

References: systemd/systemd#1769

Cherry-picked from: 91518d2
Resolves: #1351415
apovichuk-stratoscale pushed a commit to Stratoscale/systemd that referenced this issue Jun 19, 2017
The new parser supports:

 <value>       - specify both limits to the same value
 <soft:hard>   - specify both limits

the size or time specific suffixes are supported, for example

  LimitRTTIME=1sec
  LimitAS=4G:16G

The patch introduces parse_rlimit_range() and rlim type (size, sec,
usec, etc.) specific parsers. No code is duplicated now.

The patch also sync docs for DefaultLimitXXX= and LimitXXX=.

References: systemd/systemd#1769

Cherry-picked from: 91518d2
Resolves: #1351415
apovichuk-stratoscale pushed a commit to Stratoscale/systemd that referenced this issue Jun 20, 2017
The new parser supports:

 <value>       - specify both limits to the same value
 <soft:hard>   - specify both limits

the size or time specific suffixes are supported, for example

  LimitRTTIME=1sec
  LimitAS=4G:16G

The patch introduces parse_rlimit_range() and rlim type (size, sec,
usec, etc.) specific parsers. No code is duplicated now.

The patch also sync docs for DefaultLimitXXX= and LimitXXX=.

References: systemd/systemd#1769

Cherry-picked from: 91518d2
Resolves: #1351415
caobinxin pushed a commit to caobinxin/systemd-lx that referenced this issue Oct 19, 2019
The new parser supports:

 <value>       - specify both limits to the same value
 <soft:hard>   - specify both limits

the size or time specific suffixes are supported, for example

  LimitRTTIME=1sec
  LimitAS=4G:16G

The patch introduces parse_rlimit_range() and rlim type (size, sec,
usec, etc.) specific parsers. No code is duplicated now.

The patch also sync docs for DefaultLimitXXX= and LimitXXX=.

References: systemd/systemd#1769

Cherry-picked from: 91518d20ddf0376808544576d0ef0883cedc67d4
Resolves: #1351415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pid1 RFE 🎁 Request for Enhancement, i.e. a feature request
Development

No branches or pull requests

4 participants