Received: by 10.213.65.68 with SMTP id h4csp278339imn; Fri, 16 Mar 2018 02:52:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELteZPdK9xBMrYfKcZbbSNgm/5TZNUmJPTZlA8yRNoYgxwm9B7JF7JK/d7t+U9yZy5DjikH/ X-Received: by 10.101.102.79 with SMTP id z15mr950789pgv.181.1521193951770; Fri, 16 Mar 2018 02:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521193951; cv=none; d=google.com; s=arc-20160816; b=ulcekMh6Tl7GMJGdGdN3nitA4OU3fChq4XiAXOWbkptcowsvKy59K7yxPrJUB2wcW9 VbaSoSPd9kjAFdwCU6JyEGTMEzaNl+meqnE42SH05erFKKaKbheEAZEMkzXg0nUCYVij HmdTks40pVYfsibRNr+a0h6ykGdtqDKjh9hhRd2zzWum9dz6IBkcn9i29nV/yCXzK4yf M/AaUXuGzh4FGVoymtKpxAu8ilRCO3HIg/dDob2D5oldQvZoBlz54joJ5lNnhL1ZphZP omrujeeHd8+/leEmIiE+QdfhVqdE+EV6mHX4aooIXjwQHp2ohTyNPR4eUWW4aTTFBUw1 KhJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=GXVLsvO9/z/6OSmGRjRJKG1TxDgWdvswWBs6zF2MvH0=; b=aGlL1ObtLC0hpT4OlDPgcKdGSM8KZltKEB8b4qE3sxstz7q8fhtJKaDII9CSjzW/uy gk2fahZ+2KKVrbF4HD7xV0pQxBOyTWPVN3bIUTV1V4QfME18wUWPoJvywfClJgT6jbAl vtLNGrdAxmlyZsxLKUdggglvJsZY1LXy5lJF88N7MGHS/3MCe8a+4n5eM7IGgWj94hvP wC1sc7VAuBHtOvHUnJcwvjGQwMYbkCse7jx9N+eGX2Z9NQeXdmCRY/YEAOD40/iPsxXp gPeNdyz/c2FdrR/g7OdxkXr+XkPmXY2rFko1octdPRUs8SOzkwnB/BeKEK46c6BlteIt Lb5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sp/MzYND; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m62si4837003pgm.88.2018.03.16.02.52.16; Fri, 16 Mar 2018 02:52:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sp/MzYND; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751783AbeCPJvY (ORCPT + 99 others); Fri, 16 Mar 2018 05:51:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41500 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbeCPJvW (ORCPT ); Fri, 16 Mar 2018 05:51:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GXVLsvO9/z/6OSmGRjRJKG1TxDgWdvswWBs6zF2MvH0=; b=sp/MzYNDp6ibjpepQbe5JzC07 UiS4YinrgJzSZ95yCHpaV7l1YW2T7gmqtMHcWfuk1ER7ANkyLfPTEeE/bUu0VqzbNVTG4jCuKuvG1 gh8n6xU2fW86JoTxjNQKVq9tm3dZUZXZizns0gDw8qv2+CGACn0lH/wvuQozZsYmBdOtidZGpcnwE fF/z9nd0z+I9DnVxvvbUNdfrf1xWMv+r3kprqdqhtsmPvu9h2O9fZzf3vzG1G9oksHfat+GtvBvsm Or30hUGIS/yfMhFbnccv+f8d0n5Q/a5cuNCWM3L75AFfnw2h3t5CisOHLMBZrk9gXym3twU+CDcJH ZVqxqtRFQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewm15-00028H-Tm; Fri, 16 Mar 2018 09:51:16 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0BB1B2029F860; Fri, 16 Mar 2018 10:51:13 +0100 (CET) Date: Fri, 16 Mar 2018 10:51:13 +0100 From: Peter Zijlstra To: Kathleen Chang Cc: mingo@redhat.com, matthias.bgg@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Jonathan.JMChen@mediatek.com, wsd_upstream@mediatek.com, Matt Fleming Subject: Re: update vruntime incorrectly When use rt_mutex Message-ID: <20180316095113.GA4064@hirez.programming.kicks-ass.net> References: <1521099370.7712.4.camel@mtkswgap22> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1521099370.7712.4.camel@mtkswgap22> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 03:36:10PM +0800, Kathleen Chang wrote: > hi, > > We found the vruntime might update incorrectly when use rt_mutex. That's nice, on what kernel? Also, your email is very hard to make sense of. > <> > When the Task is waking, update vruntime incorrectly. > 1. When there is a CFS task (A) hold rt_mutex_lock and the state is > TASK_WAKING (on_rq=0), a RT task (B) want to hold this rt_mutex_lock. > Update vruntime incorrectly. > > RT task (B) > rt_mutex_setprio (cfs->RT) -> Task is waking , and update > vruntime > > queued = task_on_rq_queued(p); // task is waking, queued=0 > running = task_current(rq, p); > if (queued) /* don't update vruntime here! */ > dequeue_task(rq, p, queue_flag); > if (running) > put_prev_task(rq, p); > > check_class_changed(rq, p, prev_class, oldprio); -> > switched_from_fair -> > detach_task_cfs_rq > ( due to task is waking, and bypass > vruntime-=cfs_rq.min_vruntime) > > static void detach_task_cfs_rq(struct task_struct *p) > { > struct sched_entity *se = &p->se; > struct cfs_rq *cfs_rq = cfs_rq_of(se); > > if (!vruntime_normalized(p)) { // return 1, then p->state is > TASK_WAKING > /* > * Fix up our vruntime so that the current sleep doesn't > * cause 'unlimited' sleep bonus. > */ > place_entity(cfs_rq, se, 0); > check_vruntime(8, se, cfs_rq->min_vruntime); > se->vruntime -= cfs_rq->min_vruntime; So here we subtract min_vruntime, > se->normalized = true; this doesn't exist.. which makes me wonder what you're looking at, > } > > detach_entity_cfs_rq(se); > } > > // when p->state is TASK_WAKING, the task's vruntime is normalized > static inline bool vruntime_normalized(struct task_struct *p) > { > ..... > if (!se->sum_exec_runtime || p->state == TASK_WAKING) > return true; > > } > > 2. When the task (A) which holds the rt_muex_lock unlock the > rt_mutex_lock. > Task (A) must be on_rq=1 > > rt_mutex_setprio (RT->CFS) > if (queued) > enqueue_task(rq, p, queue_flag); ); > /* vruntime += cfs_rq.min_vruntime */ And here we're adding min_vruntime. > if (running) > set_curr_task(rq, p); > > that result in vruntime accumulates So what exactly is the problem?