Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp51424rdb; Fri, 29 Sep 2023 16:25:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9KKXkyB7ErfQ8WEYhLfm4oQGBCF/sbCfamOadsqm07uBQglcWUTOFxkpXzugKPooTPOtB X-Received: by 2002:a17:902:eb44:b0:1c3:8679:6ed4 with SMTP id i4-20020a170902eb4400b001c386796ed4mr5325533pli.8.1696029935130; Fri, 29 Sep 2023 16:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696029935; cv=none; d=google.com; s=arc-20160816; b=UUtmwUgVOeBkOs5Ph1LWHLSrkaoTAryJcVq1ZBu1vvu1QjiFhc/tEG6INwhg7kBxiB F1auxyM3JL+2vhuOs4GDOC6Q8KKI4w6ifvusqUUHZL1d3nqJwyWS+ANTsX1Fwh1bBQdo ev3bsxwfJQPnkaPZA311rpPoT02dvcXqAkwUjtg7NV2g/c/GFZriKqGLTP3PdOtnsgbV BTE0VHxqhoEi0nSJdZrgCe+2VG5ZdDu3a98t8S+KUVT4DWAa/rnGV9Sn93ZiaTCRBjYa 8VEcjAH7rmF6Xm13rkpS0MEUdzuDyiguXPAjIGhT2uQD/GJH3wZDlM7IIAKureapqt3Q rc/Q== 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 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id b2-20020a170903228200b001c71eb782c0si10849015plh.464.2023.09.29.16.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 16:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id DDA5B823D9F2; Fri, 29 Sep 2023 12:17:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233208AbjI2TRU (ORCPT + 99 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 ); 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 ; Fri, 29 Sep 2023 12:17:17 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4053e6e8ca7so36886565e9.1 for ; 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?q?Cl=C3=A9ment=20L=C3=A9ger?= To: Steven Rostedt , Masami Hiramatsu Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Atish Patra 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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 12:17:36 -0700 (PDT) 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 --- 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); } -- 2.40.1