Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3414524rwb; Mon, 3 Oct 2022 14:49:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DMPBQ5oJ5UCQ49uK6L8s57zK9ubPEw+MF7WqI3bsEB0d9+5UksvzjrNjzhzPQdI6ZWvUk X-Received: by 2002:a17:902:d489:b0:179:fc52:b49 with SMTP id c9-20020a170902d48900b00179fc520b49mr24055878plg.86.1664833794741; Mon, 03 Oct 2022 14:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664833794; cv=none; d=google.com; s=arc-20160816; b=KJ2d2Osjfa0/GekAwEOEtuPjK1Kd4mnC80k9f/PQmRYnPLVAZADynOZbW2hvHiUYZ4 Yh/pojpIqcru0AUXzHdCnFrbQH4OP7LcK6dPg6ktQNU3iowniJHlUYcsVrCHxqhHjX9v YL/P3ssg2T11vMhMe1ixSzo5NLlHOcwSjRIscudUEUdVlAaiUI+/AvTkJk5iiYSf+hki YHoa+fFv7gyLDxW1KEHcBOBFk+d4sp4plA8I8sRQx78bQD2c3TrntV7VrjW/ewGox8nj 3TWRucTMD4DbJpjYyU+1lJl3+w/62Nx+09kr8WLm5E91FSoZEH8uYbhUjYKYgyPyscLJ wijQ== 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=sJzQbAD1j79Fgzv+EsYJl3ZM82fW9e/y9W/ZIo2cgr0=; b=IrA2uQSnRBjwMo6GlV/+x47S8YFcnW9v0SI7SWU66POJ/Ot5PYuC5nMCwDDUOgjLbD lYlm2oXqqoay81ptUdH4eW8ok7ELzHTsdRWPWkKJ+2rcfgxt81MkcgdwgQROOK6ORyko vER1C9NRbRC3LCkf9gSWBxRQ6sAo484X8fktpmHA45W+uRAUUVWDpZpNkeCi+4d9OQF5 6Aw2ejSfWCAjsuFPpqWeXYWceyTMM2LZI7dVN702uQTBHA4oUiFUS5gG3TTG7etaWGiy eZF5ibcRNsBd7dAA4w/zH6evAf+p0NLXfHSc9qm3NfPSYlisSF3Ge+YGosIGSZh87NJN nE3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cECuW8WU; 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 p67-20020a622946000000b005618039550fsi3264649pfp.271.2022.10.03.14.49.43; Mon, 03 Oct 2022 14:49:54 -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=20210112 header.b=cECuW8WU; 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 S229810AbiJCVqF (ORCPT + 99 others); Mon, 3 Oct 2022 17:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiJCVpc (ORCPT ); Mon, 3 Oct 2022 17:45:32 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D241DA64 for ; Mon, 3 Oct 2022 14:45:18 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id u5-20020a170902e80500b00178944c46aaso8959776plg.4 for ; Mon, 03 Oct 2022 14:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=sJzQbAD1j79Fgzv+EsYJl3ZM82fW9e/y9W/ZIo2cgr0=; b=cECuW8WUVfjgImf9pVAIBJjw5obKd5ujde8lV0abrnw0zqcxL0qSiEJ5LJfFgLeDjY +Zoxpp6LAC3RtFqSSlodHid7ZW2nBTmKHi7o/FsytMwsX6UwbkT1Fpw1YoUUgLLE8jks iEmNI2Y2RGHQJ9eBvNSIjtkN6dyToUqyQJz5IC7sem7S2RyaNH8j8o56YEuJ15QCsEMP crp+xJEbn5h4YOfEeBmL9s4BMBTh8aQZwtP9DWl7jHeUWIDlN3WSpOxk+79DaaF0UY7u ZrbQGizhq7hDbUTfVrA8HIfpkoyOoSh2IfIMPStcxEX9KCcF8z1tkp+A36aUhhnuIMIJ QCPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=sJzQbAD1j79Fgzv+EsYJl3ZM82fW9e/y9W/ZIo2cgr0=; b=zeZl5rjJu098hoAlJUcsKJUiQrQlMtQ3RkhdqldgNhQfBj3hhcgzOtZbtLJrKtKJYe AaOx8zbVpwOK9PYo6L5Ng20HhEfjj4AwhccwuEXn7/utoct5ZrDe4+K62R+mW6I4nzmM 1gw/sasJD886OfEEF4O7IhQWuZe3K7h9/6zguuMnlJbxYv5wEFHv6iPSFtOv5Xk1ueUr v072WI8ToFwRa0tMZ5ogMewUTDUmYkxGCdt/oVmWw/lqVWZ03lkbTQR3R3jb0eau33KX wvT6AlsY1eDnu/rRPYjOoihOkh6LxwZefIkDtPngO0aAJphn7IH0enhiN23VyLlhjHLp Oq5g== X-Gm-Message-State: ACrzQf3ogb/4sM4nDDSxSbmUti562STUD1q4YzLLL7c2KihSEN2cJx9G /XeNsZ54O4kfV/Jkcz+TCBredxY1YSZNlNOyhA4YgJN/bn8LcZ1yxV9Prlw3vF2xhZS2/06VPS4 IpoYQkbeLFE3Juiz8oALObDh0RkJ5duo6AJlmGX4GRpnH5wQfGCg01pj1SBpi55Qun1BcSQaS X-Received: from connoro.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:a99]) (user=connoro job=sendgmr) by 2002:a17:902:864c:b0:179:fe02:611e with SMTP id y12-20020a170902864c00b00179fe02611emr23421349plt.10.1664833517735; Mon, 03 Oct 2022 14:45:17 -0700 (PDT) Date: Mon, 3 Oct 2022 21:44:58 +0000 In-Reply-To: <20221003214501.2050087-1-connoro@google.com> Mime-Version: 1.0 References: <20221003214501.2050087-1-connoro@google.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221003214501.2050087-9-connoro@google.com> Subject: [RFC PATCH 08/11] sched: Fixup task CPUs for potential proxies. From: "Connor O'Brien" To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , "Connor O'Brien" 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,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 From: Juri Lelli When a mutex owner with potential proxies wakes up those proxies are activated as well, on the same CPU of the owner. They might have been sleeping on a different CPU however. Fixup potential proxies CPU at wakeup time before activating them (or they get woken up with a wrong CPU reference). XXX connoro: plan is to fold this into "sched: Add proxy execution" in future versions. Signed-off-by: Juri Lelli [Fixed trivial rebase conflict] Signed-off-by: Valentin Schneider [fix conflicts] Signed-off-by: Connor O'Brien --- kernel/sched/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 416e61182c17..ad2e7b49f98e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3733,8 +3733,15 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags, raw_spin_unlock(&pp->blocked_lock); break; } + /* XXX can't call set_task_cpu() because we are not holding + * neither pp->pi_lock nor task's rq lock. This should however + * be fine as this task can't be woken up as it is blocked on + * this mutex atm. + * A problem however might be that __set_task_cpu() calls + * set_task_rq() which deals with groups and such... + */ + __set_task_cpu(pp, cpu_of(rq)); activate_task(rq, pp, en_flags); - pp->on_rq = TASK_ON_RQ_QUEUED; resched_curr(rq); raw_spin_unlock(&pp->blocked_lock); } @@ -7114,7 +7121,8 @@ static inline void sched_submit_work(struct task_struct *tsk) * If a worker goes to sleep, notify and ask workqueue whether it * wants to wake up a task to maintain concurrency. */ - if (task_flags & (PF_WQ_WORKER | PF_IO_WORKER)) { + if ((task_flags & (PF_WQ_WORKER | PF_IO_WORKER)) && + !task_is_blocked(tsk)) { if (task_flags & PF_WQ_WORKER) wq_worker_sleeping(tsk); else -- 2.38.0.rc1.362.ged0d419d3c-goog