Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp351190rwi; Thu, 27 Oct 2022 02:02:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5pNHX+oR9BlBbz+FKnO0gQG6T9jAfZXWZjmbZpi8x/I8P6XICoGM4P6MIzmlsbPgpiaU/e X-Received: by 2002:a05:6402:550e:b0:456:f79f:2bed with SMTP id fi14-20020a056402550e00b00456f79f2bedmr45349358edb.106.1666861337726; Thu, 27 Oct 2022 02:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666861337; cv=none; d=google.com; s=arc-20160816; b=kSzOLeBUOsw7iKjqY3n49wzIXhl5wH6zgypI0QgPreDmJLpS5Hxdi9KwpFIpuwttti t3mAbxXWxFzX+7OO2SjBrdFGM3gIw0KYI0usOi0kzR8AZVMntjUE9a7K75vF0hTOjPfs cLJN8papLXHVN5lsjkdD2ZXPYi4PpoOYFR9Mp1ELadQONInH1ljt5nSndqHNvs7pWg7O gWxJ4oLvrzI/WYqCsxE1u6TUAr6DsyS0qz7jLMybRCw3qwI9xjU9wPvwWPXPH5uZEUn3 XBrgW0/fndypVCVrvg5h/CtoRClz+MLX0d0WLRgTZk3mR/X+Ow4Fmn/akfTc7fTuEx4g 8FKA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r20-20020a05640251d400b004625f4e0289si1194182edd.615.2022.10.27.02.01.52; Thu, 27 Oct 2022 02:02:17 -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 Content-Transfer-Encoding: 8bit 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 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 -- 2.20.1