Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp586304rdb; Thu, 22 Feb 2024 12:49:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcQKyP/GrsX1Pwe5ZS+6zMcVcs1Lc6tq0z7Zix/yujx7A2WWQKctoRNmu/gM+VJVlbjlSW9KQLsoQMTiooneg498nCpBiiMF2OKvxc6w== X-Google-Smtp-Source: AGHT+IG95jBCnNDq5rYWS6qvPuiwrFnfaSe003Or8zWtijkcltz1P+QCBcNWzpVfVaIQcoNtfMF/ X-Received: by 2002:a17:902:da87:b0:1d9:2158:1308 with SMTP id j7-20020a170902da8700b001d921581308mr28457995plx.28.1708634979308; Thu, 22 Feb 2024 12:49:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708634979; cv=pass; d=google.com; s=arc-20160816; b=BlrmKvB6TJwamW6DJDBLaAeT1ZnH+YjwuPGCiuha0XHwMPDkFs+B8mnTzqMCShL6Mc Hel3WE1VYHd8oyWP3pWMXyYADUNM8uQ+tD0RLQm5rjLhBGVSwKCQHJo/cRhjsilQ/1uo OBALkELxBdWULF37/njKIB5uzGI79TaDq3BbL5mDNM3RyZAmpHUMaWRFopf893bzCbJG IclrwPJbgaWYjmqWZyXk4mVTPZQG7Fwy4/AJsuCebOYXV5P2rDm8PAxpl5kBFvdT5KwK hqBvip3n/Axh3Qv/23kVKQogcyWeI8Nz1Kd6RdkNzmVsaS5BiXFkBMOA7ICTKHlMcWbl Xayw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=SRK9EHuaQ+JCWCMfavbkHoRAzX9PoIfHas8OXdMxkpQ=; fh=ypEuFeG2IyTEw7O+bIhK5pNPfE6BcavBnLwIsSty5P8=; b=y+17UO90ogv+bsqh0DS9s1YADJSIBwucIxnfR6onOv8fRDYb+y9OHpyuxXmg77yVsP Dq4eHi95dj4j1YslMTWX7yKkN2c/v1vN4oS8AQ3CB8Y0lB8mwb7U9jnDtoy+cRoqrZEk yFMVdwGdQ+UqiUtSUCz7NUTCTzkdHK3OJI/QwwBX8lUaCedHAbnh1CB9OxwPEQ5QavZu D0P0Xazx2aj9IQ4tuUfpJie5eSHRotqLV2S4PoiuKgOLWoSjPSlcDB1bJ1OWYVvvh/1y vo8vP0QxL4OqbJruIKbQl96T+Ch/6FKBHJecqUKM5BuufJSBGAdX2q8dqXdVmpnUEdNC 4ZWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4hnrQlT2; arc=pass (i=1 spf=pass spfdomain=flex--jstultz.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-77337-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d12-20020a170903230c00b001dba2bc22efsi11189845plh.350.2024.02.22.12.49.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:49:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77337-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4hnrQlT2; arc=pass (i=1 spf=pass spfdomain=flex--jstultz.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-77337-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77337-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F0FE328D21C for ; Thu, 22 Feb 2024 20:49:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 620BB71743; Thu, 22 Feb 2024 20:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4hnrQlT2" Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 218C0107B4 for ; Thu, 22 Feb 2024 20:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708634966; cv=none; b=D2qhoIuWRssca8uZ/7TrowuU4WYFElsCL8nhk3tpLNgekecDoqJMvsS0CRbaMBW+9tTaOWcjb0FyZ8PD0G08Y20QqD6L9t6A4/+SxYCNDwc7IL2VUGKgAt1u5HdyASLPyBsKGWzYJjEyWd0eiL+7OznJuKyMRvFSZTyv+6acHtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708634966; c=relaxed/simple; bh=t6lIHG5+4nq4OdH6rjR/34noTWcvT5l1VGyYFtSM6QE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ATKNCHR/F2OUj8q0RkUzKjMbqB4/08yF+GDvLFJaa9sk6ZpG7NyoK5G8xb43IGa/UryuQgIOsBAP2NkIX3OTCGcmEDfPEon/7XB6VJ0N/RMxuQYWp9MCHyMrOuoCZEbD8jklTQIRtTC/StUsPHlWia/gxNYdBKlnKjk2YwTBm68= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4hnrQlT2; arc=none smtp.client-ip=209.85.216.73 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=flex--jstultz.bounces.google.com Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-29a5bae5b3fso152983a91.2 for ; Thu, 22 Feb 2024 12:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708634963; x=1709239763; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=SRK9EHuaQ+JCWCMfavbkHoRAzX9PoIfHas8OXdMxkpQ=; b=4hnrQlT25VPjn6pjfdLMqVPQrgy3o6Ag8Qug1l3WsqX8/NSwoHp14937uhHjxKCPEv m35hgFl8uG8a35XKHoLcufELeTvuGKdLVaEgjT1G/RCGLJs1E7aUz7RW/GL4uBrRNlVQ j2WItNtDvobYjy7Lbu9I2n1Ve4qM8wh8xNBtuL5E49RDRa0JYfhx0YDZWyEQzW419QJS VRfj4cTwt38eEUoou+HacWr/xM7MdlcZA5GLZU+fuP2HieVzhV8x1J9DEN5PJzFNP692 99TobyXAFOb01ueQVTOhT5EeduMQhY6pDbsOKGVpSRE1MKezjnAqMTfi1Q2r0UZKCc+t B7Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634963; x=1709239763; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SRK9EHuaQ+JCWCMfavbkHoRAzX9PoIfHas8OXdMxkpQ=; b=uikfsUJdtH2i5NoSkNBv+9J21Ap+GEkYIVUjLt7YLcC4U94x1AJSf5Ea6sFZVHrZ6I xP3+TA4j7lM/fqN2qDJUC6T7f/c/Pjt0cmlmxOEx4A/SQjs6Yg0uJwIG//bVuQJKmQJS fFjptX/JHJ6dTlYsDOf9fG5HnPCX8RUxw++kUUAYCTEhCTCg6nrDKfR1lvvsZKQjg3lq XVNfH5kOJ+vMfpK/nFj5W0OAcHxVHtM9JEhbyAmauZFnICUkAmlyL59UwrSRAHIeIt7p WAk/lX4Ebgkwb8mhmmQyWQj7BRIkb+EYz/EaeHyu9JS66HxvFAxhJ8nWJ30/vBMihH0e eCDQ== X-Gm-Message-State: AOJu0Ywz59HFqQdwfmsvgYxD9Yr4uY7qAX93uBEzyVABnjw0bGDZIQ+s vIXYONTc3IunTxSFVsykQ49ruaOmmoCx1KrqHLgygWzQtoYMXqslfQtAwCUZ0qKd8CA5to+myur EKd1DIiQgE59jlP4+zwxeB3QgkIuQ2aMX+AoQLMN8nBIomNI4ucL4yt1T0cR6TfatiQDv+NDQrl 6POyj3xXB3UimEnJBzx+d0F8DYhpkYqbYxfNjMBL+grjec X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a17:90b:2e05:b0:299:998d:1251 with SMTP id sl5-20020a17090b2e0500b00299998d1251mr76807pjb.6.1708634962783; Thu, 22 Feb 2024 12:49:22 -0800 (PST) Date: Thu, 22 Feb 2024 12:49:03 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240222204917.1719153-1-jstultz@google.com> Subject: [PATCH] [RFC] sched: Add trace_sched_waking() tracepoint to sched_ttwu_pending() From: John Stultz To: LKML Cc: John Stultz , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , kernel-team@android.com, Zimuzo Ezeozue Content-Type: text/plain; charset="UTF-8" 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_wakeup() sched_ttwu_pending() -> ttwu_do_activate() -> ttwu_do_wakeup() where trace_sched_waking() is currently called only in try_to_wake_up(). So this patch adds a trace_sched_waking() call to sched_ttwu_pending(), so we see the same state machine transitions. With this change, the number of unexpected state transitions in perfetto was greatly reduced. This has been in my drafts for awhile, so I wanted to send this out for thoughts/feedback. Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: kernel-team@android.com Reported-by: Zimuzo Ezeozue Signed-off-by: John Stultz --- kernel/sched/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9116bcc90346..233f06360d6a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3894,6 +3894,7 @@ void sched_ttwu_pending(void *arg) if (WARN_ON_ONCE(task_cpu(p) != cpu_of(rq))) set_task_cpu(p, cpu_of(rq)); + trace_sched_waking(p); ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf); } -- 2.44.0.rc0.258.g7320e95886-goog