Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6621501rwb; Tue, 15 Nov 2022 00:59:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf71Q3zDP1pzMC6kYx+HW6HWtvxwbyWPfqZft0d/G/fpfqMv99lES8Wc8/zk5oEWVnrTOkG1 X-Received: by 2002:a63:d810:0:b0:46f:98ce:2311 with SMTP id b16-20020a63d810000000b0046f98ce2311mr14848181pgh.413.1668502756548; Tue, 15 Nov 2022 00:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668502756; cv=none; d=google.com; s=arc-20160816; b=nmyA1Jt+27JxKJQ9RUcrn6ScVYeoGNYAzPAUeG0l6KpT9mhV2hFLeWZUMc7nPebiak xkMU0s5i7jszylmBiA+gnxObEeTQUqIjD/FmykLSF2TyzrReQ7G8NdsCk6cnoW6fEhmC LVQIELDT/W+PBFV4Noy04Pmt3s9CIcz1qPbDPd2qXj28tYxim5j6TUF/o+Re2JaUokHv ST3nKHhG0aiCOZjYWC1+SZWbZcSQ5AG9hn9/Iu4uEOa8zSHa9YdqEUNoQ9xmB/JOkjx1 jJirdJPAzjiXpc8mh61LT+XJ8BPMduiv2owGE65KjQDyotuj8i9nK+rjmKwC2ZPNQyf9 prtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Br7wfnGC5NUyut7YxxozUW4KhQVe6rOdCak4rhDhcOA=; b=FyeouqxaygDbH9ZSJIMPlQoR2Uf24fy7PZx4P33QNGd7VrQRx2DtLyEkzVC4LQstz6 CfO4Ioo3Oz52SrNjikeF66/ZASFueCDoY2ATmpugMiajfSEqDFtCb3o1ohN0PWaZmpt4 /kX8aj6bsznVop+8wjdR9FrGE8ztsxiHazJt+agyYiMp3awArX5RGcT79LyQDFZwvjad iN6fmNcOo/lRfw3an751qIHtwVwDAeCayLfWdLfbbYpaT7m2f/ww0Lw2wO3uE29hrBHG yGQfKnCT8aoVfn3z0r86mHSp5Hc7NCyAp3eaBPYJ1Bzc+ulUTx/rru6G4Yfhr9c9jGpe sPpA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a170902869000b001870506835bsi10277688plo.601.2022.11.15.00.59.04; Tue, 15 Nov 2022 00:59:16 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232952AbiKOIoI (ORCPT + 89 others); Tue, 15 Nov 2022 03:44:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbiKOIoD (ORCPT ); Tue, 15 Nov 2022 03:44:03 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C72F12091; Tue, 15 Nov 2022 00:44:01 -0800 (PST) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NBKPS5bH9zqSQQ; Tue, 15 Nov 2022 16:40:12 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 16:43:59 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 16:43:58 +0800 Subject: Re: [PATCH v9] kallsyms: Add self-test facility To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , , , Masahiro Yamada , Alexei Starovoitov , Jiri Olsa , Kees Cook , Andrew Morton , "Luis Chamberlain" , , "Steven Rostedt" , Ingo Molnar CC: David Laight References: <20221115083349.1662-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: Date: Tue, 15 Nov 2022 16:43:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20221115083349.1662-1-thunder.leizhen@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 On 2022/11/15 16:33, Zhen Lei wrote: > Added test cases for basic functions and performance of functions > kallsyms_lookup_name(), kallsyms_on_each_symbol() and > kallsyms_on_each_match_symbol(). It also calculates the compression rate > of the kallsyms compression algorithm for the current symbol set. > > The basic functions test begins by testing a set of symbols whose address > values are known. Then, traverse all symbol addresses and find the > corresponding symbol name based on the address. It's impossible to > determine whether these addresses are correct, but we can use the above > three functions along with the addresses to test each other. Due to the > traversal operation of kallsyms_on_each_symbol() is too slow, only 60 > symbols can be tested in one second, so let it test on average once > every 128 symbols. The other two functions validate all symbols. > > If the basic functions test is passed, print only performance test > results. If the test fails, print error information, but do not perform > subsequent performance tests. > > Start self-test automatically after system startup if > CONFIG_KALLSYMS_SELFTEST=y. > > Example of output content: (prefix 'kallsyms_selftest:' is omitted > start > --------------------------------------------------------- > | nr_symbols | compressed size | original size | ratio(%) | > |---------------------------------------------------------| > | 107543 | 1357912 | 2407433 | 56.40 | > --------------------------------------------------------- > kallsyms_lookup_name() looked up 107543 symbols > The time spent on each symbol is (ns): min=630, max=35295, avg=7353 > kallsyms_on_each_symbol() traverse all: 11782628 ns > kallsyms_on_each_match_symbol() traverse all: 9261 ns > finish > > Signed-off-by: Zhen Lei > --- > include/linux/kallsyms.h | 1 + > init/Kconfig | 13 + > kernel/Makefile | 1 + > kernel/kallsyms.c | 2 +- > kernel/kallsyms_selftest.c | 485 +++++++++++++++++++++++++++++++++++++ > kernel/kallsyms_selftest.h | 13 + > 6 files changed, 514 insertions(+), 1 deletion(-) > create mode 100644 kernel/kallsyms_selftest.c > create mode 100644 kernel/kallsyms_selftest.h v8 --> v9: [v8] https://lkml.org/lkml/2022/11/2/225 Adjust the prototype of some callback functions. Because 7/9 and 8/9 in v8 are dropped. -- Regards, Zhen Lei