From: Mathieu Othacehe <othacehe@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 39341@debbugs.gnu.org, 39341-done@debbugs.gnu.org,
Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: bug#39341: Installer using 100% of a CPU core
Date: Thu, 29 Apr 2021 11:33:17 +0200 [thread overview]
Message-ID: <8735v91llu.fsf@gnu.org> (raw)
In-Reply-To: <87sg3asexh.fsf@gnu.org> ("Ludovic Courtès"'s message of "Wed, 28 Apr 2021 15:43:06 +0200")
[-- Attachment #1: Type: text/plain, Size: 487 bytes --]
Hey Ludo,
Your recent patch is just revealing an issue we always had with this
Kmscon patch. Basically, without the "unlink" called you introduced, the
FIFO fd was added only to the first discovered input and the keyboard
layout was only applied to that very input.
Conveniently, that input was always the main user keyboard I guess. The
attached patch fixes that issue by registering the FIFO on the first
input, but applying the keyboard layout to all the inputs.
Thanks,
Mathieu
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-kmscon-Fix-layout-setup.patch --]
[-- Type: text/x-patch, Size: 3378 bytes --]
From 1a0fddd844ced62c802db0d6d133af45880435f0 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
Date: Thu, 29 Apr 2021 11:11:32 +0200
Subject: [PATCH] gnu: kmscon: Fix layout setup.
Kmscon may discover multiple inputs, corresponding to multiple devices. This
means that the uxkb_dev_keymap_update function may be called multiple times,
and the FIFO is registered on each input poll loop.
When a new layout is written on the FIFO by the installer, the first input
picking up the message, will apply the new layout. However, that input may not
be the input that the user is currently using.
To fix it, register the FIFO on the first input poll loop, but apply the new
layout on all the inputs in the uxkb_keymap_update_handler function.
* gnu/packages/patches/kmscon-runtime-keymap-switch.patch
(uxkb_keymap_update_handler): Apply the new layout to all the inputs.
(uxkb_dev_keymap_update): Register the FIFO fd only on the first input poll loop.
---
.../kmscon-runtime-keymap-switch.patch | 29 ++++++++++++++-----
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch
index 480aaecad2..abff9c460d 100644
--- a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch
+++ b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch
@@ -132,7 +132,7 @@ index 925c755..8fe08f8 100644
#include <xkbcommon/xkbcommon.h>
#include "shl_hook.h"
#include "shl_llog.h"
-@@ -178,6 +181,95 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data)
+@@ -178,6 +181,110 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data)
shl_hook_call(dev->input->hook, dev->input, &dev->repeat_event);
}
@@ -171,7 +171,23 @@ index 925c755..8fe08f8 100644
+
+ llog_info(dev->input, "HANDLER CALLED %s|%s|%s\n",
+ model, layout, variant);
-+ uxkb_desc_init(dev->input, model, layout, variant, options, NULL);
++
++ struct uterm_input *input = dev->input;
++ struct shl_dlist *iter;
++
++ /* Apply the new layout to all the inputs. */
++ shl_dlist_for_each(iter, &input->devices) {
++ struct uterm_input_dev *dev;
++ dev = shl_dlist_entry(iter,
++ struct uterm_input_dev,
++ list);
++ uxkb_desc_init(dev->input, model, layout, variant, options, NULL);
++ dev->state = xkb_state_new(dev->input->keymap);
++ if (!dev->state) {
++ llog_error(dev->input, "cannot create XKB state");
++ return;
++ }
++ }
+
+ /* The client will now close the FIFO. Close it too, and re-create a
+ * FIFO so other clients can eventually connect. */
@@ -180,11 +196,6 @@ index 925c755..8fe08f8 100644
+ dev->rupdate_fd = -1;
+ uxkb_dev_keymap_update(dev);
+
-+ dev->state = xkb_state_new(dev->input->keymap);
-+ if (!dev->state) {
-+ llog_error(dev->input, "cannot create XKB state");
-+ return;
-+ }
+}
+
+int uxkb_dev_keymap_update(struct uterm_input_dev *dev)
@@ -193,6 +204,10 @@ index 925c755..8fe08f8 100644
+ char *file;
+ int pid = getpid();
+
++ /* Add the FIFO fd only to the first input poll loop. */
++ if (dev->rupdate_fd > 0)
++ return 0;
++
+ ret = asprintf(&file, INPUT_KEYMAP_UPDATE_FILE, pid);
+ if (ret < 0)
+ return ret;
--
2.31.1
next prev parent reply other threads:[~2021-04-29 9:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 5:19 bug#39341: Installer using 100% of a CPU core Maxim Cournoyer
2021-04-25 21:41 ` Ludovic Courtès
2021-04-26 14:32 ` pelzflorian (Florian Pelz)
2021-04-26 16:07 ` Ludovic Courtès
2021-04-26 16:14 ` pelzflorian (Florian Pelz)
2021-04-27 10:38 ` Ludovic Courtès
2021-04-27 12:32 ` pelzflorian (Florian Pelz)
2021-04-27 17:43 ` Bengt Richter
2021-04-27 19:58 ` pelzflorian (Florian Pelz)
2021-04-27 21:26 ` Ludovic Courtès
2021-04-28 7:02 ` pelzflorian (Florian Pelz)
2021-04-28 7:06 ` pelzflorian (Florian Pelz)
2021-04-28 13:43 ` Ludovic Courtès
2021-04-28 15:20 ` pelzflorian (Florian Pelz)
2021-04-29 9:33 ` Mathieu Othacehe [this message]
2021-04-29 9:59 ` Ludovic Courtès
2021-04-29 10:13 ` Mathieu Othacehe
2021-04-29 10:47 ` pelzflorian (Florian Pelz)
2021-04-28 15:22 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735v91llu.fsf@gnu.org \
--to=othacehe@gnu.org \
--cc=39341-done@debbugs.gnu.org \
--cc=39341@debbugs.gnu.org \
--cc=ludo@gnu.org \
--cc=maxim.cournoyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.