From patchwork Mon Jan 20 16:36:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Irenge X-Patchwork-Id: 233647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E4BDC33CA1 for ; Mon, 20 Jan 2020 16:36:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74ED02073D for ; Mon, 20 Jan 2020 16:36:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="geQD4FlM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbgATQgm (ORCPT ); Mon, 20 Jan 2020 11:36:42 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:32885 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgATQgm (ORCPT ); Mon, 20 Jan 2020 11:36:42 -0500 Received: by mail-wr1-f65.google.com with SMTP id b6so160689wrq.0 for ; Mon, 20 Jan 2020 08:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dOkzNM5nxgSk+tKouD8MJc8DJm3w+fMwD4IBQWVE0HI=; b=geQD4FlMh5hwtlNh0qJG1Z0u/1zrKbISlLoH/qPVQdR6vrzxfb9djsCDjKdwRh72nX vhv8xFRQJAlmI0Dux9MXuC0bmOlbZIlXVGpxCRvjJ0G4qTHTW+/0xsf7h8/5vd0yOH5n uixPonZqSLCkAIEcyRuLyvtE93ev0qxhVc4om0ivYaHDtX1MZDw9XdRhj5HFZDRTHIh6 Rd2QwB6nQuebLjF4HQoXmidPX4c6yPnpfV/h24WHWO7N3/hNXn6eYRG98hdA/3a3UbpU go4yQY2g9t5rKp78aS8mfaMQquxXvQGsXWMsPvVS1t7yot5c3TxtinbmLNH2dgWfpGGC iKGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dOkzNM5nxgSk+tKouD8MJc8DJm3w+fMwD4IBQWVE0HI=; b=fClAEiWf1GTTZm1bC1HN56rQDT1uxotUUNLJpz/jYoyCSuwAqGXHyNFjFB8iXB/7TJ LeehU30S1BDYEvU5aPbg0NdsJGJfFb15sFOa047HkcsT3Be3m+XHHnvaAgPMch+jsNkv R0rLHCt0yV9o+hDQCHNp3+Z1VbEYH85/O/y/h0OMtR3DhVuvqgQ/gRDr9Cl9JkqS1xQC Z2fV/kgCMLP9y38CYGk+uNq2miHugL8yiOQv20OxgTblACyptnAErpuloJVZBva8Bxgd 2Yr8rDJ+6uB9gktQ7lSxKP/EIqDzj2ey5j+Lnq/YFEM7zijo/9+xMJguSd5bp5e/UduI FBXQ== X-Gm-Message-State: APjAAAUj9i1j5PG4mB8bwwBUZkcwYBizPhEWuKvWsm6cYUkz0C4sJlwl uyLUSUPKQJsvJz+Qkx+3+A== X-Google-Smtp-Source: APXvYqx0pqHT8yYXF47WqCM4x68hp9kZOTqQz/5Vn1VNqAa7k02ydijeniZFEFTwB39UTYAc5JhEDg== X-Received: by 2002:a5d:6a52:: with SMTP id t18mr312250wrw.391.1579538199728; Mon, 20 Jan 2020 08:36:39 -0800 (PST) Received: from ninjahub.org ([91.235.65.22]) by smtp.googlemail.com with ESMTPSA id x7sm47089018wrq.41.2020.01.20.08.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 08:36:39 -0800 (PST) From: Jules Irenge To: jbi.octave@gmail.com Cc: "Steven Rostedt (VMware)" , stable@vger.kernel.org, kbuild test robot Subject: [PATCH 3/7] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Date: Mon, 20 Jan 2020 16:36:18 +0000 Message-Id: <20200120163622.8603-3-jbi.octave@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120163622.8603-1-jbi.octave@gmail.com> References: <20200120163622.8603-1-jbi.octave@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "Steven Rostedt (VMware)" On some archs with some configurations, MCOUNT_INSN_SIZE is not defined, and this makes the stack tracer fail to compile. Just define it to zero in this case. Link: https://lore.kernel.org/r/202001020219.zvE3vsty%lkp@intel.com Cc: stable@vger.kernel.org Fixes: 4df297129f622 ("tracing: Remove most or all of stack tracer stack size from stack_max_size") Reported-by: kbuild test robot Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/trace_stack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index 4df9a209f7ca..c557f42a9397 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c @@ -283,6 +283,11 @@ static void check_stack(unsigned long ip, unsigned long *stack) local_irq_restore(flags); } +/* Some archs may not define MCOUNT_INSN_SIZE */ +#ifndef MCOUNT_INSN_SIZE +# define MCOUNT_INSN_SIZE 0 +#endif + static void stack_trace_call(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct pt_regs *pt_regs) From patchwork Mon Jan 20 16:36:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Irenge X-Patchwork-Id: 233646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7684BC33CB8 for ; Mon, 20 Jan 2020 16:36:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BBBA2073D for ; Mon, 20 Jan 2020 16:36:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ptMjcISU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729121AbgATQgn (ORCPT ); Mon, 20 Jan 2020 11:36:43 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54794 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbgATQgm (ORCPT ); Mon, 20 Jan 2020 11:36:42 -0500 Received: by mail-wm1-f68.google.com with SMTP id b19so212299wmj.4 for ; Mon, 20 Jan 2020 08:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=my3klEdMv2aXl47gDfCMre1jIwXbyGvgJglyXOvxDvo=; b=ptMjcISULgCPNftGjxd+Y+qnIh7ZlYKa9X/KNGrAx46pIiZDTahrK62V3Eu2fsca66 61sd2aODUGLQrV8f/eap8xrUlJP/B8GfNfiQE6VhVe8H42uITQ9B0L9t8CsRd48l3XJ5 UhuHeXK2H4HomE3ckAJBjvj7jeTiht6KEvPXmx/Vy37vkHLyMc8e2b/SNwnYlUj+BXj3 xD8GN066/9fC7x2YpLvWgbuQNQY1+xzcAQu77b08a/T2c0lZcPQvCrgYUJwfBi3WSOlj 6UoiWl+Ry/aVcl1zziQkIPAkfsg033Yj7XI+5cDmoTCO0VrR7V7/9Vo3r65xFN/x+qGA 9/bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=my3klEdMv2aXl47gDfCMre1jIwXbyGvgJglyXOvxDvo=; b=ks//9VqHX4TQNNW/M6rWH9XP672610fCiVqLq+Qr53kOlCXjfiHE2jyCgwfCMQrRPN s3VtF7qm8/XTPSI2wBpyuO6CEgbu3U9GRWYUX/rtlBdpMSh3DT4vgKQSJXLsdt+jGsD5 Kk6e7KRE8AM6b6Xa74Oiv7kBRmp6BXUyySnGqLmMs4Ft8HoVdSdqrcp9D48YoAuKk4Mv DRj4hnXCQg3nyleGFd28jVLvZwfkBdLtWZAOoG3nwJK5sYKG+cYUthy6/8g2vu8tVE9h h0RqQMDLmrE5OrjUCbvlvxsp2dfPvYxCLd7emmOKrEsyy/0H5Nyqc43P1r68RevvWZW2 433g== X-Gm-Message-State: APjAAAXeLDnU7RZJ2ylu1ZUjk2vtqsxdCDGYZlsrLUudl4jXr3MO0i4W tbz6HAmEKb8AF7PdrPxztR+oivDQsQ== X-Google-Smtp-Source: APXvYqwoLM+da5XTG5xwcz216k8hd+a6Cc9iGoOt4iLYUDOsRkUEzN9TF30EzBz5S9HZBhtyVqmGcw== X-Received: by 2002:a7b:c386:: with SMTP id s6mr174680wmj.105.1579538200748; Mon, 20 Jan 2020 08:36:40 -0800 (PST) Received: from ninjahub.org ([91.235.65.22]) by smtp.googlemail.com with ESMTPSA id x7sm47089018wrq.41.2020.01.20.08.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 08:36:40 -0800 (PST) From: Jules Irenge To: jbi.octave@gmail.com Cc: Wen Yang , stable@vger.kernel.org, Steven Rostedt Subject: [PATCH 4/7] ftrace: Avoid potential division by zero in function profiler Date: Mon, 20 Jan 2020 16:36:19 +0000 Message-Id: <20200120163622.8603-4-jbi.octave@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120163622.8603-1-jbi.octave@gmail.com> References: <20200120163622.8603-1-jbi.octave@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wen Yang The ftrace_profile->counter is unsigned long and do_div truncates it to 32 bits, which means it can test non-zero and be truncated to zero for division. Fix this issue by using div64_ul() instead. Link: http://lkml.kernel.org/r/20200103030248.14516-1-wenyang@linux.alibaba.com Cc: stable@vger.kernel.org Fixes: e330b3bcd8319 ("tracing: Show sample std dev in function profiling") Fixes: 34886c8bc590f ("tracing: add average time in function to function profiler") Signed-off-by: Wen Yang Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/ftrace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index ac99a3500076..9bf1f2cd515e 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -526,8 +526,7 @@ static int function_stat_show(struct seq_file *m, void *v) } #ifdef CONFIG_FUNCTION_GRAPH_TRACER - avg = rec->time; - do_div(avg, rec->counter); + avg = div64_ul(rec->time, rec->counter); if (tracing_thresh && (avg < tracing_thresh)) goto out; #endif @@ -553,7 +552,8 @@ static int function_stat_show(struct seq_file *m, void *v) * Divide only 1000 for ns^2 -> us^2 conversion. * trace_print_graph_duration will divide 1000 again. */ - do_div(stddev, rec->counter * (rec->counter - 1) * 1000); + stddev = div64_ul(stddev, + rec->counter * (rec->counter - 1) * 1000); } trace_seq_init(&s); From patchwork Mon Jan 20 16:36:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Irenge X-Patchwork-Id: 233645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40B24C33CAA for ; Mon, 20 Jan 2020 16:36:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 132B721D7E for ; Mon, 20 Jan 2020 16:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fQAjUbwG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbgATQgo (ORCPT ); Mon, 20 Jan 2020 11:36:44 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37931 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbgATQgo (ORCPT ); Mon, 20 Jan 2020 11:36:44 -0500 Received: by mail-wm1-f66.google.com with SMTP id u2so238880wmc.3 for ; Mon, 20 Jan 2020 08:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ALyiENCeDuKpEATpQ1h8kabgaW8aSQkr3Q+Uga+z3qo=; b=fQAjUbwG/NJ9IpKC7iPF9FtqCaWW3aDhrXxPMOXfoK/iVBvgQ0H8z0FVaipFLAeVhM D3NzrKgWqQSaiWXsGuXP4RQdpMsG3kv0J8lv0BJvgeSrL+2FAUgXTQaKAG1d3QxYFmCY rXUJ+GNMPaeMkm59Bztuc0lpyyLQhn0f9iHJVEhyLeguW7FuNBm+yEEBblxzoDDuBVtN a3IJtaCSSI+ptQa2vGDqJlQQSFerI0Z4aOmJ5N/9NqM/Tup6Kv3yWQceP0hu3kXx9fc/ zcarmG6YwaFpuJ+fzbQf7Ocf1EI/ecWaW4aMd/E2/oBhVZkLhF3FonGMXhCMFVY97uPG iDpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ALyiENCeDuKpEATpQ1h8kabgaW8aSQkr3Q+Uga+z3qo=; b=Gwt+Pa9ccrjsRTX6DJKQgSJxEjAyswli8tfhobr2nq5Yu7oUodGT+8fZm81lqqhRT/ LGrgD2ifE643qJE86g/nKbIw1a0I3dc2VAjGxxeHuBu3J9INIOJsUUfo3RMQ2gS2z5nm RgwLSflv52z7FD5xXfbVYaCisBbVJd7Bp81GExu/WXQkg7WmY2BSuyvZVEytEERbc+Oz ofsC2c5x6NYJPh+ZpV0xWHPbKLSUf+YNcudGj+pmOPf7wph8LsLKVV8MPdx60B5gMZsT siFelfTu16QbTOQZLjpgG2EeoPe8XZZ6mGIwqQDJbTg0f5HTMgzz89HhN/BbKeLJyMq4 nkJQ== X-Gm-Message-State: APjAAAV/asAk7WjOQs2QlAE0FbYIgtbGo9WOsonBfTjOW1yAvMzhbFQy cUoRBlXK0+dGdJQpFHaKDz++Nxs5r26C X-Google-Smtp-Source: APXvYqzEvrdX/Hxd5Rq8phJxuRR6PXyExt54UX8lGrTBXfMn2GTGCsPON347HusQYomvmosMI8OSyg== X-Received: by 2002:a1c:6755:: with SMTP id b82mr206896wmc.126.1579538202623; Mon, 20 Jan 2020 08:36:42 -0800 (PST) Received: from ninjahub.org ([91.235.65.22]) by smtp.googlemail.com with ESMTPSA id x7sm47089018wrq.41.2020.01.20.08.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 08:36:42 -0800 (PST) From: Jules Irenge To: jbi.octave@gmail.com Cc: Kaitao Cheng , stable@vger.kernel.org, Steven Rostedt Subject: [PATCH 6/7] kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail Date: Mon, 20 Jan 2020 16:36:21 +0000 Message-Id: <20200120163622.8603-6-jbi.octave@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120163622.8603-1-jbi.octave@gmail.com> References: <20200120163622.8603-1-jbi.octave@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Kaitao Cheng In the function, if register_trace_sched_migrate_task() returns error, sched_switch/sched_wakeup_new/sched_wakeup won't unregister. That is why fail_deprobe_sched_switch was added. Link: http://lkml.kernel.org/r/20191231133530.2794-1-pilgrimtao@gmail.com Cc: stable@vger.kernel.org Fixes: 478142c39c8c2 ("tracing: do not grab lock in wakeup latency function tracing") Signed-off-by: Kaitao Cheng Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/trace_sched_wakeup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index 5e43b9664eca..617e297f46dc 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c @@ -630,7 +630,7 @@ static void start_wakeup_tracer(struct trace_array *tr) if (ret) { pr_info("wakeup trace: Couldn't activate tracepoint" " probe to kernel_sched_migrate_task\n"); - return; + goto fail_deprobe_sched_switch; } wakeup_reset(tr); @@ -648,6 +648,8 @@ static void start_wakeup_tracer(struct trace_array *tr) printk(KERN_ERR "failed to start wakeup tracer\n"); return; +fail_deprobe_sched_switch: + unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL); fail_deprobe_wake_new: unregister_trace_sched_wakeup_new(probe_wakeup, NULL); fail_deprobe: