From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49525C77B75 for ; Mon, 8 May 2023 03:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232026AbjEHDh0 (ORCPT ); Sun, 7 May 2023 23:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbjEHDh0 (ORCPT ); Sun, 7 May 2023 23:37:26 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C4024483; Sun, 7 May 2023 20:37:22 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QF6QK2JbgzpW6Q; Mon, 8 May 2023 11:36:09 +0800 (CST) Received: from [10.174.176.93] (10.174.176.93) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 8 May 2023 11:37:19 +0800 Message-ID: Date: Mon, 8 May 2023 11:37:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH 4/9] softirq: Allow early break To: Eric Dumazet CC: , , , , , , , , , , , , , , , , , , , , , , , References: <20230505113315.3307723-1-liujian56@huawei.com> <20230505113315.3307723-5-liujian56@huawei.com> From: "liujian (CE)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.93] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On 2023/5/5 20:10, Eric Dumazet wrote: > On Fri, May 5, 2023 at 1:24 PM Liu Jian wrote: >> >> From: Peter Zijlstra >> >> Allow terminating the softirq processing loop without finishing the >> vectors. >> >> Signed-off-by: Peter Zijlstra (Intel) >> Signed-off-by: Liu Jian >> --- >> kernel/softirq.c | 16 ++++++++++------ >> 1 file changed, 10 insertions(+), 6 deletions(-) >> >> diff --git a/kernel/softirq.c b/kernel/softirq.c >> index 48a81d8ae49a..e2cad5d108c8 100644 >> --- a/kernel/softirq.c >> +++ b/kernel/softirq.c >> @@ -582,6 +582,9 @@ asmlinkage __visible void __softirq_entry __do_softirq(void) >> prev_count, preempt_count()); >> preempt_count_set(prev_count); >> } >> + >> + if (pending && __softirq_needs_break(start)) >> + break; > > This means that some softirq may starve, because > > for_each_set_bit(vec_nr, &pending, NR_SOFTIRQS) > > Always iterate using the same order (of bits) > > Yes, we need to record the softirq that is not executed and continue next time. I will fix it in next version. Thanks. > > >> } >> >> if (!IS_ENABLED(CONFIG_PREEMPT_RT) && >> @@ -590,13 +593,14 @@ asmlinkage __visible void __softirq_entry __do_softirq(void) >> >> local_irq_disable(); >> >> - pending = local_softirq_pending(); >> - if (pending) { >> - if (!__softirq_needs_break(start) && --max_restart) >> - goto restart; >> + if (pending) >> + or_softirq_pending(pending); >> + else if ((pending = local_softirq_pending()) && >> + !__softirq_needs_break(start) && >> + --max_restart) >> + goto restart; >> >> - wakeup_softirqd(); >> - } >> + wakeup_softirqd(); >> >> account_softirq_exit(current); >> lockdep_softirq_end(in_hardirq); >> -- >> 2.34.1 >>