From patchwork Mon Aug 14 13:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 13620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2790044vqi; Mon, 14 Aug 2023 07:42:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHD7rLxK85OR83Sd+Zdp+F7P1gcSGJZPTlYAOSSLX40ZYsbIGsDjjC++Q2Wwu2+REOTj37u X-Received: by 2002:a05:6a21:3e0d:b0:13f:c40c:379 with SMTP id bk13-20020a056a213e0d00b0013fc40c0379mr10246451pzc.13.1692024148147; Mon, 14 Aug 2023 07:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692024148; cv=none; d=google.com; s=arc-20160816; b=EMHKz5LuLTvXQFevnBeVLkmaziaAQbAafteOHcZ1OUznuAewxfWikXi/FoluzpA36O GJQhXjo150DhLT/QNgUCa1KLDUD62O3LvHg+VPjPhM04Mn/+a+08wSKIbghr4n7Jjbvg UheKiunZ8fnI9Q7XavrWgnKS6dSde8dZpWklzxoA4cgX9Rwax/X1/kMywlpMMFPFzq6U c4QCzvUiBdVJRopIZxAUvDkBx+KHRMmyt0dnSkxt9k3WbLTq3gK/xC631mkI06ywkmZo T4mrzEb+bdHcrLaTPwCKYkSyzBfLdCd4isOXtWDrNxMHrlxxme69DKcIjctdkaJnGutA 3ZEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=R9IR6nMh0ngh6Bv7iNtA/5Z0sgh77bKDUoglSCnPwhU=; fh=bGF4ESczbIrmrNxFOdEMfzJNgTVkRsqDRt+LRN0CeSg=; b=x2ItAjxVJLEKyKHHBGoZgNhg5RgJJnWpBnlYToImToldRjDfn0fX/pWxjzaDBxLyVr GUUKixIIepWT16tpDVh2JDHo/L43A2vFUMRM8ayaCc1KVdJ0y3h+eHT6l+5KhpTsalY0 LJy2xeX06r/+Weo5668Df+VmyULxt/v3m1oiTb1D5lnDr/Z5VDqe/c7gYqOUMmG2VQOy 9v2EbD7DqMmR1hVTIG36mcGR47NMjSr56yzEKgFRR5MMV4vabSbfuA+Tqdss1aSKrs1g 92jA8s/Hjft5PRgLA4goKLwIA3KAI5MoB2acaquItk1LeL/A3NTgyrYp3bnOLyBkDH/q FUsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=K7iwZAnj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k37-20020a634b65000000b0055c7f16bb2bsi8003180pgl.449.2023.08.14.07.42.13; Mon, 14 Aug 2023 07:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=K7iwZAnj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230518AbjHNN2k (ORCPT + 99 others); Mon, 14 Aug 2023 09:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbjHNN2c (ORCPT ); Mon, 14 Aug 2023 09:28:32 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A475A3 for ; Mon, 14 Aug 2023 06:28:24 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 37EBX0QW010808; Mon, 14 Aug 2023 08:23:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=PODMain02222019; bh=R 9IR6nMh0ngh6Bv7iNtA/5Z0sgh77bKDUoglSCnPwhU=; b=K7iwZAnjnUgn86Npf WtFN+uUtrR/tvK14X0A3X5f+tlaRZxvkkkW/n56fnUJVhkWsunK4Ng6xwRWhQwLU p9iax0j+SWvgQeI7ao6Sr9MISdNIvNOT0NLYlPIRvbFeYlW2BFown6Sr5mfOkoNs tlNeJRKgR2Kao7YQLWPNqjtOJqawgizLsQlEYR+4ToOgArNMLdxZIuilopjXW6OH bgS97cIVqQ8Qv1XfGervJgP7YWAuCPKmzI8Th8IDvO4lCudlplCn+2wfb2r5qDaA lwLrgKeE3vzxJppwUIryZBCPeUS0su6HjtDpND+0HlSvj/uHCdLqrsg7zP/T+4AO lfsNg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3se6uhhvdp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Aug 2023 08:23:13 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 14 Aug 2023 14:23:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.30 via Frontend Transport; Mon, 14 Aug 2023 14:23:11 +0100 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.65.68]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 70759458; Mon, 14 Aug 2023 13:23:11 +0000 (UTC) From: Richard Fitzgerald To: , , CC: , , , , Richard Fitzgerald Subject: [PATCH v4 00/10] kunit: Add dynamically-extending log Date: Mon, 14 Aug 2023 14:22:59 +0100 Message-ID: <20230814132309.32641-1-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-GUID: 8Jih5ue5vraZN-04bVM6xMogy14Z2A6L X-Proofpoint-ORIG-GUID: 8Jih5ue5vraZN-04bVM6xMogy14Z2A6L X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774215913462986494 X-GMAIL-MSGID: 1774215913462986494 This patch chain changes the logging implementation to use string_stream so that the log will grow dynamically. The first 8 patches add test code for string_stream, and make some changes to string_stream needed to be able to use it for the log. The final patch adds a performance report of string_stream. CHANGES SINCE V3: Completely rewritten to use string_stream instead of implementing a separate extending-buffer implementation for logging. I have used the performance test from the final patch on my original fixed-size-fragment implementation from V3 to get a comparison of the two implementations (run on i3-8145UE CPU @ 2.20GHz): string_stream V3 fixed-size-buffer Time elapsed: 7748 us 3251 us Total string length: 573890 573890 Bytes requested: 823994 728336 Actual bytes allocated: 1061440 728352 I don't think the difference is enough to be worth complicating the string_stream implementation with my fixed-fragment implementation from V3 of this patch chain. Richard Fitzgerald (10): kunit: string-stream: Improve testing of string_stream kunit: string-stream: Don't create a fragment for empty strings kunit: string-stream: Add cases for adding empty strings to a string_stream kunit: string-stream: Add option to make all lines end with newline kunit: string-stream: Add cases for string_stream newline appending kunit: string-stream: Pass struct kunit to string_stream_get_string() kunit: string-stream: Decouple string_stream from kunit kunit: string-stream: Add test for freeing resource-managed string_stream kunit: Use string_stream for test log kunit: string-stream: Test performance of string_stream include/kunit/test.h | 14 +- lib/kunit/Makefile | 5 +- lib/kunit/debugfs.c | 36 ++- lib/kunit/kunit-test.c | 52 +--- lib/kunit/log-test.c | 72 ++++++ lib/kunit/string-stream-test.c | 447 +++++++++++++++++++++++++++++++-- lib/kunit/string-stream.c | 129 +++++++--- lib/kunit/string-stream.h | 22 +- lib/kunit/test.c | 48 +--- 9 files changed, 656 insertions(+), 169 deletions(-) create mode 100644 lib/kunit/log-test.c