Message ID | 20230929191637.416931-1-cleger@rivosinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp70193vqb; Fri, 29 Sep 2023 15:16:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1QVieuVV01wKuvfvJiQVrJxOqULxSrLw4loSdHQp7HCLGxD7sG+nxcXYRLEQJyH4Uo6kF X-Received: by 2002:a17:902:cec9:b0:1c6:291e:24b6 with SMTP id d9-20020a170902cec900b001c6291e24b6mr5892135plg.37.1696025795263; Fri, 29 Sep 2023 15:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696025795; cv=none; d=google.com; s=arc-20160816; b=G8vVuLpiz49QqJTPeOgxG7Kax0LWkCrAuEADsJhq+EI0+JNoLHVp2vGXf51S2uXhiA SzMx3fWRVLiQfm3WH5R9lXOaiVrbIeML9MLA6akko3KJGLwZI0uyUC9CGpVNDcBrlMGh FQ01NjHXUSnUJ13Y8RWtZCXYFgqfGhhczgbi9ToYAWEpyF1XR+Qnsr2vQj4uSko6cNO6 YHFF1XvyIcyzqU04dZeXHQB23Orny2clYfSkKbo/8Da6AXoMkl4Mgm4/z7VVKcFNd/T0 DborUXBDS8r5C38vDP7hKvSDRt9UF4zabSUx1NwttNNY1qsgqMcpCmhoqu3tmrH6pNq7 CBCA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pN0zsFl48jOIbMUKHa3f1BUkQARK08SxAyaTSBsfszA=; fh=ALcOqEPZ4ZGV3FeBEaGfPRnshlCd40Bkhxj2Q0p74r8=; b=pox2UHqNsZQlI7BO/6po7Zi3HEGTdAXVsKz4Z88C5cHQX+/ThC1zhj4RYfa+Cm1AAO rJQ8D6S3fH21nev6Bcp41EuXPxDxa2qBUCabGgkSq06op27nJRcNTE6oJzphQEAM4fym juiacJYdzkdObIgRQT93xhkCoUfSqsu+wVs64mVaWLckP0D5h17UvX9oup4jMPw3hiJI 3ICRXZuyeL4Lc8F0z1rYg+sA0ckbsTRmzGtS9wkKx5B7Uk/GOQO2dLLHLk3KhV3ngLVa bD9YE05McqfQ+q16vA6o9DVEhMsZoP1myGOlKszjRVLWfp/FNl646UH16KyuLgI9XBMr F01A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WbxINGqi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q6-20020a170902a3c600b001c7264c458dsi7054326plb.181.2023.09.29.15.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 15:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WbxINGqi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A1AC08211405; Fri, 29 Sep 2023 12:17:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233280AbjI2TRU (ORCPT <rfc822;pwkd43@gmail.com> + 19 others); Fri, 29 Sep 2023 15:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232960AbjI2TRT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 29 Sep 2023 15:17:19 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178C91AA for <linux-kernel@vger.kernel.org>; Fri, 29 Sep 2023 12:17:17 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4053e6e8ca7so36886565e9.1 for <linux-kernel@vger.kernel.org>; Fri, 29 Sep 2023 12:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696015035; x=1696619835; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pN0zsFl48jOIbMUKHa3f1BUkQARK08SxAyaTSBsfszA=; b=WbxINGqifppFE5iW769UOqrvmJciZhPY9ej9OKD117tj0RMh+FCmttaAqfWHC/2AQH LZ7GMDDHXQuFrrJIQJoFKqpFIWuCba6ov5KHW3fNpe5d/XN/HkY3jJqLepMJZO6kvWce +fkpBsGAvcSqZjDnJyMrbp8Su0sfeYIprcmIJJ2HK/sNuKzZmwBJiGyzdw5c/NMpDcs4 JecZ4fv7nlM7NxOPzpnGGwkJnJtY88ppy4pGw4sdW94XTcL72qR9RlhFWnnwRHhKeWRU l9igWxz2twzvjkkNalH4GVezncFfHF9QmAVMXGhgpdEKGD/C4Ej0MGxRk+r92/Z/lY2F cvaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696015035; x=1696619835; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pN0zsFl48jOIbMUKHa3f1BUkQARK08SxAyaTSBsfszA=; b=ZzGSNGmchBRjoNW+Kl7A6aP+wUNKvr7ESn6WfudPIrm75kqEhoLzOOaz+WuaMxRjJI ItFRF4Wk/v1QRD/6aaYXs6iKdFtN+wW71vx5elO42QsVUSDlTJ4UzUlwXNPnWMJRdOmQ MUBuUzVdLP4bnRSkf7lIRuYQvb5G5FxKthmZAC669O/aY3GYjmPbixNP2TQoF9YFBE7m U+2Z83jWDwxgHxi95pB/T7QQ/auE6Q+Mo7peCamM96JvPmoUYlg+2evYvz6tWh/QyjgA O/K99p2hIeLYcNIysOXGZx/t/vzRVcexKMG1OTWosOG83VYkEc3FRCXUKYAgVi79XO9f WQeQ== X-Gm-Message-State: AOJu0YysnEr82NidxAD0HtDzhdRpqZU4clsHMPjtp4NWAFZx+9o/SRCI Nyowctp90hGWjtwA/40Q37v/aQ== X-Received: by 2002:a05:600c:3b87:b0:406:513d:738f with SMTP id n7-20020a05600c3b8700b00406513d738fmr4736627wms.2.1696015035387; Fri, 29 Sep 2023 12:17:15 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:9f43:3ca4:162c:d540]) by smtp.gmail.com with ESMTPSA id t15-20020a1c770f000000b00406408dc788sm1995230wmi.44.2023.09.29.12.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 12:17:14 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= <cleger@rivosinc.com> To: Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org> Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= <cleger@rivosinc.com>, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Atish Patra <atishp@rivosinc.com> Subject: [PATCH v2] tracing: relax trace_event_eval_update() execution with cond_resched() Date: Fri, 29 Sep 2023 21:16:37 +0200 Message-Id: <20230929191637.416931-1-cleger@rivosinc.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 29 Sep 2023 12:17:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778411944212456856 X-GMAIL-MSGID: 1778411944212456856 |
Series |
[v2] tracing: relax trace_event_eval_update() execution with cond_resched()
|
|
Commit Message
Clément Léger
Sept. 29, 2023, 7:16 p.m. UTC
When kernel is compiled without preemption, the eval_map_work_func()
(which calls trace_event_eval_update()) will not be preempted up to its
complete execution. This can actually cause a problem since if another
CPU call stop_machine(), the call will have to wait for the
eval_map_work_func() function to finish executing in the workqueue
before being able to be scheduled. This problem was observe on a SMP
system at boot time, when the CPU calling the initcalls executed
clocksource_done_booting() which in the end calls stop_machine(). We
observed a 1 second delay because one CPU was executing
eval_map_work_func() and was not preempted by the stop_machine() task.
Adding a call to cond_resched() in trace_event_eval_update() allows
other tasks to be executed and thus continue working asynchronously
like before without blocking any pending task at boot time.
Signed-off-by: Clément Léger <cleger@rivosinc.com>
---
Changes in v2:
- Use cond_resched() instead of schedule()
kernel/trace/trace_events.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Fri, Sep 29, 2023 at 12:17 PM Clément Léger <cleger@rivosinc.com> wrote: > > When kernel is compiled without preemption, the eval_map_work_func() > (which calls trace_event_eval_update()) will not be preempted up to its > complete execution. This can actually cause a problem since if another > CPU call stop_machine(), the call will have to wait for the > eval_map_work_func() function to finish executing in the workqueue > before being able to be scheduled. This problem was observe on a SMP > system at boot time, when the CPU calling the initcalls executed > clocksource_done_booting() which in the end calls stop_machine(). We > observed a 1 second delay because one CPU was executing > eval_map_work_func() and was not preempted by the stop_machine() task. > > Adding a call to cond_resched() in trace_event_eval_update() allows > other tasks to be executed and thus continue working asynchronously > like before without blocking any pending task at boot time. > > Signed-off-by: Clément Léger <cleger@rivosinc.com> > --- > > Changes in v2: > - Use cond_resched() instead of schedule() > > kernel/trace/trace_events.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c > index 91951d038ba4..f49d6ddb6342 100644 > --- a/kernel/trace/trace_events.c > +++ b/kernel/trace/trace_events.c > @@ -2770,6 +2770,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) > update_event_fields(call, map[i]); > } > } > + cond_resched(); > } > up_write(&trace_event_sem); > } (First email got rejected as gmail decided to switch back the format to html :(). Sorry for the noise. Thanks for the fix. The boot time improvement is evident in both spike/Qemu. FWIW Tested-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> > -- > 2.40.1 >
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 91951d038ba4..f49d6ddb6342 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2770,6 +2770,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) update_event_fields(call, map[i]); } } + cond_resched(); } up_write(&trace_event_sem); }