Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1467291imm; Fri, 7 Sep 2018 00:18:03 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZc6uyZkw6NSPbQRuswZkuN/8zxK5OOrWoTpgo/ovDOEA6I9Cb+Gjx+CzYwMYOwXDAXW1Hr X-Received: by 2002:a63:4909:: with SMTP id w9-v6mr6709773pga.123.1536304683354; Fri, 07 Sep 2018 00:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536304683; cv=none; d=google.com; s=arc-20160816; b=FbUItswMHLb0Laly/QqRDQ2v/eRdtwnNAgPSJNyF4D+meACPbS97oKWOi3Sit6Vg5z j6Js/bgrz3RlilA+U6iWF9/l7kqJc1XfH1Wwv0bip5Lg3UKffEaRHoY50oXWoZu3KJci ORItRy/sMCmSLiT2B9OWJfvQObg/Z706LC95Au4M7UPNL1Jqh3TcCn9Yi6IaOAtFEfES tFbg8b9Ixp0SZhHd6lYNDFWJh15JuW3q15ZW2cvjbgJg4IRBt/vK7PPABIeRI+/6AS63 RuRpWtqP8vZd4FuHdB2gXRfMuzNumJY/A/nZdDn09uxVQTKd6Y1YupKjVxNjKweIWPGo Uxwg== 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; bh=WAcTWorLVziaKbF69W7ubAgfrLu6JqXMDUbsCTpCx+U=; b=dnCagWkj/SATgrc+7uuTngwDLPNouN5/PiDsScCcdomw+I8BWZP24tcWyCTgBugJIj oLAJQmvLjg0LKVW+qrq4TOe0RrecvitSH73EJZMwr5dorESwPXQgZcVIKhpIIFDVOL9m OnbcE0J9h1ULTVOvNEE9KvEyCUYuE039a+iyIcz9n+0pADXnJ9CXmQjauNbqVaCh032P oRgqpFzg9xlTQ28+apvPmH4vfqqLdCNDL9MvZ4RXlqcLKEfZNnpTKszMMzPkjg0G18Jp 4BT7tMDEtjwJb/1LynMiqi8CA5CKG3o8vGe2pdpNInjMp3E0a+fYiwpeEfrclhAjyIfn Q+bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sruWDCwl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj4-v6si6945940plb.119.2018.09.07.00.17.47; Fri, 07 Sep 2018 00:18:03 -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=pass header.i=@gmail.com header.s=20161025 header.b=sruWDCwl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbeIGLzk (ORCPT + 99 others); Fri, 7 Sep 2018 07:55:40 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37679 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbeIGLzk (ORCPT ); Fri, 7 Sep 2018 07:55:40 -0400 Received: by mail-wr1-f66.google.com with SMTP id u12-v6so13819825wrr.4 for ; Fri, 07 Sep 2018 00:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WAcTWorLVziaKbF69W7ubAgfrLu6JqXMDUbsCTpCx+U=; b=sruWDCwl8SNWfJbPx2DqpmhqFNpwHq5rZzrDx1ClSQ3rbqOfkEM89WX6JiXUwzPlDw gfkrakND3w+duqFrGd9sPgv9/52ujQFWh+iWk2idxixEghNGTnbdaJ3BHXBTsON3oZsg 0DzAUmJ/CUNOFiEVUhA8XtRNyJ4x+xhKbUsXgwX1klhCzS5h66UBF8UZFPrY+iK5oxtc 4Cz2y69EZEl5K4CcnezC1BLqIj40CBV0hataR7Bfu26K1J3Y192LSk7j+Nh5btCE8ed6 pfbBtdHhygleo8HDHp27SpF6RK8A2gleWYU2BuKemsGg2h1DxYYG0VfdYXfwhiAzCvOP Su9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WAcTWorLVziaKbF69W7ubAgfrLu6JqXMDUbsCTpCx+U=; b=iF5fFfiE/TB2Z9oIhVZpnlx/95A9+oq15GzbPr+RfI5bmfoGRD6MTTxTkv5oaWVjOx ulgdSc9aJ0cyzrpnfhxyM4GZTgY+ClZYX6AEtqY3Ubykdp3wUXUXtiN0Gp+loWAFLajj jS++wD7AhOPeHM2MvrsLtoCeIUc1nIhvsay0L5eeR8OnhzwO1HARt8Ig2USngkQeWips ibqsTH8Rwc2pjZHE7fP+AkEBbRo5T+wbymNjOVm++gcinbXH09ij54jjBUEVKqT/LXIu tYks+6Hz9Wv8+zRCFjH/uZhVCtswXcx54kQTZVQ3VhO3V8SJcfS2ufs7Bb3WDlvinWjF H6Ng== X-Gm-Message-State: APzg51AHw3ZSHKXW2/gOvUtUVmM+6HysAi12arWKBhfz4GECXyO/kQc1 pWntrArWUYa6+rypqOpgza4= X-Received: by 2002:a5d:418c:: with SMTP id m12-v6mr4955713wrp.8.1536304565639; Fri, 07 Sep 2018 00:16:05 -0700 (PDT) Received: from localhost.localdomain ([151.15.227.30]) by smtp.gmail.com with ESMTPSA id n11-v6sm7925882wra.26.2018.09.07.00.16.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Sep 2018 00:16:04 -0700 (PDT) Date: Fri, 7 Sep 2018 09:16:02 +0200 From: Juri Lelli To: Dietmar Eggemann Cc: Miguel de Dios , Steve Muckle , Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, kernel-team@android.com, Todd Kjos , Paul Turner , Quentin Perret , Patrick Bellasi , Chris Redpath , Morten Rasmussen , John Dias Subject: Re: [PATCH] sched/fair: vruntime should normalize when switching from fair Message-ID: <20180907071602.GA29405@localhost.localdomain> References: <20180817182728.76129-1-smuckle@google.com> <20180824065419.GB24860@localhost.localdomain> <5fa77995-428e-077e-e236-7cc4a2e82577@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5fa77995-428e-077e-e236-7cc4a2e82577@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/09/18 16:25, Dietmar Eggemann wrote: > Hi Juri, > > On 08/23/2018 11:54 PM, Juri Lelli wrote: > > On 23/08/18 18:52, Dietmar Eggemann wrote: > > > Hi, > > > > > > On 08/21/2018 01:54 AM, Miguel de Dios wrote: > > > > On 08/17/2018 11:27 AM, Steve Muckle wrote: > > > > > From: John Dias > > [...] > > > > > > > I tried to catch this issue on my Arm64 Juno board using pi_test (and a > > > slightly adapted pip_test (usleep_val = 1500 and keep low as cfs)) from > > > rt-tests but wasn't able to do so. > > > > > > # pi_stress --inversions=1 --duration=1 --groups=1 --sched id=low,policy=cfs > > > > > > Starting PI Stress Test > > > Number of thread groups: 1 > > > Duration of test run: 1 seconds > > > Number of inversions per group: 1 > > > Admin thread SCHED_FIFO priority 4 > > > 1 groups of 3 threads will be created > > > High thread SCHED_FIFO priority 3 > > > Med thread SCHED_FIFO priority 2 > > > Low thread SCHED_OTHER nice 0 > > > > > > # ./pip_stress > > > > > > In both cases, the cfs task entering rt_mutex_setprio() is queued, so > > > dequeue_task_fair()->dequeue_entity(), which subtracts cfs_rq->min_vruntime > > > from se->vruntime, is called on it before it gets the rt prio. > > > > > > Maybe it requires a very specific use of the pthread library to provoke this > > > issue by making sure that the cfs tasks really blocks/sleeps? > > > > Maybe one could play with rt-app to recreate such specific use case? > > > > https://github.com/scheduler-tools/rt-app/blob/master/doc/tutorial.txt#L459 > > I played a little bit with rt-app on hikey960 to re-create Steve's test > program. Oh, nice! Thanks for sharing what you have got. > Since there is no semaphore support (sem_wait(), sem_post()) I used > condition variables (wait: pthread_cond_wait() , signal: > pthread_cond_signal()). It's not really the same since this is stateless but > sleeps before the signals help to maintain the state in this easy example. > > This provokes the vruntime issue e.g. for cpus 0,4 and it doesn't for 0,1: > > > "global": { > "calibration" : 130, > "pi_enabled" : true > }, > "tasks": { > "rt_task": { > "loop" : 100, > "policy" : "SCHED_FIFO", > "cpus" : [0], > > "lock" : "b_mutex", > "wait" : { "ref" : "b_cond", "mutex" : "b_mutex" }, > "unlock" : "b_mutex", > "sleep" : 3000, > "lock1" : "a_mutex", > "signal" : "a_cond", > "unlock1" : "a_mutex", > "lock2" : "pi-mutex", > "unlock2" : "pi-mutex" > }, > "cfs_task": { > "loop" : 100, > "policy" : "SCHED_OTHER", > "cpus" : [4], > > "lock" : "pi-mutex", > "sleep" : 3000, > "lock1" : "b_mutex", > "signal" : "b_cond", > "unlock" : "b_mutex", > "lock2" : "a_mutex", > "wait" : { "ref" : "a_cond", "mutex" : "a_mutex" }, > "unlock1" : "a_mutex", > "unlock2" : "pi-mutex" > } > } > } > > Adding semaphores is possible but rt-app has no easy way to initialize > individual objects, e.g. sem_init(..., value). The only way I see is via the > global section, like "pi_enabled". But then, this is true for all objects of > this kind (in this case mutexes)? Right, global section should work fine. Why do you think this is a problem/limitation? > So the following couple of lines extension to rt-app works because both > semaphores can be initialized to 0: > > { > "global": { > "calibration" : 130, > "pi_enabled" : true > }, > "tasks": { > "rt_task": { > "loop" : 100, > "policy" : "SCHED_FIFO", > "cpus" : [0], > > "sem_wait" : "b_sem", > "sleep" : 1000, > "sem_post" : "a_sem", > > "lock" : "pi-mutex", > "unlock" : "pi-mutex" > }, > "cfs_task": { > "loop" : 100, > "policy" : "SCHED_OTHER", > "cpus" : [4], > > "lock" : "pi-mutex", > "sleep" : 1000, > "sem_post" : "b_sem", > "sem_wait" : "a_sem", > "unlock" : "pi-mutex" > } > } > } > > Any thoughts on that? I can see something like this as infrastructure to > create a regression test case based on rt-app and standard ftrace. Agree. I guess we should add your first example to the repo (you'd be very welcome to create a PR) already and then work to support the second?