Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp15563pxb; Fri, 15 Jan 2021 06:40:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5w/9Ty9TkJe/a1eMz/znEtdhuMuBqCOB0xuG3VKx8LR02vevh7gye5Pm5HSet42eEU2oi X-Received: by 2002:a17:906:3b11:: with SMTP id g17mr2813476ejf.473.1610721654357; Fri, 15 Jan 2021 06:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610721654; cv=none; d=google.com; s=arc-20160816; b=sMbDMR7dOH6EQ556aVnBLj6t5e7CXimQJWisI7IhpkHU4s4SI2eZkFO1BNgSHoQ0WO TYNNjD1R6ViTseHuu2ty5r50dMSdV9eBo/KO1gpJDTIe0Nl6nJKjCt3FG5jLOiC80JaE P0H3p8OSXLNDmUMIjaP77B1zbXr5WSNCXqadm4SSXCB4RNiLWFfdC9a09tG7VRZWWva1 s3IMJXHKioE7JGBBSfPgjp2nzlT96Q82G2YRQvrXcJryXblOJHvUfW+b/C9wFFTzJD+o ktFbwfheZyK7GYIy58eRAa5DaB2rmorNfRK6x2ypiGjD3hvJq26aCLikXTOy8qIzA/Rv Kdpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=78eSQV8ENF+jcNM9LgkNRQPY5bxIiUw35uMKrEAGvdk=; b=sNvROLovKGC9euCWbg2NRE9TMgcOyzVCSNi2E31bkqgH8nt3qWqV4IatX3nKw4WrU7 2JjrJ6KqgBLZLbI0O3/TN5imJWLjsayChsjyfLT8ewNO1cJt0LDHjw8eKJa5DM4k05u+ wfn3mQfqJzvxxXdOhy1FScRbniZVAwXKEw18+EAt72AYxqlPQWGTzNks1xQ7/j/C/b+5 ZqDtASOYkW2chcUvoCwKYeV9i3uxHAJDwiy0fK0xPmd0PY5pivvUlSllgG4Wu4r7nU6T S1JHvSlBEqgH1K7t5+TubOFSDXQQoUCGAu2SJCoW5RFFS03uuON40+Yexlgn0sxfyR7h 9tgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn23si3920756edb.27.2021.01.15.06.40.29; Fri, 15 Jan 2021 06:40:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730764AbhAOOhY (ORCPT + 99 others); Fri, 15 Jan 2021 09:37:24 -0500 Received: from foss.arm.com ([217.140.110.172]:41974 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728974AbhAOOhX (ORCPT ); Fri, 15 Jan 2021 09:37:23 -0500 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 A9254ED1; Fri, 15 Jan 2021 06:36:37 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B801B3F70D; Fri, 15 Jan 2021 06:36:34 -0800 (PST) Subject: Re: [PATCH 6/6] sched/deadline: Fixes cpu/rd/dl_bw references for suspended tasks To: Daniel Bristot de Oliveira , linux-kernel@vger.kernel.org Cc: Marco Perronet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Li Zefan , Tejun Heo , Johannes Weiner , Valentin Schneider , cgroups@vger.kernel.org References: <8c1cb0c850e2f3ab1d7a533aa4b33a30f9dbeda5.1610463999.git.bristot@redhat.com> From: Dietmar Eggemann Message-ID: <97875017-a6bb-98ea-83f9-82e95db58aca@arm.com> Date: Fri, 15 Jan 2021 15:36:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8c1cb0c850e2f3ab1d7a533aa4b33a30f9dbeda5.1610463999.git.bristot@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/01/2021 16:53, Daniel Bristot de Oliveira wrote: [...] > ----- %< ----- > #!/bin/bash > # Enter on the cgroup directory > cd /sys/fs/cgroup/ > > # Check it if is cgroup v2 and enable cpuset > if [ -e cgroup.subtree_control ]; then > # Enable cpuset controller on cgroup v2 > echo +cpuset > cgroup.subtree_control > fi > > echo LOG: create an exclusive cpuset and assigned the CPU 0 to it > # Create cpuset groups > rmdir dl-group &> /dev/null > mkdir dl-group > > # Restrict the task to the CPU 0 > echo 0 > dl-group/cpuset.mems > echo 0 > dl-group/cpuset.cpus > echo root > dl-group/cpuset.cpus.partition > > echo LOG: dispatching a regular task > sleep 100 & > CPUSET_PID="$!" > > # let it settle down > sleep 1 > > # Assign the second task to the cgroup There is only one task 'CPUSET_PID' involved here? > echo LOG: moving the second DL task to the cpuset > echo "$CPUSET_PID" > dl-group/cgroup.procs 2> /dev/null > > CPUSET_ALLOWED=`cat /proc/$CPUSET_PID/status | grep Cpus_allowed_list | awk '{print $2}'` > > chrt -p -d --sched-period 1000000000 --sched-runtime 100000000 0 $CPUSET_PID > ACCEPTED=$? > > if [ $ACCEPTED == 0 ]; then > echo PASS: the task became DL > else > echo FAIL: the task was rejected as DL > fi [...] > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 5961a97541c2..3c2775e6869f 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -5905,15 +5905,15 @@ static int __sched_setscheduler(struct task_struct *p, > #ifdef CONFIG_SMP > if (dl_bandwidth_enabled() && dl_policy(policy) && > !(attr->sched_flags & SCHED_FLAG_SUGOV)) { > - cpumask_t *span = rq->rd->span; > + struct root_domain *rd = dl_task_rd(p); > > /* > * Don't allow tasks with an affinity mask smaller than > * the entire root_domain to become SCHED_DEADLINE. We > * will also fail if there's no bandwidth available. > */ > - if (!cpumask_subset(span, p->cpus_ptr) || > - rq->rd->dl_bw.bw == 0) { > + if (!cpumask_subset(rd->span, p->cpus_ptr) || > + rd->dl_bw.bw == 0) { > retval = -EPERM; > goto unlock; > } > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index c221e14d5b86..1f6264cb8867 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -2678,8 +2678,8 @@ int sched_dl_overflow(struct task_struct *p, int policy, > u64 period = attr->sched_period ?: attr->sched_deadline; > u64 runtime = attr->sched_runtime; > u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0; > - int cpus, err = -1, cpu = task_cpu(p); > - struct dl_bw *dl_b = dl_bw_of(cpu); > + int cpus, err = -1, cpu = dl_task_cpu(p); > + struct dl_bw *dl_b = dl_task_root_bw(p); > unsigned long cap; > > if (attr->sched_flags & SCHED_FLAG_SUGOV) > Wouldn't it be sufficient to just introduce dl_task_cpu() and use the correct cpu to get rd->span or struct dl_bw in __sched_setscheduler() -> sched_dl_overflow()? diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5961a97541c2..0573f676696a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5905,7 +5905,8 @@ static int __sched_setscheduler(struct task_struct *p, #ifdef CONFIG_SMP if (dl_bandwidth_enabled() && dl_policy(policy) && !(attr->sched_flags & SCHED_FLAG_SUGOV)) { - cpumask_t *span = rq->rd->span; + int cpu = dl_task_cpu(p); + cpumask_t *span = cpu_rq(cpu)->rd->span; /* * Don't allow tasks with an affinity mask smaller than diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index c221e14d5b86..308ecaaf3d28 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2678,7 +2678,7 @@ int sched_dl_overflow(struct task_struct *p, int policy, u64 period = attr->sched_period ?: attr->sched_deadline; u64 runtime = attr->sched_runtime; u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0; - int cpus, err = -1, cpu = task_cpu(p); + int cpus, err = -1, cpu = dl_task_cpu(p); struct dl_bw *dl_b = dl_bw_of(cpu); unsigned long cap;