Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp251262rwb; Fri, 18 Nov 2022 00:32:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5gfeSjGKia3nqjOffRqCPpl+oMp0TVhsH0z+oHw50PYE3OHokQSLjO1RDm9c5g1RXlqScs X-Received: by 2002:a05:6402:613:b0:461:4059:eb3f with SMTP id n19-20020a056402061300b004614059eb3fmr5154819edv.157.1668760323810; Fri, 18 Nov 2022 00:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668760323; cv=none; d=google.com; s=arc-20160816; b=S5NMD4iEdQvMoHNxKfBl2eahtEf7mNu/TzR7UujCp1VhYASrObG3GI8ysJ3QvWPeut Q83Y5r6CfA1CTnJ9lQXNx3NtnlbyDqCcdnArWuPdwHo4VqvrrIYYCDcj9mnrNCW6lErL Dvu6n1hwS694UsS2jEXinZYGLLJ9sdYIncEasa6K/HdMVSc3X+KbpJxzRAb7qnWw27KG 3q0CBce9uGG3K5fNsWDmKZFIsFQZGJUrhdt207bdOu18MbkQHOe220YPD59ltL8q1m6/ HvVuHIYvrf0SvFpKohICazDGRhC5OnFSVxwq7K8/hgKZkotb6WBzHEiABCEvVEjxdjMh bguA== 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=bL61u+2dqwW/EcEsaMGkXQTvRGn76w9a2Ft5PT17cKk=; b=gN0hCe9HhoFDPaZ1AY30M8CMt+/iyY3U2kgfk5tI2CUALCxNJHxMPKwAijCrwq6Z5g 07Yg0q5kP1otNpu8R+KJsppIyWsy6Tj4ZYJDqhw2i6mZMMT7MmVs4ztrONcXLPEhneb0 qVxBA7w1ln/FMw3OB9B95ocv1KZEJf8BXs1K3DHRXbc8kc7X1Hge1bepWp75rDIwGOZn i9Hs5bjSwwZBfhoaLKSAjDcWVlcqbqX/Iumfev0i/FoE4DW7DZdFiECzO1ugWr6RxdlO 7nSXQWIQsWVt8vt0Ff5s1YQTUw7+lAsyZBz3VD8dE70PLDkAGQS4finQ3UWTT/vGBj2B 858w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YBvW9ig5; 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 ds2-20020a0564021cc200b00461891a8138si2685730edb.446.2022.11.18.00.31.41; Fri, 18 Nov 2022 00:32:03 -0800 (PST) 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=YBvW9ig5; 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 S241214AbiKRISv (ORCPT + 90 others); Fri, 18 Nov 2022 03:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241333AbiKRISt (ORCPT ); Fri, 18 Nov 2022 03:18:49 -0500 Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [IPv6:2607:f8b0:4864:20::e34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5389315FD5 for ; Fri, 18 Nov 2022 00:18:48 -0800 (PST) Received: by mail-vs1-xe34.google.com with SMTP id t5so4016237vsh.8 for ; Fri, 18 Nov 2022 00:18:48 -0800 (PST) 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=bL61u+2dqwW/EcEsaMGkXQTvRGn76w9a2Ft5PT17cKk=; b=YBvW9ig59iSyCg3IQ0Vh+0oOMNcO+gSIsWC26yolGTVRx2M5lShlLRMljkjUF/2A+p j2zIkXOJyW/L4wMWuQ8FeYJTLJeCFC0SXdAtgGZBXVGRfhw4qBMz43SBqgv6Wg/TQsF1 +yr80WVCykvtUizp6a+pvkk3QJldMBHVbCBRXK4GonmY0U6sjNLeTXHVylZORvjlYlur KNviqUNg8RcQvP1GxK4ImUBIRevrWFxwtjoQbs7GymUkXMvtlKx/pyfhmK0YzUzFAp3I mxAFa7ZzyxEilHwMNwNV7jenaUTV2Gwdg0GSI4pCp4KcdYTa6axDGCMnsRenMmHT27Zu DzvA== 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=bL61u+2dqwW/EcEsaMGkXQTvRGn76w9a2Ft5PT17cKk=; b=C/hf7xwzAfeuMPp8daimrOMMsInAEEaLDu4zJNc36L7r8XaWGMD8o2S8AbEReSwDvA 8ngJszg3aOmSXi2CWWCI9ZNyIUUSyHitkCjxBfSVpPB3L92vHiP21ZFedWf1LLS7Ey1L EN47NqjHRA7r4ZZspHPHteud/nuHJ/eXTQkkv5mAVnnSBRBU38IiZYeb8VSgoRmOwyl2 2YE2MU/DeM4gGefQii+NRAKCI8tmMpk2VH0zBwpU3UzdSQehKV51o2i8BCttvkIklG3T vHv63kLVdzP8KXVSYMIv1z+5livgXpG1Mjh8hQe4DlTUqe2Z/YjK2ygGlqJe7yof/nid iQuQ== X-Gm-Message-State: ANoB5pkloMKOx2oHAcRj82zoM+yIdrA/43E1H067WRWHeWEfE/UHOM5S gE7aHQhcOrwZN2HakJVeYAOmv/62l4XXmezfR+obbbB91SwwhJ4= X-Received: by 2002:a67:f995:0:b0:3aa:4802:ac46 with SMTP id b21-20020a67f995000000b003aa4802ac46mr3933229vsq.49.1668759527196; Fri, 18 Nov 2022 00:18:47 -0800 (PST) MIME-Version: 1.0 References: <20221116075929.453876-1-jstultz@google.com> <20221116075929.453876-4-jstultz@google.com> In-Reply-To: From: John Stultz Date: Fri, 18 Nov 2022 00:18:35 -0800 Message-ID: Subject: Re: [PATCH v5 3/3] softirq: defer softirq processing to ksoftirqd if CPU is busy with RT To: Peter Zijlstra Cc: LKML , Pavankumar Kondeti , John Dias , "Connor O'Brien" , Rick Yiu , John Kacur , Qais Yousef , Chris Redpath , Abhijeet Dharmapurikar , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Thomas Gleixner , Heiko Carstens , Vasily Gorbik , Joel Fernandes , Alexander Gordeev , kernel-team@android.com, Satya Durga Srinivasu Prabhala , "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, Nov 16, 2022 at 2:37 AM Peter Zijlstra wrote: > On Wed, Nov 16, 2022 at 07:59:28AM +0000, John Stultz wrote: > > From: Pavankumar Kondeti > > > > Defer the softirq processing to ksoftirqd if a RT task is > > running or queued on the current CPU. This complements the RT > > task placement algorithm which tries to find a CPU that is not > > currently busy with softirqs. > > > > Currently NET_TX, NET_RX, BLOCK and IRQ_POLL softirqs are only > > deferred as they can potentially run for long time. > > > > Additionally, this patch stubs out ksoftirqd_running() logic, > > in the CONFIG_RT_SOFTIRQ_AWARE_SCHED case, as deferring > > potentially long-running softirqs will cause the logic to not > > process shorter-running softirqs immediately. By stubbing it out > > the potentially long running softirqs are deferred, but the > > shorter running ones can still run immediately. > > So I'm hating on the new config space, and dubious of the placement > logic (I'm thinking much the same gain can be had when actual softirq > processing stops quickly when we want to reschedule). Hey Peter! Thanks for taking the time to look this over and provide feedback! > However I still have these here patches (revived from the dead): > > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=core/softirq > > That fix some of this same... I think the last time this fell on its > face due to regressions and me not having time/energy to chase them down > and the author of the hack-of-the-day solution walking off or something > like that. So I've taken a look at your patch series and backported it (as well as extended it to use softirq_needs_break for the BLOCK softirq) to a 5.10 device kernel where I can compare the behaviors against the tuned code that's shipping. At first glance at your patches, I was optimistic, as it's great that it nicely time bounds the number of softirqs run, but I fet that it doesn't help if a single softirq takes longer than we'd like. (And indeed, I can see single BLOCK softirqs invocations taking quite some time - > 16ms! in my last run) Obviously "fix that driver to not do that" would be the standard response, but it does become a constant wack-a-mole game. Sort of like some of the philosophy around some of the PREEMPT_RT changes, where a broad solution is used to avoid having to fix and maintain latencies in code across the kernel, this task placement solution helps avoid rt latencies being dependent on the continual perfection of all drivers used. > I think this aspect of the whole softirq thing really needs fixing first > and not hidden under some obscure CONFIG symbol. Sure, and while I am happy to help with your current patch series, as I do think it should improve things, I'm not sure if it will let us move away from the softirq-rt placement optimization patches. Any ideas for additional approaches that would be more agreeable to you? We could pull most of the logic out from the CONFIG file, maybe let userland set the long-softirq mask which rt tasks would avoid scheduling onto? Though I know folks would probably like to avoid the cpupri_find_fitness test logic if they could so I'll have to think how to efficiently shortcut that if the mask is null. Anyway, thanks so much again for the feedback! -john