Skip to content

vconsole-setup: skip fonts copy if the current terminal is in graphic… - #11130

Merged
keszybz merged 1 commit into
systemd:masterfrom
fbuihuu:vconsole-skip-font-set
Dec 13, 2018
Merged

keszybz merged 1 commit into
systemd:masterfrom
fbuihuu:vconsole-skip-font-set

Conversation

@fbuihuu

@fbuihuu fbuihuu commented Dec 12, 2018

Copy link
Copy Markdown
Contributor

…al mode

If the terminal is in graphical mode, the kernel will refuse to copy the fonts
and will return -EINVAL.

Also having the graphical mode in effect probably indicates that the terminal
is in used by another application and we shouldn't interfer in such cases.

Note that the check (as well as the others) is racy.

@keszybz

keszybz commented Dec 12, 2018

Copy link
Copy Markdown
Member

What is the error returned from the ioctl? If it is distinct enough, an alternative fix that would not create a race condition would be to try the ioctl and not report the error if we get this code.

@fbuihuu

fbuihuu commented Dec 12, 2018

Copy link
Copy Markdown
Contributor Author

As written in the commit message, the kernel returns EINVAL in such case so it seems too generic.

Also I'm not sure how we could fix the race from userspace: we need to do the following sequence atomically "if tty in text mode then copy fonts", not something doable AFAIK.

@keszybz

keszybz commented Dec 12, 2018

Copy link
Copy Markdown
Member

What about the following: instead of calling KDGETMODE first, only call it if KDFONTOP fails? This doesn't remove the race, but makes it less important. In general, we mostly expect terminals to go through text mode to graphical mode, and stay so, especially during boot. So we'd still have a possible race, but we'd only hit it is something was holding the terminal and gave it up, which seems to be much less likely event. Then if the KDGETMODE reports != KD_TEXT, assume the terminal is busy and only do log_debug.

It'd have been nice the kernel returned EBUSY. Maybe we could patch the kernel too? This would provide a nicer long-term solution.

@fbuihuu

fbuihuu commented Dec 12, 2018

Copy link
Copy Markdown
Contributor Author

That sounds good, I'll change the patch accordingly.

@poettering

Copy link
Copy Markdown
Member

also a bit of debug logging would be good, that says what happens.

@fbuihuu
fbuihuu force-pushed the vconsole-skip-font-set branch from 2475d71 to 4152e99 Compare December 12, 2018 15:07
@fbuihuu

fbuihuu commented Dec 12, 2018

Copy link
Copy Markdown
Contributor Author

@keszybz new version pushed. It includes your feedback. PTAL.

@evverx

evverx commented Dec 12, 2018 •

Copy link
Copy Markdown
Contributor

@mrc0mmand could you skip TEST-16-EXTEND-TIMEOUT on CentOS? It (or whatever it tests) has always been flaky so I don't think there's any point in running it. Ubuntu CI will keep reminding everybody of that flakiness, though.

@mrc0mmand

Copy link
Copy Markdown
Member

@evverx will do. Also, I'll re-trigger the CentOS CI job to get more relevant results.

Comment thread src/vconsole/vconsole-setup.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So... last_errno is either a postive errno value, or a negative -EBUSY. Also, the synthethic -EBUSY is logged and returned.
This will work fine, but somehow it feels wrong. I think that the original errno should be returned (even if it is always -EINVAL now, but the kernel could change). So what about using a separate boolean for ioctl(fd_d, KDGETMODE, &mode) >= 0 && mode != KD_TEXT instead?

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.

If we do that it won't be obvious that the font copy failed because the terminal is busy.

…aphical mode

If the terminal is in graphical mode, the kernel will refuse to copy the fonts
and will return -EINVAL.

Also having the graphical mode in effect probably indicates that the terminal
is in used by another application and we shouldn't interfer in such cases.
@fbuihuu
fbuihuu force-pushed the vconsole-skip-font-set branch from 4152e99 to 8240dec Compare December 12, 2018 22:32
@fbuihuu

fbuihuu commented Dec 12, 2018

Copy link
Copy Markdown
Contributor Author

@keszybz how about this instead ?

@keszybz
keszybz merged commit d610d20 into systemd:master Dec 13, 2018
@fbuihuu
fbuihuu deleted the vconsole-skip-font-set branch January 7, 2019 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

5 participants