From owner-freebsd-current@freebsd.org Sun Jan 21 20:45:43 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6270CEBA23E for ; Sun, 21 Jan 2018 20:45:43 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: from mail-wr0-x22e.google.com (mail-wr0-x22e.google.com [IPv6:2a00:1450:400c:c0c::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E51C17B944 for ; Sun, 21 Jan 2018 20:45:42 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: by mail-wr0-x22e.google.com with SMTP id v15so3661023wrb.8 for ; Sun, 21 Jan 2018 12:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qM4nVWE3FUSBBkTmjZfLnxHiYh71Be190jAvqVDUfo8=; b=CjOtJCeSJcV8+QOgUffy0DOX8q8J9h2xbH8XC4i44krldMAPyMCLoCLtrabNEKD/b+ w/+Exq+gEHgA5jyX4er5bxwNBGZtaj8z0fGm1QZHglhcgSRVNVDM4b1MVXkYpPsIEwpC Unh7u5ImtueB3cBvch7hUcUqXadMdhfuZv3qK+dNQ/VqI9VanDGg+hzaWB8KIWerFnXZ ATTiAFDxFefYQ9+Ej+MBBJRtavMOA1e1dzTImymmzr/8UfCBCCE2NE+hQBgfv2UxuNLl UQkycczEGyWyE6OIbzYqAtVtLV8rQfO26HYpmVHZ+GCObrc24jzGaNiNx0ldp9WZUFMH Dqhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qM4nVWE3FUSBBkTmjZfLnxHiYh71Be190jAvqVDUfo8=; b=jSYQExbRq8ib2TjXJUH6vyGo73PS8iQjL87zsuVK0oeNJDz99HhYNG6KOwnivr4ztp qnTQLTs4Tts8L7Q7ByS1Dp4hZd7KHITyNNIkXSKvrGiExsz/Ny46ksYe2ohjwNtdzuSu J4TmpmMOn9PC4pWG9wLBLVeExuMu2HqRLFjRyp9esEo+a1NAl3pI6vNc+nROceUl8BMA EuPRzFd1XXIzAGxwv9b73bFpKb4gAyGrz6QepIZlMaK++4FMQoVBI0UDbUNKBULqrIzg niZZLkR09Cj7Xvxr724OZ8X0mPaiQ2Fs4AYJBpeMsPr534jePzMVHtqd1yLgA1U6KQQ2 lffQ== X-Gm-Message-State: AKwxyteTif4z2uXIrbs5I+ZEmGMLw5CaAygto0e4xiR3O8R7GzEmZeYc tClL4YygFeEOGNTgKLwVaGJaycFAE+FVajft8uM= X-Google-Smtp-Source: AH8x225ST/OXdsvpNsLrKxuz/mcXi0aixvgnF12T/6YVnXGBDoloh630fmNj3bBT8nrIlM3yC+GxBBqbfLHiK5Bivic= X-Received: by 10.223.196.147 with SMTP id m19mr4545946wrf.56.1516567541381; Sun, 21 Jan 2018 12:45:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.136.187 with HTTP; Sun, 21 Jan 2018 12:45:01 -0800 (PST) In-Reply-To: References: From: Johannes Lundberg Date: Sun, 21 Jan 2018 20:45:01 +0000 Message-ID: Subject: Re: Periodical interrupt storm when playing game with USB keyboard To: Hans Petter Selasky Cc: freebsd-current Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jan 2018 20:45:43 -0000 On Sun, Jan 21, 2018 at 8:35 PM, Johannes Lundberg wrote: > Sending the same again, this time cc the list. > > > On Sun, Jan 21, 2018 at 7:34 PM, Hans Petter Selasky > wrote: > >> On 01/21/18 16:41, Johannes Lundberg wrote: >> >>> Hi >>> >>> Finally I found the root to the problem that's been having me puzzled f= or >>> the last week. >>> >>> I started playing UT2004 on my laptop while away from home. Worked >>> perfectly. When I'm home and connect external display+mouse/keyboard, I >>> get >>> weird random lag. >>> >>> It is intr process that goes up to 100% CPU usage (swi4: clock) for a >>> couple of seconds every 30 seconds or so, but only when I'm moving arou= nd >>> in the game. To move around you need to hold down any of the wasd-keys. >>> >>> Turns out, the interrupt storms only happen when I use my external >>> keyboard, not with the laptop keyboard. >>> >>> The internal keyboard is: >>> atkbdc0: port 0x60,0x64 irq 1 on acpi0 >>> atkbd0: irq 1 on atkbdc0 >>> >>> and external (Microsoft sculpt ergonomic desktop): >>> ugen0.2: at usbus0 >>> ukbd0: >> 2.00/7.97, addr 1> on usbus0 >>> >>> The game runs with a linux binary. 32/64bit both act the same. >>> It uses libSDL-1.2 from /compat/linux/lib for rendering but not sure >>> about >>> input events. >>> >>> I tried lowering the key repeat rate both with xset and kbdcontrol but = it >>> has no effect. >>> >>> I don't have any wired USB keyboard to try with. >>> >>> Anyone have a clue to what's going on? >>> >>> Hardware is Dell Latitude E7270 >>> with >>> FreeBSD 12-CURRENT >>> drm-next-kmod >>> linux-c6 >>> >> >> Hi, >> >> What does "vmstat -i" say? >> > > Don=E2=80=99t remember the exact values now but it says cpu0:timer is get= ting A > LOT of interrupts. Like at least 10-50x the others. Otherwise normal. > > >> >> The issue can also be caused by a timer with a small or zero timeout. >> >> This can be checked by setting: >> kern.eventtimer.periodic=3D1 >> >> in /boot/loader.conf and rebooting. >> > > Wow, kern.eventtimer.periodic=3D1 really made all the difference. > No problem at all now and all cpu timers have equal interrupt total and > rate. > > What does kern.eventtimer.periodic do? The sysctl description wasn't > that elaborate... > Replying myself. Found some explanation at https://www.freebsd.org/cgi/man.cgi?query=3Deventtimers&apropos=3D0&sektion= =3D0&manpath=3DFreeBSD+12-current&arch=3Ddefault&format=3Dhtml With periodic each cpu timer has an interrupt rate of 1999 while on one shot it's around 700. Maybe not a very power efficient and precise solution to the problem but it works. > > >> --HPS >> > >