Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3128288pxu; Mon, 19 Oct 2020 04:54:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiPRM10zjp/kDzOhdxdzugoUfovtL22Kyq72bcpFX4mmnSe5dMbxChJdKdGE6rkp18QE3V X-Received: by 2002:a05:6402:1847:: with SMTP id v7mr18337740edy.307.1603108440802; Mon, 19 Oct 2020 04:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603108440; cv=none; d=google.com; s=arc-20160816; b=I0jWLbrML2CgogCsbUtzENG4cJ0E0oRNDoixbh0M4nEe7ENBciRZAxUenmY/lczoGP sI64b3dsgrBYufjdh0d8buvUHkjJG06HEZIkldDqFh1OmOb+mhlI2Q/8H5bcaGfcQ8KB AiU4OcN4F1zg1ARz2mADcqGVps4lu+NcyqyNPVitc0syEu0NlUxyVaW76Xu5qFnDEmA2 wx8EFJ2vLpFR0GMVSe70E4hu9auMWW+Q+6f+bdyZPMkFKM6H2t+dFq+gKHTlMr6pUxQ4 So8LE9UcaFoeE73FDnseYqeBqnt9sFw9Aa5I3IrbeR1HsQeeIviWwSf3xzU5n8nAmlmc ovaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dV6Kmz3KFq8s+hL1GBRSzaRznjI+tzxR7a8Pz+35BC4=; b=spaLHvGA05fxU4rM0gI6ZYZlID/AgcpgTyHlcLiyIki9FK1RQwtqf6KxgBAktj9bQz ear9EhXaTNNnobolXyTnut56L42U/WQBmBQ88i7TtcuR5um1ts+Vm7I+Y2TkHW8m9Ur7 fbVjDTi3eyO6biQUuOOolD1g7JM0Oc1WaKIlVdZnJz/LL7XLXICNzleCQubd5XDddJwL K4SMbLIaAx/1BP+Ga0iEmaEt91kk+375YkXoAq3dsysmmsTBPXsEqF9WnX4XuQTL/hoU o7As86rR8Cg2LLkp+27LpxuOo5QZarMjPbvdZqv7ZUvV5EDH00urxZHMuKR28pMpyIyT H1XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=F7gapMM4; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si7787950edt.355.2020.10.19.04.53.38; Mon, 19 Oct 2020 04:54:00 -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=@kernel.org header.s=default header.b=F7gapMM4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727522AbgJSLDy (ORCPT + 99 others); Mon, 19 Oct 2020 07:03:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:58298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgJSLDy (ORCPT ); Mon, 19 Oct 2020 07:03:54 -0400 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D46AA22263; Mon, 19 Oct 2020 11:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603105433; bh=MlTuiCzjXhOWFPtC2Q6bTRqPFaq9rch3+wu+hpA35Yo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=F7gapMM4qjLfXtYgi6Jnr406ROeCOVM9CBd4GrCnxCp9t77/JSC6debeN2d2XyeOz VoCGjuuht0BgyzpxRSxVRz1Es+FIbxFeOcfFVq9Thx4p+Pec/vMxs4K98hLjcLLhV+ iENSy2Hk/g7u6X3OAvqvdYOGC9Yhst6qAJIEtC8E= Received: by mail-lf1-f45.google.com with SMTP id r127so13585674lff.12; Mon, 19 Oct 2020 04:03:52 -0700 (PDT) X-Gm-Message-State: AOAM533SWEtKwdRlVOPyhqVJUIHhlvRvPg7Mb2oCa+MP5UBzrNrPQUIA 7X20KL18JyyfUYaiC+mQ57FUhwDl5A6eFeTl67o= X-Received: by 2002:a19:e305:: with SMTP id a5mr5277572lfh.549.1603105430990; Mon, 19 Oct 2020 04:03:50 -0700 (PDT) MIME-Version: 1.0 References: <1602918377-23573-1-git-send-email-guoren@kernel.org> <1602918377-23573-10-git-send-email-guoren@kernel.org> <20201019173648.573d58c7fde864090bf0487a@kernel.org> In-Reply-To: <20201019173648.573d58c7fde864090bf0487a@kernel.org> From: Guo Ren Date: Mon, 19 Oct 2020 19:03:39 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 9/9] riscv: Fixup lockdep_assert_held(&text_mutex) in patch_insn_write To: Masami Hiramatsu Cc: Palmer Dabbelt , Paul Walmsley , Alan Kao , Steven Rostedt , linux-riscv , Linux Kernel Mailing List , Anup Patel , linux-csky@vger.kernel.org, Greentime Hu , Zong Li , =?UTF-8?Q?Patrick_St=C3=A4hlin?= , Guo Ren Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Good Idea! I'll try :P On Mon, Oct 19, 2020 at 4:36 PM Masami Hiramatsu wrote: > > On Sat, 17 Oct 2020 07:06:17 +0000 > guoren@kernel.org wrote: > > > From: Guo Ren > > > > It will cause warning messages: > > echo function_graph > /sys/kernel/debug/tracing/current_tracer > > [ 47.691397] ------------[ cut here ]------------ > > [ 47.692899] WARNING: CPU: 0 PID: 11 at arch/riscv/kernel/patch.c:63 patch_insn_write+0x182/0x19a > > [ 47.694483] Modules linked in: > > [ 47.695754] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-11367-g1054335 #132 > > [ 47.698228] epc: ffffffe000204530 ra : ffffffe00020452c sp : ffffffe0023ffc20 gp : ffffffe0013e1fe0 tp : ffffffe0023e4e00 t0 : 0000000000000000 > > [ 47.701872] t1 : 000000000000000e t2 : 000000000000001b s0 : ffffffe0023ffc70 s1 : ffffffe000206850 a0 : 0000000000000000 a1 : ffffffffffffffff > > [ 47.705550] a2 : 0000000000000000 a3 : ffffffe03af7c5e8 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 00000000150b02d8 > > [ 47.709159] s2 : 0000000000000008 s3 : 0000000000000858 s4 : ffffffe0023ffc98 s5 : 0000000000000850 s6 : 0000000000000003 s7 : 0000000000000002 > > [ 47.714135] s8 : 0000000000000004 s9 : 0000000000000001 s10: 0000000000000001 s11: 0000000000000003 t3 : ffffffffffffe000 t4 : 0000000000d86254 > > [ 47.716574] t5 : 0000000000000005 t6 : 0000000000040000status: 0000000000000100 badaddr: 0000000000000000 cause: 0000000000000003 > > [ 47.720019] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-11367-g1054335 #132 > > [ 47.722074] Call Trace: > > [ 47.722561] [] walk_stackframe+0x0/0xc2 > > [ 47.724608] [] show_stack+0x46/0x52 > > [ 47.726246] [] dump_stack+0x90/0xb6 > > [ 47.727672] [] __warn+0x98/0xfa > > [ 47.729131] [] report_bug+0xaa/0x11e > > [ 47.730624] [] do_trap_break+0x96/0xfe > > [ 47.732448] [] ret_from_exception+0x0/0x14 > > [ 47.734341] [] patch_insn_write+0x17e/0x19a > > [ 47.737235] irq event stamp: 39 > > [ 47.738521] hardirqs last enabled at (39): [] _save_context+0xa2/0xe6 > > [ 47.741055] hardirqs last disabled at (38): [] multi_cpu_stop+0x130/0x166 > > [ 47.743551] softirqs last enabled at (0): [] copy_process+0x430/0x1316 > > [ 47.746031] softirqs last disabled at (0): [<0000000000000000>] 0x0 > > [ 47.748617] ---[ end trace 88a1054faa6524ef ]--- > > > > Because the path of stop_machine(__ftrace_modify_code)-> > > ftrace_modify_all_code->...->patch_insn_write has no pair of > > lock&unlock text_mutex, so we shouldn't put assert here. > > Hm, are there any chance to get the text_mutex in that path? > There are ftrace_arch_code_modify_prepare/post_process() in arch/riscv/kernel/ftrace.c, > aren't those used? > > Thank you, > > > > > Signed-off-by: Guo Ren > > --- > > arch/riscv/kernel/patch.c | 7 ------- > > 1 file changed, 7 deletions(-) > > > > diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c > > index 0b55287..2ee5063 100644 > > --- a/arch/riscv/kernel/patch.c > > +++ b/arch/riscv/kernel/patch.c > > @@ -55,13 +55,6 @@ static int patch_insn_write(void *addr, const void *insn, size_t len) > > bool across_pages = (((uintptr_t) addr & ~PAGE_MASK) + len) > PAGE_SIZE; > > int ret; > > > > - /* > > - * Before reaching here, it was expected to lock the text_mutex > > - * already, so we don't need to give another lock here and could > > - * ensure that it was safe between each cores. > > - */ > > - lockdep_assert_held(&text_mutex); > > - > > if (across_pages) > > patch_map(addr + len, FIX_TEXT_POKE1); > > > > -- > > 2.7.4 > > > > > -- > Masami Hiramatsu -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/