Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1240926pxb; Fri, 21 Jan 2022 13:08:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyV8h0Kc3AP+Ren5CLLkA54xwp7r4WPW0xJAk/sECcGnpkpDWxVTObP02ENzQjJpLHSgazN X-Received: by 2002:a17:902:b688:b0:149:a1d6:c731 with SMTP id c8-20020a170902b68800b00149a1d6c731mr5264027pls.145.1642799303087; Fri, 21 Jan 2022 13:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799303; cv=none; d=google.com; s=arc-20160816; b=ZPKfCBUJpeiAiAKtME7XiUOBqwhqSnDxPqsiHPUvES6lKdfuDFbnB1vq/HBNgDpT1u dTjhWnQ5xDkcvJcXqA3JgTvb00itmsbUWg9sFhBCQDY2Ym4U9RVcckDLAGoGNAZ8EqdJ gF/EEjk8lAd+bWdq2Uf1qi6WxxQjgtxhY5SK3vLz8p36ppSk6LbazDeDULRD8Ykfo+z5 yvrke5TUv3MBYw8PCMJiE6Ab/By3qUPQNpoZWK5HDGbRfW4ZdAnqiUk08ZDPgcE8KLMn REWSL5+M6pJLpjZpKBQi+6oviPXaFBgq1dVRvYdca5qF4FZbHNxRVukw0Ew92TSbdUUN /aIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KhyhwE3CHJG0B5F6U7HDGNGF80WPUFSFTmXHqgzZiOw=; b=TwN8axXzElUNOJqiCvvc84RtBfY4FiTo17JYdKgWK8+lU4qoZysCifUN70QwfBLUf+ LxkK7/1f7yqIzc4mc7kF+IGr/ycvcNxckCxgKaHxcqaSrjFMb9/nv1/0WYGrE/S557LL MnHDAuUUetHXbatuMVQBg1m0RGdlTiKNDogSnTBHb5OokerxJrk/iUt2rcZqTQ0JwBXp VOtrQ6M5Cf0uQi0jIZDsNdS/BD2UcDFY52GCebvsGvAX9+XDVtdH20IerFbkeU79Vf6Y aRSYAcUUOsGkFCguYdsY2X/e23sYE8xp4TD5J3Ou/ZticqEmxE7I56XmbObdBUiuOqU6 obZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OgobDuIg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si7005504plq.290.2022.01.21.13.08.11; Fri, 21 Jan 2022 13:08:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OgobDuIg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237543AbiATHAs (ORCPT + 99 others); Thu, 20 Jan 2022 02:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231164AbiATHAr (ORCPT ); Thu, 20 Jan 2022 02:00:47 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B4C4C061574 for ; Wed, 19 Jan 2022 23:00:47 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id h12so4869689pjq.3 for ; Wed, 19 Jan 2022 23:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KhyhwE3CHJG0B5F6U7HDGNGF80WPUFSFTmXHqgzZiOw=; b=OgobDuIgA9duQXU2Cd3SfEWbNR+WG/wX/ddOj10SQAFnxJZLt00GzM8JV2pQfeWpZ/ xoyotaVVO9dKM6kF/AR+xDQBrHStlCkYBAEQMSWYJaBn7gFqbL5XMeaqp823Paq4qwhP Otc0vVJT9sAymFfAGRGL2BfMnQnkovW+CHgznwNe8yrDews4RnMxgw8s3imrRqE+3CYv 3++FeH//mLKa1PfnStqph4emVMj81upshs3VJKUCa3Qvr1BYNRuLSWnTc42AKIyPslEX 7JNqAE4L0DImJZitAEHbF9p3VStnd19TJ/y45LGDoDnykM7EI59/G/9gXB8GCBDwLT3d 1JSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KhyhwE3CHJG0B5F6U7HDGNGF80WPUFSFTmXHqgzZiOw=; b=ckj+DdBh18MUO7YGoQKQGRC5H3fY4C7tHiR7TinOoMKmKg6+rjnhHGYh1XArmxccjW Qit/Q52Vf5uUOp3CIKp5PAaFdVVyeDxmDXLuGGLiaoDZyX2KzeVBdtI1JFihzcA50mRw aIKDMTheJHQr+gtp6ib34GTshyAycqDX+kaA7UnOabp3VgXI9lMzKSPMgAK/i7xPjZBb Z8TiqnbEMkBs7oEnb1xh7sCRLHiWa8R5TBJ/oqstAdoOpgM3do5m8cT2KBbSdqdWUO7R 8z3vvGnfp8d3u/xf2khe17Ea8oyB5eIpG3tjO1rsJC+z7QlrZj3G1Z2Gwz7m0uMQxIYL MMYw== X-Gm-Message-State: AOAM531vzzP3s5dLZpGFAgBPimd/dsYdh3aum0BZJS/2YX5IrKpYigOw E44DNN9VtJ4OO4Duy6t/1co= X-Received: by 2002:a17:902:b414:b0:149:61c7:d550 with SMTP id x20-20020a170902b41400b0014961c7d550mr36717502plr.129.1642662046662; Wed, 19 Jan 2022 23:00:46 -0800 (PST) Received: from vultr.guest ([141.164.42.249]) by smtp.gmail.com with ESMTPSA id y6sm1954296pfa.66.2022.01.19.23.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 23:00:46 -0800 (PST) From: Yuntao Wang To: Steven Rostedt Cc: Lukas Bulwahn , Ingo Molnar , linux-kernel@vger.kernel.org, Yuntao Wang Subject: [PATCH v2] tracing: Deal with error return code of the ftrace_process_locs() function Date: Thu, 20 Jan 2022 06:59:49 +0000 Message-Id: <20220120065949.1813231-1-ytcoode@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220119095741.1fff2305@gandalf.local.home> References: <20220119095741.1fff2305@gandalf.local.home> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ftrace_process_locs() function may return -ENOMEM error code, which should be handled by the callers. Signed-off-by: Yuntao Wang --- Changes since v1: - Deal with error return code instead of just removing it kernel/trace/ftrace.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 6163b6f762f7..eb98797b399b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6791,11 +6791,16 @@ void ftrace_module_enable(struct module *mod) void ftrace_module_init(struct module *mod) { + int ret; + if (ftrace_disabled || !mod->num_ftrace_callsites) return; - ftrace_process_locs(mod, mod->ftrace_callsites, - mod->ftrace_callsites + mod->num_ftrace_callsites); + ret = ftrace_process_locs(mod, mod->ftrace_callsites, + mod->ftrace_callsites + mod->num_ftrace_callsites); + if (ret) + pr_warn("ftrace: failed to allocate entries for module '%s' functions\n", + mod->name); } static void save_ftrace_mod_rec(struct ftrace_mod_map *mod_map, @@ -7126,15 +7131,19 @@ void __init ftrace_init(void) pr_info("ftrace: allocating %ld entries in %ld pages\n", count, count / ENTRIES_PER_PAGE + 1); - last_ftrace_enabled = ftrace_enabled = 1; - ret = ftrace_process_locs(NULL, __start_mcount_loc, __stop_mcount_loc); + if (ret) { + pr_warn("ftrace: failed to allocate entries for functions\n"); + goto failed; + } pr_info("ftrace: allocated %ld pages with %ld groups\n", ftrace_number_of_pages, ftrace_number_of_groups); + last_ftrace_enabled = ftrace_enabled = 1; + set_ftrace_early_filters(); return; -- 2.34.1.75.gabe6bb3905