Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1300368ybl; Wed, 18 Dec 2019 16:15:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwtAITl44Xwf6QumqFHTrhj9HbDKjthCCzs4eUFOSnBj4HjEtHY3TxLibwdxzfYRaQC+z5F X-Received: by 2002:a05:6830:1e5c:: with SMTP id e28mr5667919otj.293.1576714532495; Wed, 18 Dec 2019 16:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576714532; cv=none; d=google.com; s=arc-20160816; b=g+eUG4/7Qfy4VyeVCTvJzCXNKF+IZqg9Euy+fFr9MxNc1yXR6Moj4/7qoPC5SuUrJj SwtYXHBgxd+ZI2je4GEz27RcYXRBMpd8BJa8kjCEBIgFQrACyIuiwS6gmbQZOZoyIy5m 0LZa89P/OO+gGtx5SRcYu+WJ0RHHG9DZQflyJRT9SQV5/FIi8v38t1FCgcxbo8bo2PMz VPNuOJbLRon5G1pDkaA6TmAdcPHAF3he8aVRnCNAKg/sYokuCSYGEJpVjfaxTbXjh5pV DAeU9EN05T1u+WhVNdbxuOr7g1vyQ2VEHJEpQicDsgquH1urgHrW3R/V9jp2Z/Xrs2MG 1i0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=dtYJGhXvidGK6sDcgxIhyPPLb4WJNKOiIKfjLPl0mNY=; b=No0SHy609hvFse0sIHzEavltcDMwEPai/Tw4Lrngimg75o+JFqKr7NF5VyFTXkqepP DlRBGO8KNpe1/16Wqrjb9woRdyRSfD4QbZ25qGtVyaDRH4RJwoO9+YNV/r66/uk3VKk+ 8D9RcwITqMTAOo/8y6LkpHRoz6+SbqjpBVLf71kwKzMvORhwjxInLB5rejXQCGoS5WPc LOY6T6Ka+KCBrFGLHxciFlphJdaMx0hNYAOOWFCaae7H5JJA0YfdfgoO318Ys3T9v0D9 tAyVr7GwX7XpB6EC3njS8VyU2W9A6/hcty9KvZIHxV15GIZzEeWGpIsy04jE35OOTBOR 4OLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u1SOj+6Q; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si2373591otl.83.2019.12.18.16.15.21; Wed, 18 Dec 2019 16:15:32 -0800 (PST) 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=@google.com header.s=20161025 header.b=u1SOj+6Q; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbfLSAOV (ORCPT + 99 others); Wed, 18 Dec 2019 19:14:21 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:35354 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfLSAOV (ORCPT ); Wed, 18 Dec 2019 19:14:21 -0500 Received: by mail-pj1-f73.google.com with SMTP id l8so2174188pje.0 for ; Wed, 18 Dec 2019 16:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=dtYJGhXvidGK6sDcgxIhyPPLb4WJNKOiIKfjLPl0mNY=; b=u1SOj+6QXy3P3+I/a6pnKxQFl4cXlIVvppy9KcSbvMrci41+XkyOO9nhDVV3SfXH+2 F82sj9a0EAqRVy/qvV/wLyH5CIu0INQyIx4q83KGmNAlwdzBIV4Z8X+NcSGsdIfHDg68 WjGqWQz1Q+dF9AKR2seYRjCp1Rchj0kdKPTHJgYIGBrIaMWnUv9GIBG+eSn+CUEzxDkc aiSFz8me8cD0M1Ryh5bAt/H8TjWG4UP+MNXhPuM/dU4SUCO/f7fgnBTgA8rCGV1HKtP6 XOOzJi6CIFzZYrZd45wAiSPQVOohNPBM8ejWrSuIafIgRilYXtQmF/Wiykx/2diSm+TH fZ2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=dtYJGhXvidGK6sDcgxIhyPPLb4WJNKOiIKfjLPl0mNY=; b=ll7XpSx0R8zUKQtAtTMTHLkxjBxqAo2xhca1uriG67+AKYSVjoJ4ZiPD0Wt6am6+Em SYUc/osjTDs+N4fp2JgUKaE/vcL+/BoOSnv29um/oUperKP9TNrEdKOnYNjNciySvgOH mIbif9W9i195eievh3DgDNZhMizVJLg6zeH1hBRTq4fK+tkW/6cU0nRIvBiqWs1cR6Ly zAfpd4rzbSo7oV9tQ5G1PL+vezerHzj3KN24DKIUkHlknLhO9Fwtx9/49GQ5T15CtUAX A6eylWWJ0Q1pFnL1G7zj5jHNRZcGTPa6VNU/a6si05X7GqKJ0iTZ7dtkYa9x8eL33a+z aaPg== X-Gm-Message-State: APjAAAWU5XoqrQCFwgFdsH3rQPXF8xJD155CPgLrn2yUotc6AQU1yqxh YnvJTm/wfqj8exH2SLLsHjooBFd57+aQ X-Received: by 2002:a63:d848:: with SMTP id k8mr5011243pgj.114.1576714460207; Wed, 18 Dec 2019 16:14:20 -0800 (PST) Date: Wed, 18 Dec 2019 16:14:18 -0800 In-Reply-To: Message-Id: <20191219001418.234372-1-joshdon@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v3] sched/fair: Do not set skip buddy up the sched hierarchy From: Josh Don To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org, Paul Turner , Josh Don Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Venkatesh Pallipadi Setting the skip buddy up the hierarchy effectively means that a thread calling yield will also end up skipping the other tasks in its hierarchy as well. However, a yielding thread shouldn't end up causing this behavior on behalf of its entire hierarchy. For typical uses of yield, setting the skip buddy up the hierarchy is counter-productive, as that results in CPU being yielded to a task in some other cgroup. So, limit the skip effect only to the task requesting it. Co-developed-by: Josh Don Signed-off-by: Josh Don --- v2: Only clear skip buddy on the current cfs_rq v3: Modify comment describing the justification for this change. kernel/sched/fair.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 08a233e97a01..0056b57d52cb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4051,13 +4051,10 @@ static void __clear_buddies_next(struct sched_entity *se) static void __clear_buddies_skip(struct sched_entity *se) { - for_each_sched_entity(se) { - struct cfs_rq *cfs_rq = cfs_rq_of(se); - if (cfs_rq->skip != se) - break; + struct cfs_rq *cfs_rq = cfs_rq_of(se); + if (cfs_rq->skip == se) cfs_rq->skip = NULL; - } } static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se) @@ -6552,8 +6549,12 @@ static void set_next_buddy(struct sched_entity *se) static void set_skip_buddy(struct sched_entity *se) { - for_each_sched_entity(se) - cfs_rq_of(se)->skip = se; + /* + * Only set the skip buddy for the task requesting it. Setting the skip + * buddy up the hierarchy would result in skipping all other tasks in + * the hierarchy as well. + */ + cfs_rq_of(se)->skip = se; } /* -- 2.24.1.735.g03f4e72817-goog