Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp280114rwd; Wed, 31 May 2023 23:26:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zkWZK9M8l+3NtkVGu+lH7HcR6akh3v9pYz2PbnjKu5fMcfFk30ZdwZg7N6F9euL9ouCoS X-Received: by 2002:a17:902:850a:b0:1ae:5c72:d63c with SMTP id bj10-20020a170902850a00b001ae5c72d63cmr5178967plb.11.1685600761916; Wed, 31 May 2023 23:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685600761; cv=none; d=google.com; s=arc-20160816; b=xHxcBzyikFWmobzMcLJea40GM2bhqMK6T8ntD5QMZejCKAq56rdZrLpPKJirBi7M2P WQFUYc9NmgZkdKw3FXjgDIM32tGY7Am25/nzCVj3FHPJmi78qQJQg5X5pfZKwxIPRVls aChIsiLNX9r+oG3ZI1SrrE8uUcAWW9kNj5xDd/86s4gR7nCAOZz5hn0LCq12I9cxQ2af 7jpNMGCfwnL+/Rp/fUlDGURNttRoHx5B5VoyZaaO8PabrDpvM0HdyKdn8TxBCPja8kwk 0UmmYHT1xyFVmpKmwTzOSKoxh0PbaWseTmChMJ5/y64aGkT9b72G3VaVkw+brAqsSbpT JrzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Nl83JFmq5DGiAWWnIdFRVnY3DNvwp/CATr/wZmCpEuo=; b=gp2mG9grfgnxtzLjT8JSQHf5ZRF2oaxq+dnkSyQizWVRldnTVfEbHS+b6fPpi8LKDB NdumiMW4yut71vCkSmVdip8Bf8xuFn4WrNPvdCYOEdvkVzBplZ9YxYSlbO1i0oPUXmQ3 hX0dmI8dZwgNQBrYaSRQObTJuhdi+ssD9jLERTlGFc81q0M/fKv639ks8TTU+pJ6hQAU 1gEAU1avQ59WW6zDzS8h2MSprqx3m5YMQ4Z6sfjMBqasNnAm4nwsRsEEI4Im0+u1v/Vk CSky5Q9Z/Bs2hRg0CzQFdTdx3kqoWkQgEe2AHkkb+nJbU6G+e6zcNmCOUmh3fa0bAziQ RZug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="ViVgx/Pu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a17090264c200b001b01d8f7586si1307973pli.649.2023.05.31.23.25.50; Wed, 31 May 2023 23:26:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="ViVgx/Pu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbjFAGAz (ORCPT + 99 others); Thu, 1 Jun 2023 02:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbjFAF7w (ORCPT ); Thu, 1 Jun 2023 01:59:52 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 332DBE5D for ; Wed, 31 May 2023 22:59:20 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1b03ae23cf7so1285925ad.3 for ; Wed, 31 May 2023 22:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685599159; x=1688191159; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Nl83JFmq5DGiAWWnIdFRVnY3DNvwp/CATr/wZmCpEuo=; b=ViVgx/PuN9MLmdNybo41KvSJ+mqfr/QrzY3xE1C+mEnv4qvIG8Vh4e4lAZq8o/pi+6 BuAai3UElvNic61P7FJHBK+0xOElM9YDgRpupsAZv1HIXfQmHojcQ++RThtOAZJB6D0K bxY2XDj3I7lytKbMUskON/IwrVL/HImFBiAiwCqo0NzGWFYJDfkXpysgIwln2UjsXC0e AvYTEnwtdIZZSq7h5TsIHyjlmWOQDHDKAujHxLqnwpcZ6OY5V+v0PlkibSTLcFnleBdn yTvV9sN/zEDtIsOld6sHqGEou51tPudWF8Gc4dGA+lmXHxjeaqBO6R0jETCk7lNAA4cI V0oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685599159; x=1688191159; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Nl83JFmq5DGiAWWnIdFRVnY3DNvwp/CATr/wZmCpEuo=; b=XQ2nRmJfQYaYx4GuVvJ5cJvGp2WYSGYwyzlDJJnqABiKd7AjokHv+KdNIoHJVFPvtB n7Dfpnu1pcRLE2NQ+44EPZ5PviUu8IX1DP/g+QPbbqG4Rd4AfcVKQstcUBeh1aCuwhWp UCjpvjbiYS7RGt6uUjNp1tSqYsdbXTKRZR6JnI+kRDHtF0Qc1EWsH2PpTROdLJuhsI6H 11hde5t3ITWIAAuWi448tdKZuK5mYk71MYD3fFEO9Qpzwz5mWv7jkER80L8sOgS6fhuR /kctzMpdPFtDb9v/rGWykHLp5Yormp5c6+zo+EF00sF6CgmtEjXSjGUBct+COIqOSUnK zBaA== X-Gm-Message-State: AC+VfDz3E9mbcCmXIpVmgsDxlyQTPogAeXHY77aA1i04GeFBvx0wnXnF tdc5oTe04ARoxBGPqg1/mK0zvsDhTWx508P5/kHU9AEMaaQZr66yKdxocu6OEvENkynCTVR58ma x+0BWsJTasVrPeL4vvL4iR2mhT2LtyO4/40Z0Hs5nDLKDbtTL1v6NPSunVmFrosMe6JqHOTk= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a17:902:8486:b0:1a6:6bdb:b542 with SMTP id c6-20020a170902848600b001a66bdbb542mr1830304plo.9.1685599159247; Wed, 31 May 2023 22:59:19 -0700 (PDT) Date: Thu, 1 Jun 2023 05:58:16 +0000 In-Reply-To: <20230601055846.2349566-1-jstultz@google.com> Mime-Version: 1.0 References: <20230601055846.2349566-1-jstultz@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230601055846.2349566-14-jstultz@google.com> Subject: [PATCH v4 13/13] sched: Fixups to find_exec_ctx From: John Stultz To: LKML Cc: John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Youssef Esmat , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org find_exec_ctx() would sometimes cause the rt task pushing to try to push tasks in the chain that ends in the rq->curr. This caused lots of migration noise and effecively livelock where tasks would get pushed off to other cpus, then proxy-migrated back to the lockowner's cpu, over and over. This kept other cpus constantly proxy-migrating away and never actually selecting a task to run - effectively hanging the system. So this patch reworks some of the find_exec_ctx logic so we stop when we hit rq->curr, and changes the logic that was returning NULL when we came across rq_selected(), as I'm not sure why we'd stop there. Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Youssef Esmat Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E . McKenney" Cc: kernel-team@android.com Signed-off-by: John Stultz --- kernel/sched/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e0e6c2feefd0..9cdabb79d450 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3881,7 +3881,15 @@ struct task_struct *find_exec_ctx(struct rq *rq, struct task_struct *p) if (owner == exec_ctx) break; - if (!task_queued_on_rq(rq, owner) || task_current_selected(rq, owner)) { + /* If we get to current, that's the exec ctx! */ + if (task_current(rq, owner)) + return owner; + + /* + * XXX This previously was checking task_current_selected() + * but that doesnt' make much sense to me. -jstultz + */ + if (!task_queued_on_rq(rq, owner)) { exec_ctx = NULL; break; } -- 2.41.0.rc0.172.g3f132b7071-goog