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 68AD7C433F5 for ; Tue, 26 Apr 2022 12:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240719AbiDZM1u (ORCPT ); Tue, 26 Apr 2022 08:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242525AbiDZM1s (ORCPT ); Tue, 26 Apr 2022 08:27:48 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D96915B46A for ; Tue, 26 Apr 2022 05:24:40 -0700 (PDT) X-UUID: 2c58419259d24d078553ea889523f2d8-20220426 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.4,REQID:0dce5ab4-1fac-480d-949c-68865cd4a741,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-20,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,AC TION:release,TS:-20 X-CID-META: VersionHash:faefae9,CLOUDID:84718ac6-85ee-4ac1-ac05-bd3f1e72e732,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,File:nil,QS:0,BEC:nil X-UUID: 2c58419259d24d078553ea889523f2d8-20220426 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 233419910; Tue, 26 Apr 2022 20:24:33 +0800 Received: from mtkexhb02.mediatek.inc (172.21.101.103) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 26 Apr 2022 20:24:11 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkexhb02.mediatek.inc (172.21.101.103) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 26 Apr 2022 20:24:10 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 26 Apr 2022 20:24:10 +0800 From: Mark-PK Tsai To: CC: , , , , , , Subject: [PATCH v4 0/2] tracing: make tracer_init_tracefs initcall asynchronous Date: Tue, 26 Apr 2022 20:24:05 +0800 Message-ID: <20220426122407.17042-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move trace_eval_init() to subsys_initcall to make it start earlier. And to avoid tracer_init_tracefs being blocked by trace_event_sem which trace_eval_init() hold [1], queue tracer_init_tracefs() to eval_map_wq to let the two works being executed sequentially. It can speed up the initialization of kernel as result of making tracer_init_tracefs asynchronous. On my arm64 platform, it reduce ~20ms of 125ms which total time do_initcalls spend. Changes in v2: - Fix the use of ftrace_eval_maps in INIT_DATA after initmem_free(). In v1, a kthread is create for tracer_init_tracefs() which might cause kernel crash if initmem is free before it finish. In v2, the work of tracer_init_tracefs() is separated into 2 parts, one is put to subsys_initcall and the other is queue to eval_map_wq which can make sure it always finish before initmem is free. Changes in v3: - Avoid adding tracer option before __update_tracer_options finish to fix the warning report by kernel test robot. Reported-by: kernel test robot https://lore.kernel.org/lkml/20220322133339.GA32582@xsang-OptiPlex-9020/ Changes in v4: - Set `tracer_options_updated = true` before calling __update_tracer_options(). Otherwise, __update_tracer_options() will skip all the tracer in trace_array. - Init tracerfs_init_work only when eval_map_wq is successfully created. Mark-PK Tsai (2): tracing: Avoid adding tracer option before update_tracer_options tracing: make tracer_init_tracefs initcall asynchronous kernel/trace/trace.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) -- 2.18.0