From patchwork Fri Mar 1 03:26:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 208623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp834761dyb; Thu, 29 Feb 2024 19:26:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQisek8WdAq7FQWboF8hinFJTApspszVDtNlInAhl55sjxesQXKvWqMAhhyQoWHpnBZw+eVVww7xlsF3+e80cxuZgQtw== X-Google-Smtp-Source: AGHT+IFyU8I6WIdNajqfjUk2qmKYGa0NSbZ/K7W4arAr+KnsACsYjLN70h6uGlD4BIBhUmzJLk6n X-Received: by 2002:a92:c56f:0:b0:365:16c8:ca8c with SMTP id b15-20020a92c56f000000b0036516c8ca8cmr713768ilj.10.1709263616291; Thu, 29 Feb 2024 19:26:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709263616; cv=pass; d=google.com; s=arc-20160816; b=sI6vgg5YH/m5hts5e6ihmOtfTHCxy1gtY3VnQV4aErbPmsvpREh1ePZdkedMC9v6Uf gaNsKRIH9Ujxk9KL8s2DImkd8ExEwkwiQ9rTSu7SQa7D0YaOb1CRk9rh/9oukWKSGxpn Nr9MHH1qxPFE1CeddcO/cOUSH0kkk3Nfxa5tUqPukEcBfdAV6WA9OkWIe/pATTmgtjGS s+kg6gFvlYAX/Q998ZoWKXXViuwvWK4cF2uXv0tP5LHeqgdgSoJxaZQq0iMd0M+VCafN g0r0NB6VwdeXY1jS9Bx9wbXTh2rN3D7z5MyesguyoNOqvEzP1funTnrOTYJuPVLMJLNS EN+g== 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=FKZzJvKcTnDdeF2Ft5+qWzW9X1Dsw98upGCNkUTIMRw=; fh=VBZwxvNvoyjuxI8urLL2jGn3no286VH9Za3DjJIT6gs=; b=HeN/1pAH8Zz7klMuQojTewTrAF6cM2glU8fxmn0sxfB15NIPzi2koqLubhWuu+asrO Rsvc8rWEUwS6epodxR54BpR8gtuW4wB3L+sCTiy9o0goms2nD8obnceaIizaZLZfqjWU XWiH6RiXZjwVKE9P1I8ilzF4kdpqCZcYJgmnNzCh8+7bQ6VFcUX7beGMebCejdHIrHNF aQ99HFNQOkOFd5sdF91FNT3uLOt+Cg/6vvJ2X+DSqdvqaLUA9LCN58NxbgOkETFvgmGi I2oZJQgton8yE2cx2xZByJ6H7KYEmC/S0GOk1u1+iLgmVWCVhQjnRSFXAqMNOfml8qib DtOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TaEUhDPx; 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-87856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c18-20020a056a00009200b006dbb1f82e81si2538597pfj.170.2024.02.29.19.26.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 19:26:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TaEUhDPx; 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-87856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87856-ouuuleilei=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 1C59D28553F for ; Fri, 1 Mar 2024 03:26:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E23CF42067; Fri, 1 Mar 2024 03:26:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TaEUhDPx" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 B410B2F2C for ; Fri, 1 Mar 2024 03:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709263604; cv=none; b=ep57rBl8h7825K/EOqowo+YUPzOCGYrDBJbi+Bz22TJfiSK/fUGhISAbQejFSI46cUo9jiR4BrtSyOPIADk/6WcLFfJ+I50UHfZyd/p2i/7njYzBBojLYnzsh1FLZq6FJFEG4uGNxwZ6iByePtDiAIOg6h8WoSVG5Zym1Xw5C0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709263604; c=relaxed/simple; bh=rbPCodznqhHhUtDUQSimWS+lG3PT01VsV2ENo/lepjk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=NzI32uYY62FUMa/GhRb20LW0nds/pIjpFNEj2gG/l7CpAD4j0WYUCxYNnAIyDpDLSOJCng+tqvwOxOim3IuXskdmo5OukxwM3jYIWo7o4oYBvJhQY+soVQrE+8G1/qYaogQ0cOs6CRT32gHbLwMDah+yps0PszBzqEIY0lbIkaY= 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=TaEUhDPx; arc=none smtp.client-ip=209.85.215.201 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-pg1-f201.google.com with SMTP id 41be03b00d2f7-5cdfd47de98so1339704a12.1 for ; Thu, 29 Feb 2024 19:26:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709263602; x=1709868402; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=FKZzJvKcTnDdeF2Ft5+qWzW9X1Dsw98upGCNkUTIMRw=; b=TaEUhDPxzE7v4gKfnNAHFw2IGBl8DYY3s4C6uxdsk3jpJWZ6t5ZiOIsuYIlJClpOCO tZOEOaQ05LEsli2b24yT3/MRcaChqy+yS4CvlA06cIxTdQ+APQT79bqeaGjAYCeA1TKz kW5PpT3w+yx/QCEyPFBj7Cro/N990Q1cAF5jiLBI6OMg4t4KOxOulyUyK+UmsWcmSILj XU2ZOMIUc/5GvEDazmQxvZvsUgyBDfo1+6lKm6pPX/OVYasvuko1wqiL+X2y2AHv+YB4 Bn2tbgqksomb2gisqPuu6htW6LGxUvXyR06wTA5kFoUCRdZlmwRgLmj0fAqEksSisHFy lNMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709263602; x=1709868402; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FKZzJvKcTnDdeF2Ft5+qWzW9X1Dsw98upGCNkUTIMRw=; b=aOWgexTueK1gNh/mCx804Aji35TejbdTEm1TXwEGMBsoTGmB5YjTEBplcfYJj5f5RF X23ut1uwLddmo2EtBxMd/p03IqffKtwSYhp57zAM2TyS1B9yustTs/X831FQvIxFcu+z 1HWINyzB/3rM6JKxDo3baYBhCO/Pc8A9cyP7wQ7ITtCSyN6/73qXp8kAeb7bF9sqWq7E IwZw5l1A0PiPC32ioR99K46vEhAnt0i4rYxYhIW9eBC1olii02m5fidIVQ7Z9UaV2X90 n/0fSVgDxcFFxnpF+kHVedBESXw19Eh1qTkdlBCIsIrVwNVBiQ7hY8tnOXBVfD0ZflbZ hQdQ== X-Gm-Message-State: AOJu0YxnR4F1PrKxMBzmUdetBbt7MyaDkP6m+PX9vNwul+FqTj/VsSZF WMRGuEIGHWlNDJoVcpeXzpyR5VN6DzluN/kesUn8ng0jXEooZI+Ya8/RMnHFaU11rhMyw/ewCWR 4WVGxF2mlucJTc+NtY4VLr+UxDopMrIcMqscRC4rZufgIY87SC/Nur/4NWnz0lisK10YHM5sZoK BTzOzNPNkTQFA7bszlF40OmvRpulFr2iLQvWBM7peSOlrd X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a63:6fc4:0:b0:5cf:c149:8dc with SMTP id k187-20020a636fc4000000b005cfc14908dcmr684pgc.11.1709263600707; Thu, 29 Feb 2024 19:26:40 -0800 (PST) Date: Thu, 29 Feb 2024 19:26:24 -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.rc1.240.g4c46232300-goog Message-ID: <20240301032637.2117250-1-jstultz@google.com> Subject: [PATCH v2] 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 , Phil Auld , Valentin Schneider , kernel-team@android.com, Zimuzo Ezeozue X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792292805580378990 X-GMAIL-MSGID: 1792292805580378990 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 add 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. 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: Phil Auld Cc: Valentin Schneider Cc: kernel-team@android.com Reviewed-by: Phil Auld Reported-by: Zimuzo Ezeozue Signed-off-by: John Stultz --- v2: * Minor commit message fix suggested by Phil Auld --- 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); }