From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58A4AC32771 for ; Fri, 16 Sep 2022 01:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229528AbiIPB1q (ORCPT ); Thu, 15 Sep 2022 21:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiIPB1o (ORCPT ); Thu, 15 Sep 2022 21:27:44 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BF9571BE1; Thu, 15 Sep 2022 18:27:42 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MTGYS4NYcz14QPq; Fri, 16 Sep 2022 09:23:40 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 16 Sep 2022 09:27:40 +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.24; Fri, 16 Sep 2022 09:27:39 +0800 Subject: Re: [PATCH v2 0/8] kallsyms: Optimizes the performance of lookup symbols To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , , , Masahiro Yamada , Alexei Starovoitov , Jiri Olsa , Kees Cook , Andrew Morton , "Luis Chamberlain" , References: <20220909130016.727-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <453a0f71-7478-f118-d547-aa0547abdd73@huawei.com> Date: Fri, 16 Sep 2022 09:27:27 +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: <20220909130016.727-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: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org Hi, everybody: Can anyone review it? Maybe I should split this patch series into two parts: kallsyms and livepatch. In fact, the performance can be improved even if the compression policy of the symbol type is not changed, that is, the scripts/callsyms.c file is not modified, but we perform the len-based filtering first. That way, it'll be easier for everyone to review. OK, I'm ready for v3. On 2022/9/9 21:00, Zhen Lei wrote: > v1 --> v2: > Add self-test facility > > v1: > Currently, to search for a symbol, we need to expand the symbols in > 'kallsyms_names' one by one, and then use the expanded string for > comparison. This is very slow. > > In fact, we can first compress the name being looked up and then use > it for comparison when traversing 'kallsyms_names'. > > This patch series optimizes the performance of function kallsyms_lookup_name(), > and function klp_find_object_symbol() in the livepatch module. Based on the > test results, the performance overhead is reduced to 5%. That is, the > performance of these functions is improved by 20 times. > > To avoid increasing the kernel size in non-debug mode, the optimization is only > for the case CONFIG_KALLSYMS_ALL=y. > > Zhen Lei (8): > scripts/kallsyms: don't compress symbol type when > CONFIG_KALLSYMS_ALL=y > scripts/kallsyms: rename build_initial_tok_table() > kallsyms: Adjust the types of some local variables > kallsyms: Improve the performance of kallsyms_lookup_name() > kallsyms: Add helper kallsyms_on_each_match_symbol() > livepatch: Use kallsyms_on_each_match_symbol() to improve performance > livepatch: Improve the search performance of > module_kallsyms_on_each_symbol() > kallsyms: Add self-test facility > > include/linux/kallsyms.h | 8 ++ > init/Kconfig | 13 ++ > kernel/Makefile | 1 + > kernel/kallsyms.c | 135 ++++++++++++++++++++- > kernel/kallsyms_selftest.c | 243 +++++++++++++++++++++++++++++++++++++ > kernel/livepatch/core.c | 25 +++- > kernel/module/kallsyms.c | 13 +- > scripts/kallsyms.c | 19 ++- > 8 files changed, 441 insertions(+), 16 deletions(-) > create mode 100644 kernel/kallsyms_selftest.c > -- Regards, Zhen Lei