Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1221296rwb; Thu, 15 Dec 2022 07:43:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Gw8BpsYZVHH72Fb8SlcVOn7hnPghAEpNygZ2De9Z72AvoINANXB1g2tJu4/wpUFI9TM/s X-Received: by 2002:a05:6a20:93a3:b0:ad:a277:e57f with SMTP id x35-20020a056a2093a300b000ada277e57fmr20155608pzh.34.1671119038330; Thu, 15 Dec 2022 07:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671119038; cv=none; d=google.com; s=arc-20160816; b=Qa28LZ1vwgoG54hW2Pi+PW43Jt25ffoKIzXr1RKwetfG24IiNYkiNmfqEpTCgRgqK0 5WkFhnW1yQ3OZ2jfOKxSv3lmwbMJwyOSYBZaWG/e+atgBd7Oms+WrjqaUC9XJclQ3l+C DbCMCqncM3rdcs/vEjJLWqAcpAcPbV8304tVY37afQELTf3BZyHjx9DVpkNSfxadjP9u HqkJq+c9LUeFsKxJ+2XNoV/TdJ+k5UiMy40svxFXMshS8FD2kB6UqYoeTZyGW8qm32VT gwe4wu2bGApAz/jMNTIChKgX0hw8j0aaaJuUaciIPQTSm+oC6wJ6rkfGsJKcoMQGKjR2 hXug== 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=e+PJ8OM02fEspKYgpZeR8IY6KQB1JYasGRGdsiTWkdU=; b=aN30F4I5cc34geLBQUT0lCobJTh5P8/MvT4tiji5rCkQ+DzQ59hz+eSrH6L794vP1S IB4lp/Xp2Fspln6X1tjLHmBpJWqcEBkklY1/uq0yn2lyWgPM32jjngNa9Qw+TFAvNIim yhoxmbwipMC5mz0g4AGuDM5pjIswn+JaGLWsyrgoJQ7zM3cAAQKP3PHJzKLe1toH1MDa 0iXJDQQDiAQh1ByUTkrtS67q4CBVbhnV2hKvTIS7TKWbRQAGJjG1KV9c7Z+UpQxKrnZ1 xUGZAPCGBiPyJ2KMr5zt3LWYtJlUZqcvnWeKJKZaHd+s7nuBitRegUXjJw8t1qxOq7Xd zrcg== 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 b9-20020a63d809000000b004822e22082esi2136074pgh.249.2022.12.15.07.43.49; Thu, 15 Dec 2022 07:43:58 -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 S229652AbiLOOnT (ORCPT + 68 others); Thu, 15 Dec 2022 09:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbiLOOnP (ORCPT ); Thu, 15 Dec 2022 09:43:15 -0500 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D21B2F007; Thu, 15 Dec 2022 06:43:14 -0800 (PST) Received: by mail-qt1-f178.google.com with SMTP id ay32so5235401qtb.11; Thu, 15 Dec 2022 06:43:14 -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=e+PJ8OM02fEspKYgpZeR8IY6KQB1JYasGRGdsiTWkdU=; b=AId3zPz7HUrq12V14Ztevj2wX+5sTu26NaCt+pg6lVCvt/+iIwvPTo1uLUMBaJPc+S pJBIeD/R6Ags2+aZRQSnXgD/ezjUDusIe+O+lZBE06WD7QaHNcs3PVOGuIuVGVJgplqx C5foZKb/ayQnNX4AjhuG80K2w9M38dvrwmUau3YQhAvesFJ4ohdLM1CpdAw07+0icvHI 4h8ilVw3NkYDlRbkK8G1vljsEMBy6UN3a/tIXBs11qkU/tMiKfJxHvlPRaTTND+97CtX 3LwFfqZmuVhccE4HcSp9V1Xk8oUDOIFDU89MF/RTrbyuw9EuNAsZYQNRkB4CYZls2KIL kuGA== X-Gm-Message-State: ANoB5pmkEQtjAM7x0b/NUbRygX1M1ffJrGq31NQmaZgHGGQcYcG6sjKP oHtI82UUTCFW/HaAooC25kmQOHFzZoSE6g== X-Received: by 2002:ac8:7a85:0:b0:3a8:28fb:b076 with SMTP id x5-20020ac87a85000000b003a828fbb076mr12407213qtr.31.1671115393001; Thu, 15 Dec 2022 06:43:13 -0800 (PST) Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com. [209.85.128.172]) by smtp.gmail.com with ESMTPSA id x8-20020ac84d48000000b00398a7c860c2sm3547853qtv.4.2022.12.15.06.43.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 06:43:12 -0800 (PST) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-3e78d07ab4fso43670827b3.9; Thu, 15 Dec 2022 06:43:12 -0800 (PST) X-Received: by 2002:a0d:dd4b:0:b0:370:61f5:b19e with SMTP id g72-20020a0ddd4b000000b0037061f5b19emr28138210ywe.316.1671115391829; Thu, 15 Dec 2022 06:43:11 -0800 (PST) MIME-Version: 1.0 References: <20221115083349.1662-1-thunder.leizhen@huawei.com> <49070ac3-02bb-a3b3-b929-ede07e3b2c95@huawei.com> In-Reply-To: <49070ac3-02bb-a3b3-b929-ede07e3b2c95@huawei.com> From: Geert Uytterhoeven Date: Thu, 15 Dec 2022 15:43:00 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9] kallsyms: Add self-test facility To: "Leizhen (ThunderTown)" 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 , "Jason A. Donenfeld" 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_H3,RCVD_IN_MSPIKE_WL,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 Thu, Dec 15, 2022 at 2:58 PM Leizhen (ThunderTown) wrote: > On 2022/12/15 21:24, Geert Uytterhoeven wrote: > > On Thu, Dec 15, 2022 at 1:34 PM Leizhen (ThunderTown) > > wrote: > >> On 2022/12/15 17:39, Geert Uytterhoeven wrote: > >>> On Thu, Dec 15, 2022 at 10:16 AM Leizhen (ThunderTown) > >>> wrote: > >>>> On 2022/12/15 16:50, Geert Uytterhoeven wrote: > >>>>> 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 > Oh, maybe you can "git reset --hard 30f3bb09778de64" and try again. > 30f3bb09778de64 kallsyms: Add self-test facility > > But the latest kernel is OK on x86. So other patches are unlikely to > affect this function. On 30f3bb09778de64 it fails the same way: start kallsyms_lookup_name() for kallsyms_test_func_static failed: addr=8dbc, expect 60308 kallsyms_lookup_name() for kallsyms_test_func failed: addr=8dbc, expect 60318 kallsyms_lookup_name() for kallsyms_test_func_weak failed: addr=8dbc, expect 6031a kallsyms_lookup_name() for vmalloc failed: addr=8dbc, expect bdc88 kallsyms_lookup_name() for vfree failed: addr=8dbc, expect bd6de kallsyms_on_each_match_symbol() for kallsyms_test_func_static failed: count=24890, addr=1ee870, expect 60308 kallsyms_on_each_match_symbol() for kallsyms_test_func failed: count=24890, addr=1ee870, expect 60318 kallsyms_on_each_match_symbol() for kallsyms_test_func_weak failed: count=24890, addr=1ee870, expect 6031a kallsyms_on_each_match_symbol() for vmalloc failed: count=24890, addr=1ee870, expect bdc88 kallsyms_on_each_match_symbol() for vfree failed: count=24890, addr=1ee870, expect bd6de abort > Is m68k big-endian? Yes it is. And 32-bit values are aligned to only 2 bytes. 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