Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4902711imb; Thu, 7 Mar 2019 03:21:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyWQwjo6LAN+kPS850WNCmeldtE8r6phSwV1J2NxgOqaMsWlf2LWJQFN6ky8Jsfy3HxL/sU X-Received: by 2002:aa7:8251:: with SMTP id e17mr12304990pfn.96.1551957675963; Thu, 07 Mar 2019 03:21:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551957675; cv=none; d=google.com; s=arc-20160816; b=JijkIrA8kDezT7fElMLH8sGomEI1RDocvvXmPk6b4zu1nfxFxPOkcWvIQxsiHAI1Ft J8NywR/dnFaftjrlcaQQIMZ6POcndSJDvPJLdSqvjWi+Il85NEYWQsqhJp1ORfvpJIq3 dxrzSZyPAhv8TWu9t81NhufMiERIvjgmPIVvRMmu6E8xZL3iG0z1spff5OiEDKuWivYh by1Rymh2BKkplSSqqPBBVsXFHKltRsFRDftY6W3h3aHAgK9OMAxQdcyFVZ0swrtMmIfE F4KRHWl79aAqSfFQS9T3JoXRsex/OzkyPd8qYBk4ZhDjH9jqmdOLxOYwrZotm07IKFcQ kbXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=Y/4kKmgfNhcZEpBfnXnIV8mrD1sFEAjo0NeebCdZe9Q=; b=sAYGFHO8/6soWlJyCNh+vPkr6k/IL6lhau2RidCLG46WLwDPFC0Mp4OJtSj0CQ8Ehu YvJvkkEat5RRvD7JsnnP5IOuuxS0L/AyEL2e88rdYzFiCMwwwKyYUYM+/QeTpszwrSBc YnJdWzm3E8IrUhwbKs6cZ6Wl0C8zU8c5LgWVK5jnt1Z2nMryyYRtDusxEdmNagCmLqyL mOa/GSt9PlQkb0qIBpyj7UMnV0ce33SG4malbGLz0QjqsgO2/8wAm/TF1Nw/QHZZITku 0TTLOABxcooQW1Gw9Yh1VfCnh3E3BTwJy2BoYWANbqoUP17KV2FIN8zZFjuZtbJFwpAl WTCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kduPkqa2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v69si4098752pfa.37.2019.03.07.03.21.00; Thu, 07 Mar 2019 03:21:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kduPkqa2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726207AbfCGLUf (ORCPT + 99 others); Thu, 7 Mar 2019 06:20:35 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35348 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbfCGLUf (ORCPT ); Thu, 7 Mar 2019 06:20:35 -0500 Received: by mail-pg1-f193.google.com with SMTP id e17so11016877pgd.2 for ; Thu, 07 Mar 2019 03:20:34 -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; bh=Y/4kKmgfNhcZEpBfnXnIV8mrD1sFEAjo0NeebCdZe9Q=; b=kduPkqa25Wkrc1EWVKaI+i7l98P2xd3C2YGUc/HHs/9naI+4vws+MK+QR0Nz+WtRIX bI3wcLpcYcZt1TjBqdHpBAuUruHc1nag8n7/XnX7anQ+g4OXm/kPWy+ftPbBWscROfVk gByLnjlWaiauyT4gfagkx6bQ/jlVeNneHqFQMcB0wSG1oh9G/84wT8cmeOj/QwhDn4Im AdF68sWkJNi1lT2hYFy2gi+8ktR21a/Udrvt8OPH7jtYY6kAeXCbg4warlJ16FXoEJjN 270fSFywquDYIg6CUyaHS0ryTVCUx0xQ3yZEJKOOSWRRo5ZKd1H+shCP4QReLgS5Djf2 ecLw== 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; bh=Y/4kKmgfNhcZEpBfnXnIV8mrD1sFEAjo0NeebCdZe9Q=; b=FaXmXUzwscFm2sgrfiSOOpqedUKlbPoqubslTTQKTRroshD+7y8h/KjdzjmF6u/lJh VnCSZyZKYAYL5J1kXXkeTAiKlXG/bYHCELM0lPat2dq5+tI1vo69mbhZeNto2I8wLsud +lz0pdif4xo/AClYCQEPureanCO8u783GYZCJRC3iek4GU6Ds8L2D4hehdVUkV6DY9aa iIiQRYG6COIo5MLJJOAJzYABlNOIzdTt6c81O165Di9fuOMaPq6LiR5Sxa7j3B0MiqLg P+GLOye7xXgh57WHqg+ECFVOdkAOHysZ9ps9FsS15CSBB13SQOPuvlV7Eq+quwzFEQ7q Zokg== X-Gm-Message-State: APjAAAViTq4SJgXDsVNO9hVGnCLyB3B23lyb7NfLfecoOOOWs4EM5EAK JRvIARVv9Rr4GuBYMMryo8k= X-Received: by 2002:a63:1105:: with SMTP id g5mr10965700pgl.322.1551957634274; Thu, 07 Mar 2019 03:20:34 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id a2sm6126929pff.58.2019.03.07.03.20.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 03:20:33 -0800 (PST) From: Yafang Shao To: peterz@infradead.org Cc: linux-kernel@vger.kernel.org, shaoyafang@didiglobal.com, Yafang Shao Subject: [PATCH v2] sched: fair: fix missed CONFIG_SCHEDSTATS Date: Thu, 7 Mar 2019 19:20:11 +0800 Message-Id: <1551957611-31457-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When I'm using trace_sched_stat_{iowait, blocked, wait, sleep} to measure how long the processes are stalled, there's always no output from trace_pipe while there're really some tasks in uninterruptible sleep state. That makes me confused, so I try to investigate why. Finally I find the reason is that CONFIG_SCHEDSTATS is not set. To avoid such kind of confusion, we should not expose these tracepoints if CONFIG_SCHEDSTATS is not set. Signed-off-by: Yafang Shao --- include/trace/events/sched.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 9a4bdfa..f060940 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -241,7 +241,6 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * DEFINE_EVENT(sched_process_template, sched_process_free, TP_PROTO(struct task_struct *p), TP_ARGS(p)); - /* * Tracepoint for a task exiting: @@ -336,6 +335,7 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * __entry->pid, __entry->old_pid) ); +#ifdef CONFIG_SCHEDSTATS /* * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE * adding sched_stat support to SCHED_FIFO/RR would be welcome. @@ -395,6 +395,28 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * TP_PROTO(struct task_struct *tsk, u64 delay), TP_ARGS(tsk, delay)); +#else + +#ifndef DEFINE_EVENT_NONE +#define DEFINE_EVENT_NONE(name, var) \ + static inline void trace_##name(var) \ + { \ + } + +DEFINE_EVENT_NONE(sched_stat_wait, + TP_PROTO(struct task_struct *tsk, u64 delay)) + +DEFINE_EVENT_NONE(sched_stat_sleep, + TP_PROTO(struct task_struct *tsk, u64 delay)) + +DEFINE_EVENT_NONE(sched_stat_iowait, + TP_PROTO(struct task_struct *tsk, u64 delay)) + +DEFINE_EVENT_NONE(sched_stat_blocked, + TP_PROTO(struct task_struct *tsk, u64 delay)) +#endif +#endif + /* * Tracepoint for accounting runtime (time the task is executing * on a CPU). -- 1.8.3.1