Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp719075rwb; Thu, 15 Dec 2022 01:15:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf4VXQZAUDYgS9KY0P9MBzklILAzuj/QOmbY0+J8DOM5OjUs2MC3Iy9fYtjm9TT62vnZMSq/ X-Received: by 2002:a17:902:b68b:b0:18e:c921:c53b with SMTP id c11-20020a170902b68b00b0018ec921c53bmr19294032pls.68.1671095703521; Thu, 15 Dec 2022 01:15:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671095703; cv=none; d=google.com; s=arc-20160816; b=OI1tBe3vPvQbXMUSMpPNTkTiKSLXIz3Rn/ySWslkhX9/iQfOud5VN+KOIx8Fb8DYSM pGUitBQePINHnR7pzdoAmnBR9XgPmOSjvUFBGF9CdDPtCLVkkAvmdIDoAQew385blRGe c8s44XCsweI+6BoWq4zAd9Bxi9mzWPj5IpnZv0St7C3arhwLSHn5PdYxzFHFlV1yLHyw TXzsmT1uGPtsagmfSIth1Y1bCTrC3fJHdCGDgpc8GkXSl34Xtcydah4lO1Uic+cJ+y6z ev094MTNwBLt9NFawsWtINGWp8ciHfYspsAnWk5PY6pIFE6dYFLZWa5YqmwaCPGtCh2z 8YWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=IObtWoKZrv/byxcXlzYwmVNDpTjH/MksUA6nr3afl+k=; b=sw/WCTYR0GXPg/xkrHswrEf4imyxNSuz7UUduqdelKK27QR62i88t8ep1NHEpUAyhD wLG6xmdEvgtyAdrL0PVAgGbZXNN0MzJOePDF50l8NJQZywufTsPZ0Fwj99tuN53qk6MG XyPbCdDOSLbT3scUlOGAOB7MCNDl1QigarNbpguq54BECrQolOszqV1REM9YdL2Ow42s Ouvo7Jbk1Bd6nktmj1Z4cnqD+68rUeAEUJ/phFTa11Sd3WRu11l9xeHIHgL7V+5x7ZQV hXiIX/WoJQkZqPctgwKnqtPTJhuLAAI0KDuMQ/CCSWFhQvAGDXtmy/PWcdfNG6VzFt5g sRHA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d22-20020a63d716000000b004782dc93af4si2421505pgg.307.2022.12.15.01.14.54; Thu, 15 Dec 2022 01:15:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229471AbiLOIvD (ORCPT + 68 others); Thu, 15 Dec 2022 03:51:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiLOIvA (ORCPT ); Thu, 15 Dec 2022 03:51:00 -0500 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FAB1FCD0; Thu, 15 Dec 2022 00:50:59 -0800 (PST) Received: by mail-qt1-f176.google.com with SMTP id x11so4591379qtv.13; Thu, 15 Dec 2022 00:50:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=IObtWoKZrv/byxcXlzYwmVNDpTjH/MksUA6nr3afl+k=; b=Xp9+gpJ4rk1meUbWBBcHfIIqVAl7AvZI6hBbnQxbwCEBj8izUqW8cLtzeOd5YdsWU+ +vxXqohM7HNGGnE/5Ez7GU53pQzpSIFzoKbzaFzfLVC1tXKqMmQZe4spZMjo52aziuEZ o2SF+0F5yX8ahX7cslr4UnX5wQ8uyXJd8CtRXLz6SUgMsccxwzQheMkhV60+9TKVJRyp w1oaLLhb6eXBkI3jeG2B5fbHiHFcR2QKRspZWvthqadfgEibx5D0sPApv+m/adPv5ALN HG0lx1CuDMsEN8g5MiZmGXwWNg267tLAIN7LYWaGUusjglpF/A52jNc+pA5IAMrhR7rT nJKg== X-Gm-Message-State: ANoB5pl7CZyvvlt+3q8GE/9axV3sb5HS3I+hzoJld3T4CRGjYUT5+d8j FNE5aFLP5U8WxHvRgoALfT0bI1AA+6s4lw== X-Received: by 2002:a05:622a:249:b0:3a5:7967:e652 with SMTP id c9-20020a05622a024900b003a57967e652mr52772818qtx.68.1671094258156; Thu, 15 Dec 2022 00:50:58 -0800 (PST) Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com. [209.85.219.181]) by smtp.gmail.com with ESMTPSA id ay41-20020a05622a22a900b003a5c60686b0sm3105518qtb.22.2022.12.15.00.50.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 00:50:57 -0800 (PST) Received: by mail-yb1-f181.google.com with SMTP id v126so947319ybv.2; Thu, 15 Dec 2022 00:50:56 -0800 (PST) X-Received: by 2002:a25:d655:0:b0:6fc:1c96:c9fe with SMTP id n82-20020a25d655000000b006fc1c96c9femr34386835ybg.36.1671094256707; Thu, 15 Dec 2022 00:50:56 -0800 (PST) MIME-Version: 1.0 References: <20221115083349.1662-1-thunder.leizhen@huawei.com> In-Reply-To: <20221115083349.1662-1-thunder.leizhen@huawei.com> From: Geert Uytterhoeven Date: Thu, 15 Dec 2022 09:50:45 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9] kallsyms: Add self-test facility To: Zhen Lei Cc: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Yamada , Alexei Starovoitov , Jiri Olsa , Kees Cook , Andrew Morton , Luis Chamberlain , linux-modules@vger.kernel.org, Steven Rostedt , Ingo Molnar , David Laight , linux-m68k Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Hi Zhen, On Tue, Nov 15, 2022 at 9:41 AM 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 Thanks for your patch, which is now commit 30f3bb09778de64e ("kallsyms: Add self-test facility") in linus/master. I gave this a try on m68k (atari_defconfig + CONFIG_KALLSYMS_SELFTEST=y), but it failed: start kallsyms_lookup_name() for kallsyms_test_func_static failed: addr=0, expect 60ab0 kallsyms_lookup_name() for kallsyms_test_func failed: addr=0, expect 60ac0 kallsyms_lookup_name() for kallsyms_test_func_weak failed: addr=0, expect 60ac2 kallsyms_lookup_name() for vmalloc failed: addr=0, expect c272a kallsyms_lookup_name() for vfree failed: addr=0, expect c2142 kallsyms_on_each_match_symbol() for kallsyms_test_func_static failed: count=0, addr=0, expect 60ab0 kallsyms_on_each_match_symbol() for kallsyms_test_func failed: count=0, addr=0, expect 60ac0 kallsyms_on_each_match_symbol() for kallsyms_test_func_weak failed: count=0, addr=0, expect 60ac2 kallsyms_on_each_match_symbol() for vmalloc failed: count=0, addr=0, expect c272a kallsyms_on_each_match_symbol() for vfree failed: count=0, addr=0, expect c2142 abort Given all addresses are zero, it looks like some required functionality or config option is missing. $ grep SYM .config CONFIG_KALLSYMS=y CONFIG_KALLSYMS_SELFTEST=y CONFIG_KALLSYMS_BASE_RELATIVE=y # CONFIG_ASYMMETRIC_KEY_TYPE is not set CONFIG_SYMBOLIC_ERRNAME=y # CONFIG_STRIP_ASM_SYMS is not set CONFIG_KALLSYMS_SELFTEST Do you have a clue? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds