Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1775514rwi; Wed, 19 Oct 2022 15:26:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Bb1qooJCE6k+CQ5NDqBXiYzZxqf2pkP5hrWdddIGlpV7COegf35e52szoY1Z9EMQvRev8 X-Received: by 2002:aa7:d30a:0:b0:460:362e:af11 with SMTP id p10-20020aa7d30a000000b00460362eaf11mr372033edq.256.1666218364246; Wed, 19 Oct 2022 15:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666218364; cv=none; d=google.com; s=arc-20160816; b=weflCpssTxkT8XEI3o1F5J8oTQ8/22NRj/8EoExCvCd8kM1M//GCZus/BsqmGctRL8 yN0iapii3DBPlDbEQUY7SzahvNwl6EdfXPHl5LayLiydmNq1NdOgGmQqYPFcSgDCw7Vz 9hbwr9XAuSbECzww8fNXuMYtqOwdHjOxZWTuXnayuy4WdZ3Ett0qbBjShHvnb5WqA5wa X/GSGaz8v9pYEhC35LB2Wt0WdvYprubb3J3+ExKYIlv+ucUyQNCwpWk3jz6kwgzThjMF GI8bkW9uGGN7xaCetTYUawLFCJ3bqk2G2WmHsrg5oq1CGRijlGgMEQ5IfnJxknshrsEq /INA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6pDjAbnGdS8XDtn4tfTx6Ke5EcI6/PEnPZIXA1s5SF0=; b=UV3ZfrDK3kyFkBSnWFe07GMg3JcV3YYACZ3dbDUTkJKHtg1aNgPFjbCU6UAFTBSwrx NvsyPBC9XM9+MwAN0SiebrJ2Mu1nnt5rO4+KWywfBwUe9ZDLpjbBYnJGARj6LG8hqz9o ypfbmqiPGlbEyW1EWOER6dwuX5ZioAElP5o2zaUDDAOYFkKszcP/uszFH+bgSMrq4M/0 Va9Xjdda06fin96QbAzoqBkaVmXysc6vw+0nTK+r4UZbt9iK/5klH1hI3pYXyOw/Wqrd l5Y+/RbM7ixoRjjkp6wIuhqcS7++17+bchVcJSZdaVXL1VAg6+tslBCixoNFFemIUMHr bJWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=C7dR+OI7; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x7-20020a170906148700b0078200f94d06si13414045ejc.237.2022.10.19.15.25.36; Wed, 19 Oct 2022 15:26:04 -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=@google.com header.s=20210112 header.b=C7dR+OI7; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231375AbiJSWJe (ORCPT + 99 others); Wed, 19 Oct 2022 18:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbiJSWJc (ORCPT ); Wed, 19 Oct 2022 18:09:32 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81B4919289 for ; Wed, 19 Oct 2022 15:09:30 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id by36so23948612ljb.4 for ; Wed, 19 Oct 2022 15:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6pDjAbnGdS8XDtn4tfTx6Ke5EcI6/PEnPZIXA1s5SF0=; b=C7dR+OI7oZALDxCFrYaC2tDm9sLZzStqcPGKxYJ7a2GRz3F00j1byYtN7656coauHN 6zVYKAujIspBeE8rGPaGYoxTrlvkWRL9QxW2FJdMjZFL22XhshrwL2Z7659Lx3kEROcP CJ3gurYa4x0wYStwqn9cIu6nigNKMfIKes9ztF3T9bOjOjE91IDfzPyhH6Cet99w82/6 zZZsJyyGdnktVuoHZMenmUW/JctV1dSGFgq+In2I/5q9MlTCMZqp+bdBHVTo7M37JPuj VfmPZ8Tekzq1SE4Rn3NL0XoBUHrZQhvYVuGCjwsZ2uEUOLOl3EI1K5nJ+wpcEjEv+mm0 Bi1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6pDjAbnGdS8XDtn4tfTx6Ke5EcI6/PEnPZIXA1s5SF0=; b=iGmAgmUIG3oLrgn1AYMZ9V8EICBkDC8O7cj2zR/erWkzVYoSGpjMV/RhQTEiG0YRaQ FNl6978EwfcYq59FdHk6F8Rl8VO96u4SWoXnxiXoHTSuhm0wVw/768WXeJgNfn49Z2PQ q45WQ/CtjAfVlVEyipv1upwo5G5LO0Sj9qFIGA/7olR/Uho5DBq74aaxXgOIHiWr6XWI 3+qi3UBUona1/rL28zjXBIi3H5kwV7vgmjZO6K9NW0Ieb1swBELD6kWBb5ZjcT+nrc/3 AELY+BNhAEumok/z0dEP8a1nNhqykAO/6NC/G4WskDC6hEdhFn/wowBUsGLANumLXseJ q/Nw== X-Gm-Message-State: ACrzQf0mESDhDo+gJ/kUBTY4RFCbBPMWmNXie0d6APFOCLrtvyTUrvRK LtpzhRLN6oIvV+lkpQKYe2STVZnFDIlSTdAoAAvCdjjt5Q== X-Received: by 2002:a2e:a28d:0:b0:26f:b4e9:4dda with SMTP id k13-20020a2ea28d000000b0026fb4e94ddamr3428858lja.13.1666217368520; Wed, 19 Oct 2022 15:09:28 -0700 (PDT) MIME-Version: 1.0 References: <20221003232033.3404802-1-jstultz@google.com> <20221003232033.3404802-3-jstultz@google.com> In-Reply-To: From: John Stultz Date: Wed, 19 Oct 2022 15:09:15 -0700 Message-ID: Subject: Re: [PATCH RFC v4 2/3] sched: Avoid placing RT threads on cores handling long softirqs To: Alexander Gordeev Cc: LKML , "Connor O'Brien" , John Dias , Rick Yiu , John Kacur , Qais Yousef , Chris Redpath , Abhijeet Dharmapurikar , Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Thomas Gleixner , kernel-team@android.com, "J . Avila" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Wed, Oct 19, 2022 at 2:11 AM Alexander Gordeev wrote: > > On Mon, Oct 17, 2022 at 08:42:53PM -0700, John Stultz wrote: > > Hrm. Suggestions? As select_task_rq_rt() is only one of the callers. > > Trying to pass curr into cpu_busy_with_softirqs() would mean > > cpupri_find_fitness() would need to read the cpu_rq(cpu)->curr for the > > specified cpu and pass that in. > > May be you could have a lightweight checker that accepts rq and curr > and gets called from select_task_rq_rt(). Then you could call that > same checker from cpu_busy_with_softirqs(). Fair enough. Though your other questions are making me wonder if this is necessary. > > Just to expand what it should be in detail: > > 1: (softirqs & LONG_SOFTIRQ_MASK) && > > 2: (curr == cpu_ksoftirqd || > > 3: task_thread_info(curr)->preempt_count & SOFTIRQ_MASK) > > > > Where we're checking > > 1) that the active_softirqs and __cpu_softirq_pending() values on the > > target cpu are running a long softirq. > > AND ( > > 2) The current task on the target cpu is ksoftirqd > > OR > > 3) The preempt_count of the current task on the target cpu has SOFTIRQ entries > > ) > > 2) When the target CPU is handling or about to handle long softirqs > already what is the difference if it is also running ksoftirqd or not? Again, a good question! From my understanding, the original patch was basically checking just #2 and #3 above, then additional logic was added to narrow it to only the LONG_SOFTIRQ_MASK values, so that may make the older part of the check redundant. I fret there are some edge cases where on the target cpu softirqs might be pending but ksoftirqd isn't running yet maybe due to a lowish-prio rt task - such that the cpu could still be considered a good target. But this seems a bit of a stretch. > 3) What is the point of this check when 1) is true already? Yeah, the more I think about this, the more duplicative it seems. Again, there's some edge details about the preempt_count being set before the active_softirq accounting is set, but the whole decision here about the target cpus is a bit racy to begin with, so I'm not sure if that is significant. So I'll go ahead and simplify the check to just the LONG_SOFTIRQ_MASK & (active | pending softirqs) check. This should avoid the need to pull the cpu_rq(cpu)->curr value and simplify things. Will send out a new version once I've been able to validate that similification doesn't introduce a regression. Thanks so much for the feedback and suggestions! -john