Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3511448pxj; Tue, 15 Jun 2021 02:31:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6U7Smq56S7h60R+y+4rHUxORyxcz2hrBIrT18a7S4ezFuQorAXPdtsHceJ8R2ySWRrl/h X-Received: by 2002:a05:6402:34d5:: with SMTP id w21mr16010699edc.257.1623749517777; Tue, 15 Jun 2021 02:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623749517; cv=none; d=google.com; s=arc-20160816; b=PKD8/kxGKjdwZisbvmiio4vJjbXqWGZoDieSUuw+eT7sag/U/AFrg+IxxJJrHPa2sZ Sgld51+1WWxKHk/XXNqmvu5AM9CibrSzhvx3o2PV0xScvGbQZe3TjCd5UV4l0X/znU2J 8+D5a0Psc8WRiyHpTStcTnbuAdGsH5ONMZyspqh2KFCxWo12LgyiI+mpXrK9V7KKce9k w40W6Y/iTa8fPMNTwxAIfVkwNy5U4krbxpOSBdDqQBbHs4kCN8sB1rnsVYcBZGsHhz1c LLmkRwcCUyaQB7wFwIsjRdBCUJcyRcL95Rmg9Cl27JQqwKIRtPHxsGhMB+S3BVPwQxQg UpPA== 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=oZVlLGY0kqQAYmVdD+6nEDNmFy2iD2bHg+txa/b3qk8=; b=PlKi1m3sW87xDe8ig67YE8Gbs7fUxoh+405qggfMYDu+QbkFzZ4llyx6HhetCk5qsy D8ZjWpTeBLPMJtK2wDQRQWu9TLO6T6jpZJPP6iabM8ebiLbfIVnGskLStcHYmCoYxxRD gHYIi2rQZlZA03n6lzHXfAj6Iyt6tzrkkXoZA/f2wQzZBITUJRqkD3OgdNiA3xZqDeHA XQP615jNn/vIt+cKMaAYnNMR+asI7L6+tQgO5rUtxvO+TKvM+7Z1scvHARa+aKtqPd8G cZ6fv+NdVagaZ5ZTozz82bpY0bdHHu2OP7J6Lh9TczUDAjfi7tb3VBTFddDqVSgA/j9B rwAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MY6mc6h4; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si15399604edn.209.2021.06.15.02.31.35; Tue, 15 Jun 2021 02:31:57 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=MY6mc6h4; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbhFOJb6 (ORCPT + 99 others); Tue, 15 Jun 2021 05:31:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36246 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbhFOJbw (ORCPT ); Tue, 15 Jun 2021 05:31:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623749388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oZVlLGY0kqQAYmVdD+6nEDNmFy2iD2bHg+txa/b3qk8=; b=MY6mc6h4umwaSFpK6efuz8T9HM1KzxrPZEwQC64ELcT7XMALOdKNy9C8OhiQ6tQYoIFwVv ZG/OJeW8RrR13ScqKzLF59sTv6XoTGJqYl27vAb3oOSEFdV7B2T5f3ETjDXdt4l2Vm3ahX DcuThrPgQJqdtl75GAM9s/wrOkmhYaI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-NaBsZni7PTKROpxqWbz96Q-1; Tue, 15 Jun 2021 05:29:46 -0400 X-MC-Unique: NaBsZni7PTKROpxqWbz96Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D359100C660; Tue, 15 Jun 2021 09:29:45 +0000 (UTC) Received: from x1.com (ovpn-113-40.rdu2.redhat.com [10.10.113.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2E1D5D6AD; Tue, 15 Jun 2021 09:29:40 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Phil Auld , Sebastian Andrzej Siewior , Kate Carcia , Daniel Bristot de Oliveira , Jonathan Corbet , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexandre Chartre , Clark Willaims , John Kacur , Juri Lelli , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 08/12] trace/hwlat: Remove printk from sampling loop Date: Tue, 15 Jun 2021 11:28:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hwlat has some time operation checks on the sample loop, and it is currently using pr_err (printk) to report them. The problem is that this can lead the system to an unresponsible state due to an overflow of printk messages. This problem can be mitigated by writing the error message to the trace buffer. Remove the printk messages from the sampling loop, switching the to messages in the trace buffer. No functional change. Cc: Jonathan Corbet Cc: Steven Rostedt Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Alexandre Chartre Cc: Clark Willaims Cc: John Kacur Cc: Juri Lelli Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira --- kernel/trace/trace_hwlat.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c index 0ab6acf6ae9a..86e8541d4331 100644 --- a/kernel/trace/trace_hwlat.c +++ b/kernel/trace/trace_hwlat.c @@ -182,6 +182,15 @@ void trace_hwlat_callback(bool enter) kdata->nmi_count++; } +/* + * hwlat_err - report a hwlat error. + */ +#define hwlat_err(msg) ({ \ + struct trace_array *tr = hwlat_trace; \ + \ + trace_array_printk_buf(tr->array_buffer.buffer, _THIS_IP_, msg); \ +}) + /** * get_sample - sample the CPU TSC and look for likely hardware latencies * @@ -225,7 +234,7 @@ static int get_sample(void) outer_diff = time_to_us(time_sub(t1, last_t2)); /* This shouldn't happen */ if (outer_diff < 0) { - pr_err(BANNER "time running backwards\n"); + hwlat_err(BANNER "time running backwards\n"); goto out; } if (outer_diff > outer_sample) @@ -237,7 +246,7 @@ static int get_sample(void) /* Check for possible overflows */ if (total < last_total) { - pr_err("Time total overflowed\n"); + hwlat_err("Time total overflowed\n"); break; } last_total = total; @@ -253,7 +262,7 @@ static int get_sample(void) /* This shouldn't happen */ if (diff < 0) { - pr_err(BANNER "time running backwards\n"); + hwlat_err(BANNER "time running backwards\n"); goto out; } -- 2.31.1