From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E988ECAAA1 for ; Mon, 24 Oct 2022 10:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbiJXKNp (ORCPT ); Mon, 24 Oct 2022 06:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiJXKNn (ORCPT ); Mon, 24 Oct 2022 06:13:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 87751C35 for ; Mon, 24 Oct 2022 03:13:42 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FAAAED1; Mon, 24 Oct 2022 03:13:48 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D5F263F7B4; Mon, 24 Oct 2022 03:13:37 -0700 (PDT) Message-ID: Date: Mon, 24 Oct 2022 12:13:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [RFC PATCH 07/11] sched: Add proxy execution Content-Language: en-US To: Connor O'Brien , linux-kernel@vger.kernel.org Cc: kernel-team@android.com, John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" References: <20221003214501.2050087-1-connoro@google.com> <20221003214501.2050087-8-connoro@google.com> From: Dietmar Eggemann In-Reply-To: <20221003214501.2050087-8-connoro@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/10/2022 23:44, Connor O'Brien wrote: > From: Peter Zijlstra [...] > + * Returns the task that is going to be used as execution context (the one > + * that is actually going to be put to run on cpu_of(rq)). > + */ > +static struct task_struct * > +proxy(struct rq *rq, struct task_struct *next, struct rq_flags *rf) > +{ [...] > +migrate_task: [...] > + /* > + * Since we're going to drop @rq, we have to put(@next) first, > + * otherwise we have a reference that no longer belongs to us. Use > + * @fake_task to fill the void and make the next pick_next_task() ^^^^^^^^^^ There was a `static struct task_struct fake_task` in https://lkml.kernel.org/r/20181009092434.26221-6-juri.lelli@redhat.com but now IMHO we use `rq->idle` <-- (1) > + * invocation happy. > + * > + * XXX double, triple think about this. > + * XXX put doesn't work with ON_RQ_MIGRATE > + * > + * CPU0 CPU1 > + * > + * B mutex_lock(X) > + * > + * A mutex_lock(X) <- B > + * A __schedule() > + * A pick->A > + * A proxy->B > + * A migrate A to CPU1 > + * B mutex_unlock(X) -> A > + * B __schedule() > + * B pick->A > + * B switch_to (A) > + * A ... does stuff > + * A ... is still running here > + * > + * * BOOM * > + */ > + put_prev_task(rq, next); > + if (curr_in_chain) { > + rq->proxy = rq->idle; > + set_tsk_need_resched(rq->idle); > + /* > + * XXX [juril] don't we still need to migrate @next to > + * @owner's CPU? > + */ > + return rq->idle; > + } --> (1) > + rq->proxy = rq->idle; > + > + for (; p; p = p->blocked_proxy) { > + int wake_cpu = p->wake_cpu; > + > + WARN_ON(p == rq->curr); > + > + deactivate_task(rq, p, 0); > + set_task_cpu(p, that_cpu); > + /* > + * We can abuse blocked_entry to migrate the thing, because @p is > + * still on the rq. > + */ > + list_add(&p->blocked_entry, &migrate_list); > + > + /* > + * Preserve p->wake_cpu, such that we can tell where it > + * used to run later. > + */ > + p->wake_cpu = wake_cpu; > + } > + > + rq_unpin_lock(rq, rf); > + raw_spin_rq_unlock(rq); Don't we run into rq_pin_lock()'s: SCHED_WARN_ON(rq->balance_callback && rq->balance_callback != &balance_push_callback) by releasing rq lock between queue_balance_callback(, push_rt/dl_tasks) and __balance_callbacks()? [...]