From patchwork Fri Nov 30 15:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 152548 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3770677ljp; Fri, 30 Nov 2018 07:10:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/UWqaxGBy4S3n8GzdGR7l4ZIeR/+VgK5FNQDwaBs3lyNmk6HUjKD0IkJJcUxOyur+waVumN X-Received: by 2002:a63:a35c:: with SMTP id v28mr5113236pgn.205.1543590612288; Fri, 30 Nov 2018 07:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543590612; cv=none; d=google.com; s=arc-20160816; b=R4IUAewwD8q1p+fsZAaeWZ7rm3pLX6LBCXuugQh6cnAh/ST0BB7bvIheuHlt+tTUhj qS8Us9bcyiAlYB7MWD1Yhr+h40G/fIvSuquscm1uY8IfshnaNYTsEedcfttzQ1u0kZXV c/oZtki2Am0fpvtSor+DBwoYbl/aamHaiG92EmoO4ExLecADTiNJj+kOMV1Q4cvHh2v/ 1xNPpqGONY4baV78ZQlz4Ga4NtF22rAppuQb8ITfRAqL8bFif7jJVQh0t30U/rg8Lcjb ke2RK9vznV9kjrBFzIbgL+wHzgRQu4MP1uDhx/O/JTyiU6xcTzK+sru4Sitml+ljr4je j+Zw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Sn6e2y3hrDqC5F6PRoRA5dBPL+JkfPGNchhGjAsqyhg=; b=wIPEqiPlazKxLiq3EbONET3V27BJFThe3aJmzY7u4GpoFJX0d/XsGeZxAcNootLMB7 ShgF6kUY1oeiYRjq/DUg51wG6GTlc7xd/FkmbzHpKybN0OjtwsYNk/Oxh2SXk9gAZiBT EvLjKbpYvEf2i4lNOh1+mWv6S+8LdS7V7Fywiuw31u71fq0ROewOkJ2AG6nYWyvVUnnh N1pvkH9GCE05bZVx7IXjghF2lAzl0k3edG+Zz0ltZ9qUa5ZceUrJBSBmMDJ4Qxeqip4C S8wqNOn7+6DqZOl/CAmjRcpSH2bsCub4JVSzf+63Va5EKAJxyq2rSN48OdmA/TsVBGkD y2kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hf7NYzds; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si5710672pfc.156.2018.11.30.07.10.11; Fri, 30 Nov 2018 07:10:12 -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=@linaro.org header.s=google header.b=Hf7NYzds; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727214AbeLACTq (ORCPT + 32 others); Fri, 30 Nov 2018 21:19:46 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41870 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbeLACTo (ORCPT ); Fri, 30 Nov 2018 21:19:44 -0500 Received: by mail-lj1-f196.google.com with SMTP id z80-v6so5273770ljb.8 for ; Fri, 30 Nov 2018 07:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sn6e2y3hrDqC5F6PRoRA5dBPL+JkfPGNchhGjAsqyhg=; b=Hf7NYzdsmIc6gAHEOJdgMn9FEKqpFUYVf1s5w8KySpDhefcB22MF6kW3XbmiACEez1 HV2hfJXyGxMtTxhQ4QgB9N1w1TcnvBd2Cvid6LJkfE61lw8uF5dDOjj/MCu39gv5xWp+ BFKA63Mww/JBddGUnzn5SLq7D9t7SFm1wdLnY= 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:mime-version :content-transfer-encoding; bh=Sn6e2y3hrDqC5F6PRoRA5dBPL+JkfPGNchhGjAsqyhg=; b=ctieoURxUym6Bg4OIpXYbfLiB+GYA2jXZ/DH8M3SpQRvWLhPTCL3PIDvhOrVDh+JnL h2OLUvSfxYOPPuC/1dnzWVBn+/qWgJKLLaCBzStL4sdO3PgNK5YtzKF0DkFz6l/GlVJz R84W/Mwpg8j6HKRsrtB7S4Aj4MgUu3MuqEjCG6H98ZTA/d/JgBGv2JuFXefF4NXSUImh j5QNzZdXbnrL9tKWzDZakwOao5dM+/N4rGPXAhtD+tIncE8NIH/RUQ29k0/te+XCwZ65 pZbzrzVRbyJO627eQkY0jXEl4NX9NVwlw2PG+ofkeAB7hnENZgabNq0bkkmK5L8cZ+2r 7XmQ== X-Gm-Message-State: AA+aEWanRjAiINrxeldINJ+6GzDx65OdUmLRJopcWAPgvTvSTsN51zev YWO0mhQT5IU8TbmqJ38KemvQqw== X-Received: by 2002:a2e:9017:: with SMTP id h23-v6mr3612440ljg.71.1543590604769; Fri, 30 Nov 2018 07:10:04 -0800 (PST) Received: from localhost (c-732171d5.07-21-73746f28.bbcust.telenor.se. [213.113.33.115]) by smtp.gmail.com with ESMTPSA id a11sm865169lfb.68.2018.11.30.07.10.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:10:04 -0800 (PST) From: Anders Roxell To: rostedt@goodmis.org, mingo@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com Cc: keescook@chromium.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Anders Roxell , Arnd Bergmann Subject: [PATCH 3/3] arm64: ftrace: add cond_resched() to func ftrace_make_(call|nop) Date: Fri, 30 Nov 2018 16:09:56 +0100 Message-Id: <20181130150956.27620-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both of those functions end up calling ftrace_modify_code(), which is expensive because it changes the page tables and flush caches. 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() before going into the ftrace_modify_code() function. Co-developed-by: Arnd Bergmann Signed-off-by: Arnd Bergmann Signed-off-by: Anders Roxell --- arch/arm64/kernel/ftrace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.19.2 diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index de1a397d2d3f..9da38da58df7 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -130,6 +130,11 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) old = aarch64_insn_gen_nop(); new = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK); + /* This function can take a long time when sanitizers are enabled, so + * lets make sure we allow RCU processing. + */ + cond_resched(); + return ftrace_modify_code(pc, old, new, true); } @@ -188,6 +193,11 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, new = aarch64_insn_gen_nop(); + /* This function can take a long time when sanitizers are enabled, so + * lets make sure we allow RCU processing. + */ + cond_resched(); + return ftrace_modify_code(pc, old, new, validate); }