Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp114787lqp; Wed, 20 Mar 2024 15:42:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgd3ygBlL/P09msgX1HdPOwkBaXTjwNI0KnjNjRR6dYf5X5qhzQXJO0ZrTDrHEaIK6I8Ml54mQ1IoRn8BM38y49YUrIYdfJZDPlIHROw== X-Google-Smtp-Source: AGHT+IE2yJSzaUkHTPuP+YtSSJs+hjACgU9Oup8bvYztdrIPW69CBk3pQz/yY7BJ380j1OC3vlxD X-Received: by 2002:a05:620a:8129:b0:78a:1a97:17f1 with SMTP id os41-20020a05620a812900b0078a1a9717f1mr3252725qkn.63.1710974572939; Wed, 20 Mar 2024 15:42:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710974572; cv=pass; d=google.com; s=arc-20160816; b=ZbBQ2HFOzDB8NW8DOOfX16w3EWieOUZ0uvIGWgcgvURab+d1owswiH6qKLL4ADu1ZV zC/zYw1Y9OHQ3Zk0tb1VKt1poAR6JH2yMYfMHCVQYMXY5uGvs0iwuKYaMpIp0uQL1b1B MDhFDkr/rpj12F4Azcq/nGe5NVvhVk3s+2mgo2tWx9izPcnuLwmXTez3ZjFKTMp6INXW sTZaJ5Ox8GUu4rPfnBJvHpUN5x0fzcZ7ccbLXcq/EsqVREqyuPPJ5S1FDqRC6ck2MZp1 6f/6FFfBMPJM52S/BjFu8uZAD3D2on6MMKajXntPIgJqbmlO2dWp07vO+OdofMbXpZCI A0eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Dw6rd0m7MA8k7bHTBxP2bB2jrvpEI2pgQ/Pyev6+gzw=; fh=R0LFI3zvK0iA4JtoNC24hjVmmIAbcjVGWjv7P1L1F/Q=; b=0D/tYvhQpCQJK+SzuHnnyoZoWK+87pX/3xi9j8MejcxoboEav8Jq6YaTrxuK22BgI3 YHaSznveK1xhdbg0uwOVNt2icIKP9FHumGj55svGIpSzNchMGKAFJ0Qtp+gY6T3BDflR JUSJXRT4fwMkyZM2ADxfDxMlNRYgcrK+/R277X/4OXldbofXL7iT6j6fYQuM8fu5VQIi 3WPceLK8WRuuYJJy90YP/aEhFZZkxBwAVwVEkZFa2vnj7QaNWUlMh5t6VVqc/woMQLal a9aOWLkeGs/TPCF5KtWNU6ZDFpS2uA4yIgBJg7ht2VghIg5hRcRXJohVzG5JmX23vZZw h3uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jxgD4Oqn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-109470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wg11-20020a05620a568b00b0078a01ed56dfsi7006707qkn.175.2024.03.20.15.42.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 15:42:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jxgD4Oqn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-109470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109470-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 98B0B1C2156E for ; Wed, 20 Mar 2024 22:42:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0141454FAD; Wed, 20 Mar 2024 22:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jxgD4Oqn" Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7430E1EB45 for ; Wed, 20 Mar 2024 22:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710974566; cv=none; b=PoFq1Od1VVRHzY2N6tpSXImcrbWtveTM91HhIVAdaYznpVYwmDt2GyH5cpD2uDlqYZthexSBsWRQ6QsMSNXmBd/e+eLXWimYVpbo5doKxUw3e4is7ZE3aCBVEHBVse14HOLqIiVPYYRZAx69Jwej7d6RnmdPVFhF9kpDB2Qh9u0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710974566; c=relaxed/simple; bh=Qzo0wWW+nIU5ofdBtQDFhFG5/t2jk1i61qipHXAvkK4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=dfZGJ02C/AXpGFRQwyXtbUpzdzJB45M0wzqRQTyt9Qg5/d4PXcvPwnJEl9zh5cSwNhKCLe+euhaHlDic3+TJV7iCdKxHxfm77fIRM/gb2JIOG8C3YcX8iYks8zsGnAFP8s6Uh8ACHIHuPZ85Ake63uFJoXlqWgfOz3TVbEVwqbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jxgD4Oqn; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-41428b378b9so14275e9.1 for ; Wed, 20 Mar 2024 15:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710974563; x=1711579363; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Dw6rd0m7MA8k7bHTBxP2bB2jrvpEI2pgQ/Pyev6+gzw=; b=jxgD4OqnCyKWcsDk/FfvSJSzm87Fl5B8tKRjRjBztEya4kHv2y+ckyVXVvLeEXvH3D x4hHUW0VwHvVA93fp7OYwE9EMCDJwe+/Qwj+aoyaVJhZKXB9nKU/dxutfD14g2AeSfYb MBAiO7+1xPMdTxVj2PJCREQEKFbUNk9ySrgyPi1n8vOoO0Yo5fC08CkX4T4+zof3tFyK dd4j7vV5VjLfMx+QoP4XvaAvrcMwYyNe1KuLn2wntpKJcsdWKgHbe1RVbArB/8USACGt FxLoxpFoi5rH4TH6xRUQSP4ZGyg1vyHlQNwaHAmeRatYh5OC+t/1r8/VhMf9dSx79O7Z 9ojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710974563; x=1711579363; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dw6rd0m7MA8k7bHTBxP2bB2jrvpEI2pgQ/Pyev6+gzw=; b=wJBClP1+OL95p3rVfwmkrzmYHsfWDXsgIBLeSavEAxMidEwUmZx3tPO1KVJ42xxi9i KBemhVdjVBeX3VbeR7PH2DkYRJ1Y1vsR+/I0XSNcWpG8hjG17aWqHXA+97xwKb++Fdd0 Zma3/sQPK/CMMti8nRh6vuJqSEsn9hG6HLejCjMqABpPvjgNcW7Cf7f/OXQRGF0fKAX0 2esxBSGEIv/UEBRbHbZL0BFCLrlFLhyxxkBwWovqkHPuvgtycjVelvqrBa5Mfhbly+cf dD7I0yT+tWhMXY5gWmvUmdBFFjnpIHd/uNac3rNSNUtO3pyPaDgVrP7JiMtTKfQzXMdP WbkA== X-Gm-Message-State: AOJu0YxVEoFRBy7vWL5hRpPpw1hQLILij10OLjCLJSbWVuINHX90lHRB 2kPEC5umN/rIqTS92bCDCJacm7xS2sCban2poAYeeGjr08nudzdekyo8YVJIJKR/CNBtlLDIoYU pRuP+ice7keVUoExs0uJ2lB2Yd9/zwHcM8Ec= X-Received: by 2002:a05:600c:1e04:b0:414:3566:eab5 with SMTP id ay4-20020a05600c1e0400b004143566eab5mr72998wmb.2.1710974562782; Wed, 20 Mar 2024 15:42:42 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240318192846.75299-1-jstultz@google.com> In-Reply-To: From: John Stultz Date: Wed, 20 Mar 2024 15:42:31 -0700 Message-ID: Subject: Re: [RESEND][PATCH v2] sched: Add trace_sched_waking() tracepoint to sched_ttwu_pending() To: Vishal Chourasia Cc: LKML , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Phil Auld , Valentin Schneider , kernel-team@android.com, Zimuzo Ezeozue Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2024 at 10:24=E2=80=AFPM Vishal Chourasia wrote: > On Mon, Mar 18, 2024 at 12:28:33PM -0700, John Stultz wrote: > > Zimuzo reported seeing occasional cases in perfetto traces where > > tasks went from sleeping directly to trace_sched_wakeup() > > without always seeing a trace_sched_waking(). > > > > Looking at the code, trace_sched_wakeup() is only called in > > ttwu_do_wakeup() > > > > The call paths that get you to ttwu_do_wakeup() are: > > try_to_wake_up() -> ttwu_do_wakeup() > > try_to_wake_up() -> ttwu_runnable() -> ttwu_do_wakeup() > > try_to_wake_up() -> ttwu_queue() -> ttwu_do_activate() -> ttwu_do_wakeu= p() > > sched_ttwu_pending() -> ttwu_do_activate() -> ttwu_do_wakeup() > Notably, sched_ttwu_pending() is invoked for remote wakeups. > > Given this, I anticipate a scenario similar to the following > occurred: When a process (P) is to be awakened on a remote CPU, > the scheduler adds P to the remote CPU's wakelist,a per-CPU queue, > and sends an IPI to the remote CPU. This action triggers > sched_ttwu_pending() on the remote CPU, which then processes the > wakelist and wakes up the queued processes. Hey! Thanks for taking a look here and sharing this feedback. Indeed, looking closer here I do have a hard time seeing how we can get to sched_ttwu_pending() without having gone through the paths in try_to_wake_up() that would call trace_sched_wakeup(): try_to_wake_up()->[ttwu_queue ->] ttwu_queue_wakelist()->sched_ttwu_pending()->... > In this scenario, the "waking trace" of P, signifying the initiation > of the wake-up, is recorded on the CPU where try_to_wake_up was executed. > Meanwhile, the "wakeup trace," denoting the completion of the wake-up, > is observed on the remote CPU where sched_ttwu_pending() is executed. > > Is there a possibility that something other than the above occurred > in your case? I suspect that the case reported may be that the task went to sleep right after the trace_sched_waking(). Which could result in the transition from sleeping to trace_sched_wakeup() without the trace_sched_waking() inbetween. The added latency from the remote wakeup probably increases the chance for this race to occur. So I'll withdraw this change for now and sync back up to check if my suspicions are correct or not. Thanks so much again for pointing this out. -john