Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8626486imu; Tue, 4 Dec 2018 11:21:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/WlP/MgglI0eIUQiV6puG/F5wTZzP/ElUjMqoDJKUtvmT+JGAUwPB0EkKHbYt89DlzQ77oI X-Received: by 2002:a62:5658:: with SMTP id k85mr21116009pfb.231.1543951290365; Tue, 04 Dec 2018 11:21:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543951290; cv=none; d=google.com; s=arc-20160816; b=KwREBGFqIDbHnxF2pz4bnt/xO8VulQGnqN4BfLZXs8efUrVgPquI+FMBvojTadXaPG zYygF+avwBGu3mZ2o0GDqq04B12TdkTkTu5viXN1/LIxj3qhiUxTHBqqpRWnGJBw02tW hBfOI0EB87d6tkZr8UtWvsNcGT4/X8PMCMJlxEpLUJ1PS589d3wUffgYDVN8ap47dIwT eVjENZ6IN4tzXk34kWfSrUkSDlVRexPk4qVekqkxag603ep8/PH9HxTZ/ZcFYmBW0n7I soNl6DgfGg2tC2/eGuKDw9uAwYHuWE5WZOSrp0CogA9rMsmznm2u73Q4yhrP/lOtcHVl 3XPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=g0QnVpqeL+AMD375irBP9AckMm3Y2JfNEjMCE5Nh/Rw=; b=Bxtb5eN7PRV4EG1Ij6+apVAnrwKzSIy4qnCBgy80OW8ubVhEwvraLbF7pgCsDeZhB7 ZaowNmoAO4JmdgYwSoRxPxm6CVsosr1WqTk1tSj44VUAzcjlItCmWo2jLfeOPsrm2oWP xanfzeVIpVuOj3GkEKUyTclIIFGDi0GcDCiNKDboHqKdAGwwsMDivPt3ZtOz1SbfDXfE TVxH1TqaJotSQwr5ADun591uwopmTfHSaWwvy3gVLpjFJq9oQUUjrTRELtV6i10WhOoS DCX3eD7uGIrKXLOCAzpMQ+hWPS70LiPksl1cbjKP4FfrbY1Uiz5w3GMvTrP3RhIBYKLR iIlQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22si18646924pfd.197.2018.12.04.11.21.15; Tue, 04 Dec 2018 11:21:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbeLDTTM (ORCPT + 99 others); Tue, 4 Dec 2018 14:19:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:35732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbeLDTTL (ORCPT ); Tue, 4 Dec 2018 14:19:11 -0500 Received: from vmware.local.home (unknown [208.91.3.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D04C72082B; Tue, 4 Dec 2018 19:19:10 +0000 (UTC) Date: Tue, 4 Dec 2018 14:19:08 -0500 From: Steven Rostedt To: Anders Roxell Cc: mingo@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com, keescook@chromium.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] tracing: add cond_resched to ftrace_replace_code() Message-ID: <20181204141908.76e7afa5@vmware.local.home> In-Reply-To: <20181204191229.6851-1-anders.roxell@linaro.org> References: <20181204191229.6851-1-anders.roxell@linaro.org> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Dec 2018 20:12:28 +0100 Anders Roxell wrote: > When running in qemu on an kernel built with allmodconfig and debug > options (in particular kcov and ubsan) enabled, ftrace_replace_code > function call take minutes. The ftrace selftest calls > ftrace_replace_code to look >40000 through > ftrace_make_call/ftrace_make_nop, and these end up calling > __aarch64_insn_write/aarch64_insn_patch_text_nosync. > > Microseconds add up because this is called in a loop for each dyn_ftrace > record, and this triggers the softlockup watchdog unless we let it sleep > occasionally. > > Rework so that we call cond_resched() if !irqs_disabled() && !preempt_count(). > > Suggested-by: Steven Rostedt (VMware) > Signed-off-by: Anders Roxell > --- > kernel/trace/ftrace.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index c375e33239f7..582e3441e318 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -2419,11 +2419,14 @@ void __weak ftrace_replace_code(int enable) > { > struct dyn_ftrace *rec; > struct ftrace_page *pg; > + bool schedulable; > int failed; > > if (unlikely(ftrace_disabled)) > return; > > + schedulable = !irqs_disabled() && !preempt_count(); > + > do_for_each_ftrace_rec(pg, rec) { > > if (rec->flags & FTRACE_FL_DISABLED) > @@ -2435,6 +2438,13 @@ void __weak ftrace_replace_code(int enable) > /* Stop processing */ > return; > } > + /* > + * Some archs calls this function with interrupts or preemption > + * disabled. Howeve, other archs don't and this can cause a > + * tremendous unneeded latency. > + */ Actually, could you move the comment up where schedulable gets set? Thanks! -- Steve > + if (schedulable) > + cond_resched(); > } while_for_each_ftrace_rec(); > } >