Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1003746rdb; Tue, 19 Sep 2023 17:53:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRp/6VotDtgoU8D0c0+ixeeGiyfk6nZPlRoWp4dk1/oBfkbrmF4XRPeVg+aVD5VcdaG1dA X-Received: by 2002:a05:6358:7212:b0:13a:a85b:a4dc with SMTP id h18-20020a056358721200b0013aa85ba4dcmr1782509rwa.29.1695171195852; Tue, 19 Sep 2023 17:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695171195; cv=none; d=google.com; s=arc-20160816; b=FB405doqdYmF36qRgdiSjkbY38Zwl+0flOkujdrGQvh2eu1wE0oltMJm6sZJRDjBWO t42vJZt2pgJHgeuVmob/eiHco1OnAG+RHQRjJkSpfXAlVZsy6zaVmE6DmdupkMYyDXI0 8ms9xgbjaKKjw03U94iceQGp4GHYcOZC7AaeUUXXmceKgVdvoQDCWkdyvpq5HUUz19WR BmXk3anZGBQusecKNH/YvDHad55sdlXxqQ1AFPnOnec12i60X1aYTXTuDjpJ8yJJp4fN Iuwf29rJMnPxUYHUffEHzsHptCb11ANCpo1WfkWqelfePvAXuakI688mo4wOc13sVBMN cBTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/YB5lVTEo2oIGM22JEX9SYzDoyZreOUPzeoeG//8zcw=; fh=dsd7LcG/ePDvn6V66zp64qPBv7sZX556z0Z38Wfno7U=; b=P04+g/BRr+DNl6sOCQyzpYPOywNuuhNKfAJWyaES0zNGgxWPUoRqVO2+jb+j1Pg0C1 iomKfMxwxwY+la0va4FkbsL3svDoi6MxmNsfbcHaxh6kyMdpiC2KJ9l+LgnKKoiCTEK2 3815bsXDtrdpQ6RN03pxvHoEjcSynltErizRyg/fypJ/tlqZO/wengtr6rV7WXF8sLJe J3crL8RvpGNRKosew8n8XMjdYqYSsxPfBMmnNbyFws2Sh7xXI0g9pnFLizr8tTxOCGbW pnjbpxZnGHk4tJM1sdwi+4nK8HnIxOA9m+nPp0H9Wa2rTc3Dekqhgyn7ys0zRntsnycU gvZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rSzxSb4l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id 1-20020a631941000000b00578aedd8e8bsi2300297pgz.716.2023.09.19.17.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 17:53:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rSzxSb4l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 42791825148A; Tue, 19 Sep 2023 12:49:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232969AbjISTtQ (ORCPT + 99 others); Tue, 19 Sep 2023 15:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232952AbjISTtO (ORCPT ); Tue, 19 Sep 2023 15:49:14 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFCF6F0 for ; Tue, 19 Sep 2023 12:49:08 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-404f881aa48so25605e9.0 for ; Tue, 19 Sep 2023 12:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695152947; x=1695757747; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/YB5lVTEo2oIGM22JEX9SYzDoyZreOUPzeoeG//8zcw=; b=rSzxSb4lPSs6zf+HtOamNlnaZNA+6CuWlZP5iTkQl9d6551+GzZ6R/qrA3EpDtyVmg LmV/5oFS+XMPdEurjKji72WQtcLvc+VmmcOb9/qUFepgvekrDtxW4TBUSq0o2676CGdX 5Nf1VUc2CKEuyuyfUyT3WgvmEaqluCCOITxIBX6MciKDc2Tb0NhY7VxEtwLHClw7d4n3 jKAqPY74ocbFNJYkNzNG1q7+i+Qoa+oihVoF7JeoLpmAdptGX6DoTQc2QySourFg1Z4u KqgVpT3Ula0C44K/d6XfiAbkRAXTp29u601ktKtDXEeW85d6E/Xdtf+HTETcNot/Xqxp NvUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695152947; x=1695757747; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/YB5lVTEo2oIGM22JEX9SYzDoyZreOUPzeoeG//8zcw=; b=wvSuW1vxJcDz+5I/WWD5OTsFplASmuRzvyfFQARFjiDhNncGH2ttyXQMKum8qAPOKt 0wFnbVkaImOn6Oc0A275geWfJqNO+/ALEyME//dJpPCdTDj7Af6muWzY1zz/vOmj5/hf kPSwr8Om+YGKAiiAmK3sD5z40ccUBAb21lQFYrg9lkDiaEs6hKlLnb4z5f6CTgL05bql 6PcZXxVavWguEytcXMRfxrHqiY+0CIZHs7Fg43Go0K1Szyf4JA9AJ52WCLgmeJWIR3xY Ps0IbwXqIocwWKSXC5lzJGY1fOUCrd9tmblZpPXUeGy9Hrp3H4urpH0zkjNFF4vGjvlJ 4NsQ== X-Gm-Message-State: AOJu0YwDdKItOgj4wrfvVDURBd8LO5n/OZc8HF8MQKQZDiF41EpFLkbK l/nuiAGeyGS0zyFzGCxLZDBGRZmRv/pIFuhLW2TU+A== X-Received: by 2002:a05:600c:1d06:b0:3fe:d691:7d63 with SMTP id l6-20020a05600c1d0600b003fed6917d63mr16494wms.6.1695152947216; Tue, 19 Sep 2023 12:49:07 -0700 (PDT) MIME-Version: 1.0 References: <20230911-kms-slow-tests-v1-0-d3800a69a1a1@kernel.org> <20230911-kms-slow-tests-v1-1-d3800a69a1a1@kernel.org> In-Reply-To: <20230911-kms-slow-tests-v1-1-d3800a69a1a1@kernel.org> From: Rae Moar Date: Tue, 19 Sep 2023 15:48:55 -0400 Message-ID: Subject: Re: [PATCH 1/2] kunit: Warn if tests are slow To: Maxime Ripard Cc: Brendan Higgins , David Gow , David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , =?UTF-8?B?TWHDrXJhIENhbmFs?= , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:49:16 -0700 (PDT) On Mon, Sep 11, 2023 at 5:51=E2=80=AFAM Maxime Ripard = wrote: > > Kunit recently gained support to setup attributes, the first one being > the speed of a given test, then allowing to filter out slow tests. > > A slow test is defined in the documentation as taking more than one > second. There's an another speed attribute called "super slow" but whose > definition is less clear. > > Add support to the test runner to check the test execution time, and > report tests that should be marked as slow but aren't. > > Signed-off-by: Maxime Ripard Hi! I like this idea especially if it was helpful in identifying slow tests already! I have a few thoughts on this. I share Jani's concern for warning all tests on slow machines. I can think of a few options. First, we could increase the threshold to about 2s even though that would eliminate warnings on potentially slow tests. However, this would point out the slowest tests. Second, we could change this to warn users only when they choose by making this a configurable option or making this a script to output a list of all unmarked slow tests. Third, we could leave this as is. As the KUnit warnings do not show up in the kunit.py output and do not cause the test to fail in any way they are relatively harmless if they are unwanted by the user. Not quite sure which I prefer? The second option might be the cleanest for the user and the time threshold could even be customizable. Let me know what you think. > --- > lib/kunit/test.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/lib/kunit/test.c b/lib/kunit/test.c > index 49698a168437..a3b924501f3d 100644 > --- a/lib/kunit/test.c > +++ b/lib/kunit/test.c > @@ -379,6 +379,9 @@ static void kunit_run_case_internal(struct kunit *tes= t, > struct kunit_suite *suite, > struct kunit_case *test_case) > { > + struct timespec64 start, end; > + struct timespec64 duration; > + > if (suite->init) { > int ret; > > @@ -390,7 +393,20 @@ static void kunit_run_case_internal(struct kunit *te= st, > } > } > > + ktime_get_ts64(&start); > + > test_case->run_case(test); > + > + ktime_get_ts64(&end); > + > + duration =3D timespec64_sub(end, start); > + > + if (duration.tv_sec >=3D 1 && > + (test_case->attr.speed =3D=3D KUNIT_SPEED_UNSET || > + test_case->attr.speed >=3D KUNIT_SPEED_NORMAL)) > + kunit_warn(test, > + "Test should be marked slow (runtime: %lld.%09= lds)", > + duration.tv_sec, duration.tv_nsec); I would consider moving this if statement into a separate function. > } > > static void kunit_case_internal_cleanup(struct kunit *test) > > -- > 2.41.0 > > -- > You received this message because you are subscribed to the Google Groups= "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an= email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgi= d/kunit-dev/20230911-kms-slow-tests-v1-1-d3800a69a1a1%40kernel.org.