Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2918800pxk; Mon, 28 Sep 2020 03:53:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc4j5XQ93AhYVblBcje5lx9NXDswHEWdytLYgkM4heh++vNrAsfD6XS+i4SN2wNZ7d0EVe X-Received: by 2002:a17:906:3e08:: with SMTP id k8mr988274eji.480.1601290402065; Mon, 28 Sep 2020 03:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601290402; cv=none; d=google.com; s=arc-20160816; b=RZ8WlnidBm0ow6s0w6VR/+NgiTBW7k5fSZW9DF8TEEZ3watVkz7NfnGm3+2IECp+ya nDadOOzfszigP9TcJb2oof4rLU1m3vEDGrLOYcEYzWCkM+Mv3qjp6WSS+4CgvL9i3zwX S4QuFC8eZC5E6EbHc3fBsG+X9+vAhOuwLtEh/0eSklJIyGYTA1l3ddxI8F2czCCwWP74 0ZQCYLNJmCOMjzoAnimIBk+ec8XQUbicV+SL+kTUKwvmblIxgikPp+pNECnQvAAVrw2g XR4QG7sopdY0Q3UtfE5xEdX8f/K/PP3eyRFMT7M0x7cm6zzBT1xIun3o6IZipTZ7DDdy /xhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SiY/fxcjly07AYC6UVog8C8EU3u0KHh2dbaMA7X6uFo=; b=StVe9s+KXmftSa9rQ3BJUERIcS2zIcjwR5euapb7OZfeELcq8dFv78jCbmxJ3kbZ7+ LbYKaLMenSQknOtNMobqtuDzC6Hu5Aki8g2JaXMNsV8xzT7pBW5Lk4TEmz/11BpkQ0Kz tRjV2P1x0EN2c0n2dtyu8XVIchRQB1PXCuKy6GZFD1kFf1PCCrJ96pVU4UKd+3mehXIy WBYpf5aCRytbq0CSf92HQymZmlgRabJHbDZ+HsQl2dKDz2C4mAqorUG3PQDmlmTAD8oM V8HyuLYiaHnlQ4J+IWSt16zmBnjHhyxljj/8MeNO1AHox/A4w9joIngpMQKDSVt21WBT k2Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l2Ex0uqO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si341774edy.509.2020.09.28.03.52.58; Mon, 28 Sep 2020 03:53:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l2Ex0uqO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbgI1KwA (ORCPT + 99 others); Mon, 28 Sep 2020 06:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgI1Kv7 (ORCPT ); Mon, 28 Sep 2020 06:51:59 -0400 Received: from mail-ua1-x943.google.com (mail-ua1-x943.google.com [IPv6:2607:f8b0:4864:20::943]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D54C061755 for ; Mon, 28 Sep 2020 03:51:59 -0700 (PDT) Received: by mail-ua1-x943.google.com with SMTP id o64so2027978uao.1 for ; Mon, 28 Sep 2020 03:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=SiY/fxcjly07AYC6UVog8C8EU3u0KHh2dbaMA7X6uFo=; b=l2Ex0uqOP2vEg6q34gHXy6uph9r0EXqW2fTF81zYWD93ThqgWkWfmonQoyx6N3aToO yOuEfCuOzYn+bigU/CnbU8We0baBCJ8e498XmP/uj8EIpCnuM7tI45L5dt9DMn9UXWav wIkODNPzlrrGwri96tfGAwtIyw5vxSin4VKsbdRRFFLSgudbbWvNd4rWOczFIUNIhrmP FDFCKQZ3HMKgF0W+BraeyWRG+Mv6dmDMDCRoE8VXDIy0nQdWGn+8w6tDgwU3/Oksi6ep 7lWacnbx39q7yv9VlGinCZAq+wR85a4uxkmTQ//UT5i3FsWvMMdtnCNo9rNdl3bUW381 pMLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SiY/fxcjly07AYC6UVog8C8EU3u0KHh2dbaMA7X6uFo=; b=FsyLIqENG2MSGHrslxQgygLvN9bq/ZKMpzgiz2ekegMyz7bFvX2OrSw9t2tspyo2Q0 rIQhPZLl0dJxX7LMhwvFzPgZdgli19VKimOqT/Xwaw4SVcb/ciptPDqiDNnOz9wJYMjl stLy833P26PnkrW8+8DPwFZumKaAXUqpGCFQiY9JqhuFtv6E8fim10xJ7FxHRusko/KD igsiUWsG/qPoSyCdwY7fAzjDlQfZyA/wIuxoRhfwQiQ3lfu/85Nr4yNWyG/ll0X7yiqg rJIBb81FNMtOcAJBYCo36P2JbyRub4e0uxu40o/14oa87y6z5WTmhpcYd0PoBsmRnKAD nigQ== X-Gm-Message-State: AOAM530UvjDakTWoPHjA+5k+oU2ErLveQVL4HKYXLa/E1XLgcKqCcr6H haTzjSGYckH8UQMxuG99L6gqLLj3HOAq0QQEpCQ= X-Received: by 2002:ab0:6ce6:: with SMTP id l6mr223585uai.55.1601290319046; Mon, 28 Sep 2020 03:51:59 -0700 (PDT) MIME-Version: 1.0 References: <20200915115609.85106-1-qianjun.kernel@gmail.com> <20200915115609.85106-5-qianjun.kernel@gmail.com> <878scz89tl.fsf@nanos.tec.linutronix.de> <20200925004207.GE19346@lenoir> In-Reply-To: <20200925004207.GE19346@lenoir> From: jun qian Date: Mon, 28 Sep 2020 18:51:48 +0800 Message-ID: Subject: Re: [PATCH V7 4/4] softirq: Allow early break the softirq processing loop To: Frederic Weisbecker Cc: Thomas Gleixner , peterz@infradead.org, will@kernel.org, luto@kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , qais.yousef@arm.com, Uladzislau Rezki Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Frederic Weisbecker =E4=BA=8E2020=E5=B9=B49=E6=9C=882= 5=E6=97=A5=E5=91=A8=E4=BA=94 =E4=B8=8A=E5=8D=888:42=E5=86=99=E9=81=93=EF=BC= =9A > > On Thu, Sep 24, 2020 at 05:37:42PM +0200, Thomas Gleixner wrote: > > Subject: softirq; Prevent starvation of higher softirq vectors > [...] > > + /* > > + * Word swap pending to move the not yet handled bits of the prev= ious > > + * run first and then clear the duplicates in the newly raised on= es. > > + */ > > + swahw32s(&cur_pending); > > + pending =3D cur_pending & ~(cur_pending << SIRQ_PREV_SHIFT); > > + > > for_each_set_bit(vec_nr, &pending, NR_SOFTIRQS) { > > int prev_count; > > > > + vec_nr &=3D SIRQ_VECTOR_MASK; > > Shouldn't NR_SOFTIRQS above protect from that? > > > __clear_bit(vec_nr, &pending); > > kstat_incr_softirqs_this_cpu(vec_nr); > > > [...] > > + } else { > > + /* > > + * Retain the unprocessed bits and swap @cur_pending back > > + * into normal ordering > > + */ > > + cur_pending =3D (u32)pending; > > + swahw32s(&cur_pending); > > + /* > > + * If the previous bits are done move the low word of > > + * @pending into the high word so it's processed first. > > + */ > > + if (!(cur_pending & SIRQ_PREV_MASK)) > > + cur_pending <<=3D SIRQ_PREV_SHIFT; > > If the previous bits are done and there is no timeout, should > we consider to restart a loop? > > A common case would be to enter do_softirq() with RCU_SOFTIRQ set > in the SIRQ_PREV_MASK and NET_RX_SOFTIRQ set in the normal mask. > > You would always end up processing the RCU_SOFTIRQ here and trigger > ksoftirqd for the NET_RX_SOFTIRQ. yes, I found that this problem also exists in our project. The RCU softirq may cost 9ms, that will delay the net_rx/tx softirq to process, Peter's branch maybe can slove the problem git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git core/softirq > > Although that's probably no big deal as we should be already in ksoftirqd > if we processed prev bits. We are just going to iterate the kthread loop > instead of the do_softirq loop. Probably no real issue then... > > > > > > + /* Merge the newly pending ones into the low word */ > > + cur_pending |=3D new_pending; > > + } > > + set_softirq_pending(cur_pending); > > wakeup_softirqd(); > > out: > > lockdep_softirq_end(in_hardirq); >