Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp857446ybl; Wed, 4 Dec 2019 12:07:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwmCi78SZLRpKSnARgZGcAECn0R+hzMtV+F4h85iJ/lbOS9LlktFxSPJuQD5etT8YNArDmt X-Received: by 2002:aca:530e:: with SMTP id h14mr3861417oib.105.1575490061449; Wed, 04 Dec 2019 12:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575490061; cv=none; d=google.com; s=arc-20160816; b=ELL2BFsKZEjHYGt4wEvjSryXQ/Y93yO4EkUzw9UNIKSAZwj+KR5PgAGHy8OtPaqn/O oha6uzucG9xttD55QbWig3UBRuXp5e8owGjCZVKWt4t4f+FE7ebNF/vubKWo0c9sLCH3 Cf5xyAIv+IDUb4soHoNVKZXH6AMWCp/z5agHvy4iZlduCe60PvSJ5m8xnJozYGg2mms0 C1NrD47NyZCxRxaL3u4TezCThlLaEeR17FQ6wPP5g488InoeQLJsUdcEUS6ZtTDtRNhM rsH/ACX7mYk7NdOvT3hMbSDEAAPqyHSuIPn7sRNu5/3QR+gCPDcmhtjbi9KQrBPldA9i 7lOw== 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:mime-version :message-id:date:dkim-signature; bh=QzM8spuJP55zBSfgdmyKlFzKEKfzJw6hEQjs+FiEARs=; b=Fg7M1JLpEQSixW777zpZf8jsGbCuIazt21vWI0UYCqoFtvpkePQwSnkaUV608ENgoH 60vs7HdJ6Nj8XWB6NhuxBnxFoxgbwReiNXx4TLLBCea7YuQRU2cFcQVEqOrLwJTBW5mE SMRKPlWU5RsF9z2sG1sElWWAoh2/hW35xrtg2ZFIsT39ew/R+sxv8/nCl576xoyCgNc7 on2YxokzFXwUzlBwvIo5TUQUPmiO9HWhc8k0PUomL8n1gNyiMQCvFTt9HFwfyscnQODN ZHf/aEmUhAog+UO74A6dzQy+i1H5Oz4+EoORTIIG48hC74PHGvwSwq2fpA9yiRT203vO rU/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=f8PPQms6; 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 g205si3810149oif.178.2019.12.04.12.07.29; Wed, 04 Dec 2019 12:07:41 -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=f8PPQms6; 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 S1728208AbfLDUG1 (ORCPT + 99 others); Wed, 4 Dec 2019 15:06:27 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:52582 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbfLDUG0 (ORCPT ); Wed, 4 Dec 2019 15:06:26 -0500 Received: by mail-pl1-f201.google.com with SMTP id 62so226234ple.19 for ; Wed, 04 Dec 2019 12:06:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=QzM8spuJP55zBSfgdmyKlFzKEKfzJw6hEQjs+FiEARs=; b=f8PPQms6ztUtNN8+vwDa0hg9YM/544F+rXr57NSMtsxTkTRYGzbdtW0nZLJLQRiidW 9CLw40Ioej6sM03bvaPfw9bJmS1ZiEUiE+vwW4/26BVx0tFPJknaJYZ9mgRjxdSqmOPh /LE7Wjwv4SBw+Wcw4y8IJZfKgVw5dh3xV5f9xLHRbFrl6mB2KNovOxr/WPVyltK2pzBb jdNT6Ed/RZv7oTl5eToxzwRQsG8p4rlHJUyXGcilQQgfKseDrrqosw50fav1RTQzImFG jRb9QoqvvmFhwp45D4k1nG/+siywYMY9qxqQxy3kJdGZXtI0kx7XDPsgOND434e/UB7f HiJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=QzM8spuJP55zBSfgdmyKlFzKEKfzJw6hEQjs+FiEARs=; b=brearM+eFCWY2DMoRRmu1DxOnvACH46Fnb+/zY0/gvGirGhTJby7p2WCMyPne2N1S6 J5mEEYNMmxbgeD1LtP5Z2NLUAGNCxMofFQT1a8XA5yEsYynG0vVeHmoBCr5/40vGt4xy P/C6innVwDueCjWe1eeGiU6T0umNbCIaWOav3c8/9f05bNF0Rg09mtE6ZRtUqAmLcFsa XKewXVTMHmTE+N3b+AbFIyn0802XDOTObs0eZUcENJ96ygJLYl2tco4/PHD6f9hfHYZ5 jo4naa3svHaE0XWQ3j1kNjSdfKIiF6+g1xhhjBz2OKgSy4doBy0vYpPFfB1LIagjON8O 2SzA== X-Gm-Message-State: APjAAAXLpVwrQ7wLjfn6nxaZeETyFoU3g5dkblajWBbjKKKJ17cPyDcT uz8BL1OJPiWxk/Mfvj2O6zI+OF8f/XoS X-Received: by 2002:a65:6095:: with SMTP id t21mr5151518pgu.97.1575489985794; Wed, 04 Dec 2019 12:06:25 -0800 (PST) Date: Wed, 4 Dec 2019 12:06:23 -0800 Message-Id: <20191204200623.198897-1-joshdon@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog Subject: [PATCH v2] 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 skip buddy all the way up the hierarchy does not play well with intra-cgroup yield. One typical usecase of yield is when a thread in a cgroup wants to yield CPU to another thread within the same cgroup. For such a case, setting the skip buddy all the way 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. Signed-off-by: Josh Don --- v2: Only clear skip buddy on the current cfs_rq kernel/sched/fair.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 08a233e97a01..0b7a1958ad52 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,15 @@ 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; + /* + * One typical usecase of yield is when a thread in a cgroup + * wants to yield CPU to another thread within the same cgroup. + * For such a case, setting the skip buddy all the way up the + * hierarchy is counter-productive, as that results in CPU being + * yielded to a task in some other cgroup. So, only set skip + * for the task requesting it. + */ + cfs_rq_of(se)->skip = se; } /* -- 2.24.0.393.g34dc348eaf-goog