Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231287
| Path | csiph.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Daniel Vetter <daniel@ffwll.ch> |
| Newsgroups | linux.kernel |
| Subject | Shared scaffolding to unit-test kernel code in userspace (was Re: [Intel-gfx] [PATCH] drm/i915: Add link training test) |
| Date | Wed, 23 Sep 2015 11:40:01 +0200 |
| Message-ID | <qbOGR-bd-9@gated-at.bofh.it> (permalink) |
| References | <qbOGR-bd-11@gated-at.bofh.it> <qbOGR-bd-13@gated-at.bofh.it> <qbOGR-bd-15@gated-at.bofh.it> <qbOGR-bd-17@gated-at.bofh.it> <qbOGR-bd-19@gated-at.bofh.it> <qbOGR-bd-21@gated-at.bofh.it> <qbOGR-bd-23@gated-at.bofh.it> |
| X-Original-To | Ander Conselvan De Oliveira <conselvan2@gmail.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=uLCUW6lfAP3bbYnpdZ+LdxXWYe1dudzMhMFkUKwgUDc=; b=ZbVbkWZZgttbRqr2A7Z8KtJnsaK1Y7rA7HbA6fWV311mEcqObLYhXXiB3z3wEFSJUD lRz6pmbpctCMz8/peJWnlntrQyjMB1/hTF/iDMho2QpoGL8trNme1NQF4KMNOwG4QD2z 6TMSATkBanHQTjfbmxbYwpNYPQDXNLJmmtbt4= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=uLCUW6lfAP3bbYnpdZ+LdxXWYe1dudzMhMFkUKwgUDc=; b=Ta6oSlioHxq6NGhaIfVfyTAkG/kJ6ojBNv+ohTO5yGvXV0v2GDCo1gm8g2BFbuyORp XrRGIz3E+dnsACe94hSP8h9cnXEC97G3Dk7egygR2ttGVq1NfHW4qPVpg9vPzi8j82Ti jaIZ4C/T+QDqvYkBD/r1MrL4+zBXxclwR9tkd48SQNmJfMUQfnkLu+avMqIyRcJIKP92 WThuC0Yr0lNPw8rJ1AuMF7R1LTgQOgDW711FjNCZWJvjRuL5Y1IitnQashGWR+uA0MKO svkzuL4paYVl0M5qod1XhHShF5uuFuNtvL+2YcND3FB7ZbTdOvjfuRxlbnWdBp+8hKFY QBQw== |
| X-Gm-Message-State | ALoCoQmDSBeh7mGmyLUpAVM4ds4CaFJ4ZIRTDeLcxvujbHd4Uhyiwd0Oo04+Ox2ef3BhXRvZfOOZ |
| X-Received | by 10.194.176.201 with SMTP id ck9mr34600900wjc.108.1443000924767; Wed, 23 Sep 2015 02:35:24 -0700 (PDT) |
| X-Google-Original-Sender | daniel.vetter@ffwll.ch |
| Mail-Followup-To | Ander Conselvan De Oliveira <conselvan2@gmail.com>, intel-gfx <intel-gfx@lists.freedesktop.org>, Thomas Wood <thomas.wood@intel.com>, Martin Peres <martin.peres@free.fr>, Ben Skeggs <bskeggs@redhat.com>, Nouveau Dev <nouveau@lists.freedesktop.org>, Shuah Khan <shuahkh@osg.samsung.com>, Greg KH <gregkh@linuxfoundation.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| X-Originating-IP | [2a02:168:56c9:0:22cf:30ff:fe4c:37d6] |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 107 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | intel-gfx <intel-gfx@lists.freedesktop.org>, Thomas Wood <thomas.wood@intel.com>, Martin Peres <martin.peres@free.fr>, Ben Skeggs <bskeggs@redhat.com>, Nouveau Dev <nouveau@lists.freedesktop.org>, Shuah Khan <shuahkh@osg.samsung.com>, Greg KH <gregkh@linuxfoundation.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> |
| X-Original-Date | Wed, 23 Sep 2015 11:38:17 +0200 |
| X-Original-Message-ID | <20150923093817.GG3383@phenom.ffwll.local> |
| X-Original-References | <1441980706-9241-1-git-send-email-ander.conselvan.de.oliveira@intel.com> <1442231511-24258-1-git-send-email-ander.conselvan.de.oliveira@intel.com> <20150914131149.GE3383@phenom.ffwll.local> <1442237891.2755.24.camel@gmail.com> <1442322533.2595.11.camel@gmail.com> <20150923082408.GN3383@phenom.ffwll.local> <1442999931.2745.21.camel@gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1231287 |
Show key headers only | View raw
On Wed, Sep 23, 2015 at 11:18 AM, Ander Conselvan De Oliveira <conselvan2@gmail.com> wrote: > On Wed, 2015-09-23 at 10:24 +0200, Daniel Vetter wrote: >> On Tue, Sep 15, 2015 at 04:08:53PM +0300, Ander Conselvan De Oliveira wrote: >> > On Mon, 2015-09-14 at 16:38 +0300, Ander Conselvan De Oliveira wrote: >> > > On Mon, 2015-09-14 at 15:11 +0200, Daniel Vetter wrote: >> > > > On Mon, Sep 14, 2015 at 02:51:51PM +0300, Ander Conselvan de Oliveira wrote: >> > > > > --- >> > > > > >> > > > > On Fri, 2015-09-11 at 17:11 +0300, Ander Conselvan de Oliveira wrote: >> > > > > > On Wed, 2015-09-09 at 11:33 +0100, Thomas Wood wrote: >> > > > > > > On 8 September 2015 at 13:28, Ander Conselvan de Oliveira >> > > > > > > <ander.conselvan.de.oliveira@intel.com> wrote: >> > > > > > > > >> > > > > > >> > > > > > > > diff --git a/link-training-test/Makefile b/link-training-test/Makefile >> > > > > > > >> > > > > > > If this is meant to be part of the test suite, then it needs to be in >> > > > > > > the tests directory and use the igt test infrastructure. Otherwise it >> > > > > > > should be placed in tools or tools/link-training-test. >> > > > > > >> > > > > > I made the test use the igt infrastructure, but I'm not sure if this is >> > > > > > a good fit for it. The dependency on the kernel is on build time, but >> > > > > > once compiled this can be run on any machine. This can also introduce >> > > > > > build failures if the test is not kept in sync with the driver source. >> > > > > > Ideally that a failure to build this would be reported as the test >> > > > > > failing, but I have no idea of how to achieve that. >> > > > > >> > > > > Alternatively, this could be in the kernel source tree directly. This >> > > > > patch adds a test subdir to the i915 source dir, containing the link >> > > > > training test. The test is compiled as part of the normal build using >> > > > > the extra-y variable so that it doesn't get linked to the final kernel. >> > > > > >> > > > > When make is run from the tests directory, a thin wrapper around the >> > > > > tests is built and linked to the object file compiled as part of the >> > > > > kernel build. Running make run_tests from the test dir runs the test >> > > > > and reports success or failure. >> > > > > >> > > > > Any thoughts? >> > > > >> > > > I think there's some precedence in other subsystems to integrate unit >> > > > tests directly in the kernel, e.g. locking selftest or similar things. >> > > > Usual approach is to either have a special module (but that often means >> > > > piles of EXPORT_SYMBOL only for that selftest module). Or just a y/n >> > > > Kconfig option which enables that code and runs all the self/unit tests >> > > > when the module loads. >> > > > >> > > > I'd go with that approach since it's simpler. And we'd only need to tell >> > > > QA to enable that Kconfig option for more testing. >> > > >> > > I'll have a look into that Kconfig approach, but there's a couple of things >> > > I like about having the unit test as user space binaries: >> > > >> > > - there's no need to boot the newly compiled kernel, so doing a test run >> > > is super fast; >> > > - the binaries can be debugged with gdb just like other user space stuff. >> > >> > I implemented the test using the Kconfig approach, and it seems to work well >> > without impacting the points above. I added the call to run the test as the >> > first thing in i915_init(), and with the driver compiled built-in, running >> > the kernel under qemu will run the tests. And qemu can also provide a gdb >> > remote target. >> > >> > One thing might be a problem though. With the previous approach, the >> > functions overriden by the test where simply reimplemented in the new binary. >> > But now the test is linked to the entire driver, so that's not possible. To >> > work around that, I had to add function pointers to all the functions called >> > by the link training state machine to intel_dp. I don't think that method >> > scales well. >> > >> > I'll send update patches for reference as replies to this mail. >> >> I had a few discussions about this at XDC and I know think doing this is >> userspace is better: >> - Faster to run tests (since no module reloading required). >> - Nouveau is developed in userspace and would like to reuse shared link >> training code too if possible from the dp helpers. >> >> So I'm leaning towards scaffolding in userspace now. Might be good to >> check out how the nouveau userspace runtime works just to steal a few >> tricks. > > I chatted with Martin Peres about this and had a look at the code. There are a few interesting > tricks in Nouveau indeed. They have user space implementation for some kernel internals such as > mutexes, ioremap on top of libpciaccess, etc. and an extensive set of stubs. > > The one thing that wouldn't be easy to take advantage of is the build integration. Their upstream > repository is not actually a kernel tree. It contains their drm code, the same that ends up in the > kernel plus all the user space stuff. There's a script that converts the commits from that > repository for inclusion in the kernel tree. Could we perhaps move at least some of the scafffolding for kernel functions to upstream? I guess nouveau has some means to pull changes from upstream too, so maybe we could push that some place nice. And I'm pretty sure we're not the only ones thinking about unit-testing specific kernelcode in a userspace environment. Adding noveau and kselftest folks. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
Shared scaffolding to unit-test kernel code in userspace (was Re: [Intel-gfx] [PATCH] drm/i915: Add link training test) Daniel Vetter <daniel@ffwll.ch> - 2015-09-23 11:40 +0200 Re: Shared scaffolding to unit-test kernel code in userspace (was Re: [Intel-gfx] [PATCH] drm/i915: Add link training test) Ander Conselvan De Oliveira <conselvan2@gmail.com> - 2015-09-29 10:50 +0200
csiph-web