Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6573029rwi; Mon, 24 Oct 2022 03:20:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ydLY0HtYCIFZlyVNIge4+nZxXpfD2deEvUdSR3368IFSqeIlytRAS5nKbABii//HrPuSN X-Received: by 2002:a17:90b:3505:b0:20d:ba2e:994b with SMTP id ls5-20020a17090b350500b0020dba2e994bmr61516059pjb.46.1666606848851; Mon, 24 Oct 2022 03:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666606848; cv=none; d=google.com; s=arc-20160816; b=DBrwWEhV74y1NJrs0v/mnXnzES4NQcM/BLs1W/HPp2X+NpKRvMgZfK+kAcOLnffurD +VCMU1yljm0uvFlve9VrkeQPehFXKIp5A0syTUBPyb2BhQDecuPtK+rx6tLndt5WFlm4 2TgUKZ+A/Ef8xH9UMFaqATQKzqHYpsuEQy/+8Mm6t7gzqichDfa05inW5yDCddaFtljw nlMSUbpMivg4lj4g2P3GD3YF9n8RnrgtXgLDW2f/76V/P9QJ8WxcKonluUDWyRG/Xw8K ReqV6WR3c32hGOQ2dpzgfIJn9wjhYLQ18NLTYZ/EOvU2G+wQXMUHoib8Nvy2rDU01BJk 0+pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=PXszBZNFKR2uqPxSYGZNvsBPAMC0/1PuRjYjiX1+hVE=; b=MR+GGH9qVBTsRKKMGA/76MS1aWvfio7UF7Ishl2vzblxJNTZZnEvNEcrllHUxOVwxJ 9rT/MhkMdU/MbU2jwXgsHyYrPsNB6YWwu0yl93besSHnwWEH5QbuhYZ0mDd5AqoP/8WK 2nI1BezJ9PlwdwA+vuw+2VBfwfCMKJzb9whc2wuQdlz0z83oVwbNpE7hECbLqikaaBzE 14g7LzRVEDB5tvSXJQaAAL9J2bAowEOZSwfzc2h5zAlAse5caQen1LpHlDPkxIiW0D7j ik39TmKvsGgc+wvFCkf1UkBeiKZ/kUYn53KuvBs8h57ajq+Yei0TdzZIeEggMhLlbNpy 2QYg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t185-20020a6381c2000000b00437e609414dsi33087575pgd.563.2022.10.24.03.20.35; Mon, 24 Oct 2022 03:20:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbiJXKNo (ORCPT + 99 others); Mon, 24 Oct 2022 06:13:44 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 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()? [...]