From patchwork Thu Oct 27 08:16:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuyi Zhou X-Patchwork-Id: 11641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp101771wru; Thu, 27 Oct 2022 01:26:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LtzSDohiQMUORwiDu+JfJL524hLi70qaTQVdMapMM3dZ1gxODVoEOUF1B+/meiN0NihST X-Received: by 2002:a17:906:cc49:b0:7ad:93d1:5eaf with SMTP id mm9-20020a170906cc4900b007ad93d15eafmr318947ejb.393.1666859200445; Thu, 27 Oct 2022 01:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859200; cv=none; d=google.com; s=arc-20160816; b=D53ANMOx+NnXdhyhK9LCPsM9TRKr3axQjz6E6kvzvxLO5SQ/fV2MSzUIG5EJYk0Nwn /j35k+7iWwDyI5DY3bZjxUpF7DnWza24ObSbK17AVgjsgUNHu5bHWsAMvRT/htQI8i0d MTUrQscH9JtHp+KZt3Y+cXWCDExhHDaF+LmqHw7CsXr8CmilvDZf0h3JAMHVyZCJjYzM U+Qmf7Fs2+Q+VTpyU3I4uh63WX7wEVgrCe2Z5M84B+u5MP7E98aXtvI8X9A5ut2/6VpJ ndcP9L4NW3OZZKqXEx4GbdUINdOn20yTomFTFSDAKB86M80LX3F3josdizw0X+uY1xPv qO9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kGQVxG2SU95XA9M7f0IhXRn42lf+Qr3tm/YzKnG6hUc=; b=dEriVArmjzQ4sqVIURa7UD5G9eUm/CEJZPnc9FAQoTe52b0ouveeOd/aeldSaUogQ3 pE0mbeWZSwawc/7Yk7Ms0gNYhsrLQX0qv5HjQKaP+/L2iyITEICNmbBA8ddcQjSCaqZ2 m4E/41Phat41dT9CtbHke8ywntMa6Htvu89m/8tSEfqDmaSkK9oVvx9pBvFcJrawrxSe G9preBR5m0vaBMNx8xoGUbTqPNS3cPSWMu/HDZo23FiEZrG5w/awd+2P0kECCkFNHq39 GAgO671rSHQdPWr2mSlyb7bfwMXSKlkFrNVMFI8nyAfiiHbzOqgVXIrbl6yKqDtKdS8p c2uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aiJWnRGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a50fe08000000b00461f7a83e58si967829edt.46.2022.10.27.01.26.13; Thu, 27 Oct 2022 01:26:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aiJWnRGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234677AbiJ0IQo (ORCPT + 99 others); Thu, 27 Oct 2022 04:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233187AbiJ0IQm (ORCPT ); Thu, 27 Oct 2022 04:16:42 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFEC31F9C for ; Thu, 27 Oct 2022 01:16:40 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id n7so698577plp.1 for ; Thu, 27 Oct 2022 01:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kGQVxG2SU95XA9M7f0IhXRn42lf+Qr3tm/YzKnG6hUc=; b=aiJWnRGbv2p+GLTzTdckX1EybobOwf4N9yfGhVZmM3o/rzjeyHxSQ8OfCCf2MlOb7Y ep1xtYsiIPSdK7nOW+W+JK4EQ5uhmxcXT7TblAfNN8oouZzqH8pvyCNNQhNolPM0yiZ9 dqs3zMSoYB2hREDOFY5362dSTEBUsPcVAInkLe0PVnDz5JuGPLFvvmz7/gHDL+FRg9hi ErOZVE2XSjZx1BBpWJ+/nKCC6b5GohK28UbcbsffW0Qub85pGDEzji8Cx6OjvD/Am6kf ZqYaIbr/yzPxIAW53LtbdPmHJMjI7b3jPFBLSDHbPfLwhNERCU1gnrVmPwy5fVB/M6Uy sJPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kGQVxG2SU95XA9M7f0IhXRn42lf+Qr3tm/YzKnG6hUc=; b=X4mx0Ov+CrWeE+wsqnII4KgfhnJ2/cwo3ehOiFkzZ+TqfugIQXEiZqyNmrFLs4xEOV hnsC1PY13JJAo0GoroZyZNSYND14XAOswizI7jzBO0N49AEt1mQknmkjND5NkcttIkH4 uCkn0yZ+NUQ3xoXF9RnSeCC2MQgoybXJob2v87zIkRFoU4lW7Y4r5A2MZa8p6Y3QtVIV YUuNJhK+LgTWa5zEZiO632mPHH3+CUz1Sp1TrZwUvsQqon6PRiLOjC0NEkfZ1+eqYaSJ EOyvbWctCwVB0VquoRB9/2cjBEZbcraCFv8kVdkGwWKBcjEGWbAuPrqmg+jU8B1BsBF1 oaAA== X-Gm-Message-State: ACrzQf1rO7eooaqQMljGjYxuRYm9+y4H6HvuRph5C9AyWgGNRv8GPF1s JyyF9W+mpcXJwAcEjLS2RtGowQ== X-Received: by 2002:a17:902:e5c6:b0:185:4bbd:17ce with SMTP id u6-20020a170902e5c600b001854bbd17cemr49174140plf.132.1666858600265; Thu, 27 Oct 2022 01:16:40 -0700 (PDT) Received: from YGFVJ29LDD.bytedance.net ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id w72-20020a62824b000000b00560e5da42d5sm632972pfd.201.2022.10.27.01.16.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Oct 2022 01:16:39 -0700 (PDT) From: Chuyi Zhou To: peterz@infradead.org, juri.lelli@redhat.com, mingo@redhat.com, vincent.guittot@linaro.org Cc: linux-kernel@vger.kernel.org, joshdon@google.com, Chuyi Zhou Subject: [PATCH] sched/fair: favor non-idle group in tick preemption Date: Thu, 27 Oct 2022 16:16:30 +0800 Message-Id: <20221027081630.34081-1-zhouchuyi@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747828552590964893?= X-GMAIL-MSGID: =?utf-8?q?1747828552590964893?= The non-idle se dominates competition vs the idle se when they are belong to the same group. We ensure that idle groups would not preempt non-idle group in wakeup preemption(see check_preempt_wakeup()). However, this can happen in tick preemption, since check_preempt_tick() dose not check current/se is idle or not. This patch adds this check. Signed-off-by: Chuyi Zhou --- kernel/sched/fair.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e4a0b8bd941c..f3324b8753b3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4750,6 +4750,7 @@ static void check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) { unsigned long ideal_runtime, delta_exec; + int cse_is_idle, pse_is_idle; struct sched_entity *se; s64 delta; @@ -4779,8 +4780,17 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) if (delta < 0) return; - if (delta > ideal_runtime) + if (delta > ideal_runtime) { + /* + * Favor non-idle group even in tick preemption + */ + cse_is_idle = se_is_idle(curr); + pse_is_idle = se_is_idle(se); + if (unlikely(!cse_is_idle && pse_is_idle)) + return; + resched_curr(rq_of(cfs_rq)); + } } static void