Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp611684ybh; Wed, 11 Mar 2020 07:25:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsHOE38LlfHc/JlLXcoh+unr+HjqcVGsnxDNUVFmyj5AlZuqW8eREp0E7dplnOPmXU43UMV X-Received: by 2002:a9d:4e94:: with SMTP id v20mr2477750otk.96.1583936742191; Wed, 11 Mar 2020 07:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583936742; cv=none; d=google.com; s=arc-20160816; b=t3j7/KbQum7rNZShSx25/4k1CUkHAC7FrNctEI62572dJsI6wsHCV8MQpn1Y5SqGsw mekxFdqMZhZ8ZFnwflCOZJXNvksfbZvgY3BYvESvxnOHz30PAKkI3fHVyD+DTYqUlD8A eWjqXjGYYkkIdLa/nRAbeHGuK14aa2Woa9rKwUmgVQkzAS0YggbinyfB7MFOuX6KcxZF 9Ne5KarT98vaZ7kjudo3aYnvFMSJmeIOJuwWAVDZo1jq7RC7rfb8dgPgfE9ntAtWUPcx dD/bzKlnNihYUMCQfS0r/zKgn96UIKSuPoTtduntAxQhFkxYBTCt21rB+G5lc5EM19t1 PKiA== 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; bh=0arugCSCxBQ4bYe3Aso1n7rKlkU2Ma6cO2+iE8G6PXU=; b=oWWcBihEwm29+gYE8gZz9tz2e6BbGixmTkkw3C0mG4/LaFdrTKZdOYCXfPw/mwU5Ry 8LxGhYqEgi/TQijHi8jIh/wr5GLYMDYkLdZpIQo5fYXpYWyropWI77X/xak8BLy4vjKi 8KZZfvMevMfjIFd56midmVTDIUvFWmvl6pS50GGchZcai1qpWbb7Cu0I04X6u0tDpVl8 z2wXpm8+CnTzHRcdpOeOQ7ww1nPcG48rd78aAuS8PRPtkHnatrepIQkX8oYeT25RkNaa 1WgYkDf/1tpwFlUazin+KZS/1GJFegDkCs0kGeODt6Zm+E+Ne//TiCbcmjGA7647E6ZK gTDw== ARC-Authentication-Results: i=1; mx.google.com; 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 l25si1203855otq.76.2020.03.11.07.25.21; Wed, 11 Mar 2020 07:25:42 -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; 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 S1729783AbgCKOX0 (ORCPT + 99 others); Wed, 11 Mar 2020 10:23:26 -0400 Received: from foss.arm.com ([217.140.110.172]:50334 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729531AbgCKOX0 (ORCPT ); Wed, 11 Mar 2020 10:23:26 -0400 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 993B831B; Wed, 11 Mar 2020 07:23:25 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B3013F67D; Wed, 11 Mar 2020 07:23:24 -0700 (PDT) Date: Wed, 11 Mar 2020 14:23:21 +0000 From: Qais Yousef To: Steven Rostedt Cc: Ingo Molnar , Peter Zijlstra , Dietmar Eggemann , Pavan Kondeti , Juri Lelli , Vincent Guittot , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 6/6] sched/rt: Fix pushing unfit tasks to a better CPU Message-ID: <20200311142321.3zfyoemzvheo4omt@e107158-lin.cambridge.arm.com> References: <20200302132721.8353-1-qais.yousef@arm.com> <20200302132721.8353-7-qais.yousef@arm.com> <20200311100020.63bb81e5@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200311100020.63bb81e5@gandalf.local.home> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/11/20 10:00, Steven Rostedt wrote: > On Mon, 2 Mar 2020 13:27:21 +0000 > Qais Yousef wrote: > > > + * Don't bother moving it if the destination CPU is > > + * not running a lower priority task. > > + */ > > + if (p->prio < cpu_rq(target)->rt.highest_prio.curr) { > > + > > + cpu = target; > > + > > + } else if (p->prio == cpu_rq(target)->rt.highest_prio.curr) { > > + > > + /* > > + * If the priority is the same and the new CPU > > + * is a better fit, then move, otherwise don't > > + * bother here either. > > + */ > > + if (fit_target) > > + cpu = target; > > + } > > BTW, A little better algorithm would be to test fit_target first: > > target_prio = cpu_rq(target)->rt.hightest_prio.curr; > if (p->prio < target_prio) { > cpu = target; > > } else if (fit_target && p->prio == target_prio) { > cpu = target; > } > > Which can also just be a single if statement: > > if (p->prio < target_prio || > (fit_target && p->prio == target_prio) > cpu = target; Indeed. We might have a better fix now if [1] goes in. It'd fix the 'thundering herd' issue I mentioned before. cpumask_any_and_distribute() should teach find_lowest_rq() to distribute tasks that wakeup at the same time better. Hence fix the need to do the above. It won't be bullet proof still, but neither the above is. I'm sure there will be other places that can benefit from this distribution function too. Thanks! -- Qais Yousef [1] https://lore.kernel.org/lkml/20200311010113.136465-1-joshdon@google.com/