Skip to content

core: add IODeviceLatencyTargetSec#9247

Merged
keszybz merged 1 commit intosystemd:masterfrom
htejun:io_latency
Aug 22, 2018
Merged

core: add IODeviceLatencyTargetSec#9247
keszybz merged 1 commit intosystemd:masterfrom
htejun:io_latency

Conversation

@htejun
Copy link
Contributor

@htejun htejun commented Jun 9, 2018

This adds support for the following proposed latency based IO control
mechanism.

https://lkml.org/lkml/2018/6/5/428

This should be merged after the kernel feature is merged. Submitting
now for early review.

struct CGroupIODeviceLatency {
LIST_FIELDS(CGroupIODeviceLatency, device_latencies);
char *path;
uint64_t target_usec;
Copy link
Member

Choose a reason for hiding this comment

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

I think using usec_t is better.

Copy link
Member

@poettering poettering left a comment

Choose a reason for hiding this comment

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

looks pretty good, just some minor comments

<listitem>
<para>Set the per-device average target I/O latency for the executed processes, if the unified control group
hierarchy is used on the system. Takes a space-separated pair of a file path and a timespan value to specify
the device specific latency target. (Example: "/dev/sda 25ms"). The file path may be specified
Copy link
Member

Choose a reason for hiding this comment

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

maybe use <literal>…</literal> here, rather than ""

return n;
}

static unsigned cgroup_apply_io_device_latency(Unit *u, const char *dev_path, uint64_t target) {
Copy link
Member

Choose a reason for hiding this comment

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

uint64_t targetusec_t target?


LIST_FOREACH_SAFE(device_latencies, l, next, c->io_device_latencies) {
if (!cgroup_apply_io_device_latency(u, l->path, l->target_usec))
cgroup_context_free_io_device_latency(c, l);
Copy link
Member

Choose a reason for hiding this comment

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

hmm, so applying these might modify the loaded unit file state?

I am seeing the existing code already did it like that, but I wonder if this is a good idea. I am pretty sure we should leave configuration unmodified by reality, if you so will. I mean, devices come and go, and I think our policy should be here that we apply what we can apply, and if we cant' apply it now, then we should handle it gracefully, but if we maybe can apply it safely later, for example because a device appeared, we should do it then. i.e. truly graceful best-effort behaviour.

but dunno, mayb it's ok to get in like this for now, but I am pretty sure we should clean that up sooner or later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... yeah maybe. I have no idea why all the device io configs try to ditch configs if the device lookup fails or the config is the default. Maybe it's to conserve memory? Given that they're all tied to a cgroup's lifetime, just keeping them around no matter what should be fine, I think.

Copy link
Member

Choose a reason for hiding this comment

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

someone called Tejun Heo added that bit in 979d031. Maybe we should ask him ;-)

Copy link
Member

Choose a reason for hiding this comment

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

I prepped #9275 now, which drops this bit. PTAL. (and rebase on top of it after that's merged)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I completely forgot that it was me. Gees. Anyways, yeah, I can't think of downsides of just keeping the configs around.

@poettering
Copy link
Member

Hmm, I made some changes to the block device resolving and validation code in #9255. I figure this PR should follow the same logic of those changes as soon as it gets merged.

Copy link
Member

@keszybz keszybz left a comment

Choose a reason for hiding this comment

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

There is a mismatch between the docs and the checks for valid paths, but @poettering already handled that in #9255.

<listitem>
<para>Set the per-device average target I/O latency for the executed processes, if the unified control group
hierarchy is used on the system. Takes a space-separated pair of a file path and a timespan value to specify
the device specific latency target. (Example: "/dev/sda 25ms"). The file path may be specified
Copy link
Member

Choose a reason for hiding this comment

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

Takes a file path and a timespan separated by a space …

(I know this just copies existing text.)

r = cg_set_attribute("io", u->cgroup_path, "io.latency", buf);
if (r < 0)
log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to set io.latency: %m");
Copy link
Member

Choose a reason for hiding this comment

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

"Failed to set io.latency on cgroup %s: %", u->cgroup_path) ?

target = e+1;

r = parse_sec(target, &usec);

Copy link
Member

Choose a reason for hiding this comment

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

Spurious newline.

@htejun
Copy link
Contributor Author

htejun commented Jun 11, 2018

Applied changes for all comments except for #9255. Will rebase on top once it's merged.

@keszybz
Copy link
Member

keszybz commented Jun 12, 2018

Please rebase.

@htejun
Copy link
Contributor Author

htejun commented Jun 12, 2018

@keszybz, will wait for #9275 and then rebase. Thanks.

@poettering
Copy link
Member

looks good to me, but let's wait until the upstream kernel feature is merged and until after the upcoming v239 release.

facebook-github-bot pushed a commit to facebookarchive/rpm-backports that referenced this pull request Jun 26, 2018
Summary:
New upstream release, plus backports of
systemd/systemd#9244
systemd/systemd#9247 and
systemd/systemd#9410

Reviewed By: jaymzh

Differential Revision: D8609874

fbshipit-source-id: a620516cb7bc4305b144c811aa5eac5d19dc8274
@evverx
Copy link
Contributor

evverx commented Jul 3, 2018

This pull request fixes 4 alerts when merging b874a67 into 98b0b11 - view on LGTM.com

fixed alerts:

  • 4 for FIXME comment

Comment posted by LGTM.com

@htejun
Copy link
Contributor Author

htejun commented Jul 11, 2018

blk-iolatency got merged into block/for-next and will be pulled into Linus's tree when v4.19-rc1 window opens.

@keszybz
Copy link
Member

keszybz commented Aug 22, 2018

blk-iolatency is available in 4.19.0-0.rc0.git6.1.fc30.x86_64, let's merge.

@keszybz keszybz merged commit 6ae4283 into systemd:master Aug 22, 2018
@evverx
Copy link
Contributor

evverx commented Aug 22, 2018

This pull request fixes 4 alerts when merging b874a67 into 71d1700 - view on LGTM.com

fixed alerts:

  • 4 for FIXME comment

Comment posted by LGTM.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants