Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp396829ybd; Tue, 25 Jun 2019 23:42:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7Oth4a124dryYOr8JsRXPnmEarvSQ1T+T2vMkg9IxfoXVAUkzInMJOJN93v/krgLM1Yld X-Received: by 2002:a63:89c7:: with SMTP id v190mr1273099pgd.299.1561531347964; Tue, 25 Jun 2019 23:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561531347; cv=none; d=google.com; s=arc-20160816; b=ZDhRphs2iADWznAw+pJ9XZpFI+ul99STh9Nd0/bZ6eArcoObt7EPj+Nlrqehoij5TT 02ja+9u8ngs5/wcUB7uL9Ctyc64by0NbHwz+X4A8EspIfoPBT5L3CQu/Ylx15KrqGIi5 14+DKNFQEXqwa+JFW81tgmeotgMSuc7POsiSUm4QDiNoVdkhoQYan0V/rczHXhSQzorU XM+825xHCqt7/6H60EoZwGiwUCVOs+7XSg8KLsgVhzrvnbsI2ku+Y+gMCO1AQB11EnGq csJkO2G1pfrOXRsrcZAaW1lFiVydr+mM276oMM0KmMt2N6ENYaeqrF9n8wm4X4WlL70h o1OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=97fNQhRc8wq4ewqRwHUZivSXGNy3wo+DiktNt6BuM1o=; b=AYr9M8L3YZnN31yjG3VafdLh8KSX3slnz8nJ//SQAxCX5Qrnjp/0x8nIRwKp8GbbTI wRlXhGXwfV60ytxTOQoKwC53Mdh4kW7atkZgGphX4leUvNWfle+xHpYA8HLoqI99bUlQ HUp7eIOxUu/j7cpy5AnQ2hy2Xjp/gzpIfqLVrmOY7ZKfzUPtVXChESdZ2VE3URazUZwE eBehZWXt2ELTvToxgnREYj4H4scvmk4QD9xsvvlwOeTAcF5vHzt3NkyRBUkDqtBD+HR3 okEzvDM7EtxDOG7UAPYbokUo9V1ajL7APUqGds3Ft56zuIxP4zIZlDXTA2ClLdehXiOY ed3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="m8w/QLFU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si16203225pfd.156.2019.06.25.23.42.11; Tue, 25 Jun 2019 23:42:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="m8w/QLFU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbfFZGmB (ORCPT + 99 others); Wed, 26 Jun 2019 02:42:01 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46799 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbfFZGmA (ORCPT ); Wed, 26 Jun 2019 02:42:00 -0400 Received: by mail-pl1-f195.google.com with SMTP id e5so843244pls.13 for ; Tue, 25 Jun 2019 23:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=97fNQhRc8wq4ewqRwHUZivSXGNy3wo+DiktNt6BuM1o=; b=m8w/QLFUOkV2r8nM4dXom4nB8yKJb7/7QTMOMQn0qijo9CexrHeK+bR0MPOk7K64RN oMDOQhVkXnI4UYsxoZERTzMchuU8ZuSXQVbe7PD7GBq58swJ1B0wl9zg2T1jDJjIFcpW O/5R7uaHiYc5vvAJDPHpVhmTpcBeCykDYFrlkLu92iDqXDEGHmkNFrPVme8ha3yeMa+9 SSjqnz+drMupIrIAA5p2oUG6JB/gHz+XdzOb+NPLguWQM152NiUsdJnj04d+wIazVHoY RqDDXsDiktD7TWekl63ZaXNaVelF0ltlqznPeRmml4YQVzfq60nVLckHZybN7zV2zT1m aBEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=97fNQhRc8wq4ewqRwHUZivSXGNy3wo+DiktNt6BuM1o=; b=DVo5jD5NDK3puGjnoDduvEnmMzFCBBfHZ0mRiheb9/ecGtjW0Pi/FW67ZE/GHav4wQ 7SuKVhC9zMg2wgutihHWJZi1d5IIbKgVSwrspS1f5dMmKYwMlwdm1rmmAyirt0otKvRJ 2iSB2rjGu7v5dMiJkna4zvPaiVQywULyEp8P2Y2dIsb5EOYQIq8pHLvu5ug07KimwJFM 3z3DvJT5Z27FtX1o4bTytdtv3Ojm01AAvXu+eVLnxF0Mp2PO9Ab0r90q+0QWDSGe1EGq djIk4qiJyx8O9HtHJjPGFiI9NqskXI5CcfZpdh2f0CFmcsO4E7DArWP4IEvW3ZXDliyN 9anw== X-Gm-Message-State: APjAAAXSFdm6YAEwrBtwmFxQb3uaMOpGUnEBm2Euc31M/08F8AGl9+IH do0QovOC3xA1sW0iXn0vP/NYvmrVd6ac3xMWG0Ej7A== X-Received: by 2002:a17:902:1004:: with SMTP id b4mr3503891pla.325.1561531318934; Tue, 25 Jun 2019 23:41:58 -0700 (PDT) MIME-Version: 1.0 References: <20190617082613.109131-1-brendanhiggins@google.com> <20190617082613.109131-2-brendanhiggins@google.com> <20190620001526.93426218BE@mail.kernel.org> <20190625214427.GN19023@42.do-not-panic.com> <20190625230253.GQ19023@42.do-not-panic.com> In-Reply-To: <20190625230253.GQ19023@42.do-not-panic.com> From: Brendan Higgins Date: Tue, 25 Jun 2019 23:41:47 -0700 Message-ID: Subject: Re: [PATCH v5 01/18] kunit: test: add KUnit test runner core To: Luis Chamberlain Cc: Stephen Boyd , Frank Rowand , Greg KH , Josh Poimboeuf , Kees Cook , Kieran Bingham , Peter Zijlstra , Rob Herring , shuah , "Theodore Ts'o" , Masahiro Yamada , devicetree , dri-devel , kunit-dev@googlegroups.com, "open list:DOCUMENTATION" , linux-fsdevel@vger.kernel.org, linux-kbuild , Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , linux-nvdimm , linux-um@lists.infradead.org, Sasha Levin , "Bird, Timothy" , Amir Goldstein , Dan Carpenter , Daniel Vetter , Jeff Dike , Joel Stanley , Julia Lawall , Kevin Hilman , Knut Omang , Logan Gunthorpe , Michael Ellerman , Petr Mladek , Randy Dunlap , Richard Weinberger , David Rientjes , Steven Rostedt , wfg@linux.intel.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 25, 2019 at 4:02 PM Luis Chamberlain wrote: > > On Tue, Jun 25, 2019 at 03:14:45PM -0700, Brendan Higgins wrote: > > On Tue, Jun 25, 2019 at 2:44 PM Luis Chamberlain wrote: > > > Since its a new architecture and since you seem to imply most tests > > > don't require locking or even IRQs disabled, I think its worth to > > > consider the impact of adding such extreme locking requirements for > > > an initial ramp up. > > > > Fair enough, I can see the point of not wanting to use irq disabled > > until we get someone complaining about it, but I think making it > > thread safe is reasonable. It means there is one less thing to confuse > > a KUnit user and the only penalty paid is some very minor performance. > > One reason I'm really excited about kunit is speed... so by all means I > think we're at a good point to analyze performance optimizationsm if > they do make sense. Yeah, but I think there are much lower hanging fruit than this (as you point out below). I am all for making/keeping KUnit super fast, but I also don't want to waste time with premature optimizations and I think having thread safe expectations and non-thread safe expectations hurts usability. Still, I am on board with making this a mutex instead of a spinlock for now. > While on the topic of parallization, what about support for running > different test cases in parallel? Or at the very least different kunit > modules in parallel. Few questions come up based on this prospect: > > * Why not support parallelism from the start? Just because it is more work and there isn't much to gain from it right now. Some numbers: I currently have a collection of 86 test cases in the branch that this patchset is from. I turned on PRINTK_TIME and looked at the first KUnit output and the last. On UML, start time was 0.090000, and end time was 0.090000. Looks like sched_clock is not very good on UML. Still it seems quite likely that all of these tests run around 0.01 seconds or less on UML: I ran KUnit with only 2 test cases enabled three times and got an average runtime of 1.55867 seconds with a standard deviation of 0.0346747. I then ran it another three times with all test cases enabled and got an average runtime of 1.535 seconds with a standard deviation of 0.0150997. The second average is less, but that doesn't really mean anything because it is well within one standard deviation with a very small sample size. Nevertheless, we can conclude that the actual runtime of those 84 test cases is most likely within one standard deviation, so on the order of 0.01 seconds. On x86 running on QEMU, first message from KUnit was printed at 0.194251 and the last KUnit message was printed at 0.340915, meaning that all 86 test cases ran in about 0.146664 seconds. In any case, running KUnit tests in parallel is definitely something I plan on adding it eventually, but it just doesn't really seem worth it right now. I find the incremental build time of the kernel to typically be between 3 and 30 seconds, and a clean build to be between 30 seconds to several minutes, depending on the number of available cores, so I don't think most users would even notice the amount of runtime contributed by the actual unit tests until we start getting into the 1000s of test cases. I don't suspect it will become an issue until we get into the 10,000s of test cases. I think we are a pretty long way off from that. > * Are you opposed to eventually having this added? For instance, there is > enough code on lib/test_kmod.c for batching tons of kthreads each > one running its own thing for testing purposes which could be used > as template. I am not opposed to adding it eventually at all. I actually plan on doing so, just not in this patchset. There are a lot of additional features, improvements, and sugar that I really want to add, so much so that most of it doesn't belong in this patchset; I just think this is one of those things that belongs in a follow up. I tried to boil down this patchset to as small as I could while still being useful; this is basically an MVP. Maybe after this patchset gets merged I should post a list of things I have ready for review, or would like to work on, and people can comment on what things they want to see next. > * If we eventually *did* support it: > - Would logs be skewed? Probably, before I went with the TAP approach, I was tagging each message with the test case it came from and I could have parsed it and assembled a coherent view of the logs using that; now that I am using TAP conforming output, that won't work. I haven't really thought too hard about how to address it, but there are ways. For the UML users, I am planning on adding a feature to guarantee hermeticity between tests running in different modules by adding a feature that allows a single kernel to be built with all tests included, and then determine which tests get run by passing in command line arguments or something. This way you can get the isolation from running tests in separate environments without increasing the build cost. We could also use this method to achieve parallelism by dispatching multiple kernels at once. That only works for UML, but I imagine you could do something similar for users running tests under qemu. > - Could we have a way to query: give me log for only kunit module > named "foo"? Yeah, I think that would make sense as part of the hermeticity thing I mentioned above. Hope that seems reasonable!