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 E1AEDEE4996 for ; Tue, 22 Aug 2023 15:20:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236915AbjHVPU3 (ORCPT ); Tue, 22 Aug 2023 11:20:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234758AbjHVPU1 (ORCPT ); Tue, 22 Aug 2023 11:20:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7DD9ECCB for ; Tue, 22 Aug 2023 08:20:25 -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 A7DB411FB; Tue, 22 Aug 2023 08:21:05 -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 B6CAA3F64C; Tue, 22 Aug 2023 08:20:21 -0700 (PDT) Message-ID: Date: Tue, 22 Aug 2023 17:20:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v5 16/19] sched: Fix proxy/current (push,pull)ability Content-Language: en-US To: John Stultz , LKML Cc: Valentin Schneider , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , 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, Connor O'Brien References: <20230819060915.3001568-1-jstultz@google.com> <20230819060915.3001568-17-jstultz@google.com> From: Dietmar Eggemann In-Reply-To: <20230819060915.3001568-17-jstultz@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 19/08/2023 08:08, John Stultz wrote: > From: Valentin Schneider [...] > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index bee7082b294f..e8065fc5c894 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -6656,6 +6656,21 @@ proxy(struct rq *rq, struct task_struct *next, struct rq_flags *rf) > raw_spin_unlock(&mutex->wait_lock); > return ret; > } > + > +static inline void proxy_tag_curr(struct rq *rq, struct task_struct *next) > +{ > + /* > + * pick_next_task() calls set_next_task() on the selected task > + * at some point, which ensures it is not push/pullable. > + * However, the selected task *and* the ,mutex owner form an > + * atomic pair wrt push/pull. > + * > + * Make sure owner is not pushable. Unfortunately we can only > + * deal with that by means of a dequeue/enqueue cycle. :-/ > + */ > + dequeue_task(rq, next, DEQUEUE_NOCLOCK | DEQUEUE_SAVE); > + enqueue_task(rq, next, ENQUEUE_NOCLOCK | ENQUEUE_RESTORE); > +} > #else /* PROXY_EXEC */ > static struct task_struct * > proxy(struct rq *rq, struct task_struct *next, struct rq_flags *rf) > @@ -6663,6 +6678,8 @@ proxy(struct rq *rq, struct task_struct *next, struct rq_flags *rf) > BUG(); // This should never be called in the !PROXY case > return next; > } > + > +static inline void proxy_tag_curr(struct rq *rq, struct task_struct *next) { } > #endif /* PROXY_EXEC */ > > /* > @@ -6711,6 +6728,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) > unsigned long prev_state; > struct rq_flags rf; > struct rq *rq; > + bool proxied; > int cpu; > > cpu = smp_processor_id(); > @@ -6760,6 +6778,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) > switch_count = &prev->nvcsw; > } > > + proxied = (rq_selected(rq) != prev); Looks like proxied isn't used here. (*) > pick_again: > next = pick_next_task(rq, rq_selected(rq), &rf); > rq_set_selected(rq, next); > @@ -6786,6 +6805,10 @@ static void __sched notrace __schedule(unsigned int sched_mode) > * changes to task_struct made by pick_next_task(). > */ > RCU_INIT_POINTER(rq->curr, next); > + > + if (unlikely(!task_current_selected(rq, next))) > + proxy_tag_curr(rq, next); > + > /* > * The membarrier system call requires each architecture > * to have a full memory barrier after updating > @@ -6810,6 +6833,10 @@ static void __sched notrace __schedule(unsigned int sched_mode) > /* Also unlocks the rq: */ > rq = context_switch(rq, prev, next, &rf); > } else { > + /* In case next was already curr but just got blocked_donor*/ > + if (unlikely(!task_current_selected(rq, next))) > + proxy_tag_curr(rq, next); (*) v4 had: + /* In case next was already curr but just got blocked_donor*/ + if (unlikely(!proxied && next->blocked_donor)) > + > rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); > > rq_unpin_lock(rq, &rf); I miss changes in enqueue_task_rt() and put_prev_task_rt() related to 'affinity of blocked tasks doesn't matter' from v4.