Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp156181pxk; Wed, 9 Sep 2020 01:35:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK5vM5s3zakbYuOTAcGlaHGNbWYzeaLttWpjtNKgiCFYwlS81v6DdujXFECq3J5gR8cAel X-Received: by 2002:a17:906:c830:: with SMTP id dd16mr2660823ejb.196.1599640558636; Wed, 09 Sep 2020 01:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599640558; cv=none; d=google.com; s=arc-20160816; b=tMjgBRcmeygWPEftGemZStmyD8te9r1zbZ8fk/z50ss6pwg9yr8n3rceFcfasBw/1j DaLDpgtnRYXeBTI7tkXg+ru00soQhTsJI5DEePomPAVLoSH9dZl0q2DLtJM0e9v4FEJo SXY45nkBeqmdlAUnKYWQIYpboLXpf+dioa6NjcaApCVKPUOCFgTw+wSIHK7Qbec9yFel VqR/hJW0oeK3EN0mzWjfFA61dPrCG5SfaxRTwAb5ep+/ikwi57IsC/DlBfQ6TONRXK+L 8xanP/ZlvEwDKWkYkk9n3Y3JkVxJcakc9w9Y5rKVJpX7SQXsNYNeqfx1GXgsDNJ+lMoi Bs5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MsQRJbIjqWwVO8tBA19OtnBJtI7NFv3wFSz6AT6T1T4=; b=phB7/B+4HSrzJkGLs+ROvl45KnpX9oWgKAbd7eSmQbT7F9wMyzWhE+63KXkDJ6cghQ aRSK+JHw2Mg6YvRtuqBKd5vZsd02khdnyEBgyUcDWLjUh7sirp6vHhTrggOsczUc9gkH VdvXiUbwfwFH4MEv778kovMcYKjebS5fXcOrMzLzu6W4AgVqFHj2j5o4E8HnYXyuJwgm dxay+3pp80BWMjtpWSftfhJD+2TOK5DEXlHEc6BrVURRjI69Mc2g1NrKWt4Q2HEm8zXJ 3UYuR9z2+s91cOMGYhjOAQmEhCmocXvNVnmDiu+YSG6utKQ9Zmvgadd1KkdR0z4q1orZ fokQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZF9+qSlW; 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 u21si1071805ejy.112.2020.09.09.01.35.36; Wed, 09 Sep 2020 01:35:58 -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=ZF9+qSlW; 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 S1728911AbgIIIc3 (ORCPT + 99 others); Wed, 9 Sep 2020 04:32:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727920AbgIIIcY (ORCPT ); Wed, 9 Sep 2020 04:32:24 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3352BC061573 for ; Wed, 9 Sep 2020 01:32:23 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id e23so1603206otk.7 for ; Wed, 09 Sep 2020 01:32:23 -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=MsQRJbIjqWwVO8tBA19OtnBJtI7NFv3wFSz6AT6T1T4=; b=ZF9+qSlWcgqllAmZUgXL8tWH5tzsfyFvou4SpISOE/bzcWPT05V0wXRXKy1G/OdjzY iq4d0VBF4apqKbTYByp6JxlmawORc85JWt5rNTP4Fm70fxCx65UG4HDcDwLn0uPv1edy dmoJgsGCbsw5A2vJbhtOfd+mM7lXmjiyoi+krIql/mlmIRyCYVVcMJOJrSf+kertfZTe OkwHXywqCUygRocCLPVukFqRxg39iTclFTSoxyjEYvf0oJW0uPCK31uk6NP453nBlbIX hlEQT4UhLkZW2+SrV38ttTyoYfBDUTye+nSoEp8Sl4Zz5zdfLnwdaCpr7bpPCQ/WAmNO 617Q== 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=MsQRJbIjqWwVO8tBA19OtnBJtI7NFv3wFSz6AT6T1T4=; b=DhVBgvJU7xXVVR+KR38H0tc2pcDV721Lz1ZIgJB77XKcuPBfYwJQuZe/Rq9Q7bqrO2 xcxR3srdDOjgUJGtuOPmLSlkmbrxzNm317MU3cfzGLTDWDhf/kA0ODDeYeBCcfBC+IE/ 98x+wX6a057+WSTq0uTm89hMH4qkMvPM83OuO7W1jbmJx0Seq76bQXZGhaWo3GZPTYF6 RpUc/LRdXa7CgLQhUoYupv5jkN0UGO6eSgfnBRtfCd+Mo5+Bh04Hx7mhYtMCmlBNRHIt WlRnygoL2EpwraxuyqTrelZsotvSfAzFRn+efcRRQFCtOI6ONlEcMgOn51GeSa2NDK0D HR+w== X-Gm-Message-State: AOAM531dFSDH2hp1aJFBe1seNHOhr1WDK9obvl2vIez94+vUtGkn11kN KDBgZpUpd8uQ16pW7YRV51vBjJP3DtR/Mf28+X6Xt/pQYXs= X-Received: by 2002:a05:6830:1f4f:: with SMTP id u15mr2080838oth.215.1599640341507; Wed, 09 Sep 2020 01:32:21 -0700 (PDT) MIME-Version: 1.0 References: <1595601083-10183-1-git-send-email-qianjun.kernel@gmail.com> <87sgddaru7.fsf@nanos.tec.linutronix.de> <87v9i6a53n.fsf@nanos.tec.linutronix.de> In-Reply-To: <87v9i6a53n.fsf@nanos.tec.linutronix.de> From: jun qian Date: Wed, 9 Sep 2020 16:32:10 +0800 Message-ID: Subject: Re: [PATCH V4] Softirq:avoid large sched delay from the pending softirqs To: Thomas Gleixner Cc: peterz@infradead.org, will@kernel.org, luto@kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Uladzislau Rezki Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thomas Gleixner =E4=BA=8E2020=E5=B9=B47=E6=9C=8829=E6= =97=A5=E5=91=A8=E4=B8=89 =E4=B8=8B=E5=8D=888:16=E5=86=99=E9=81=93=EF=BC=9A > > Qian, > > jun qian writes: > > On Mon, Jul 27, 2020 at 11:41 PM Thomas Gleixner w= rote: > >> > + or_softirq_pending(pending << (vec_nr + 1)); > >> > >> To or the value interrupts need to be disabled because otherwise you c= an > >> lose a bit when an interrupt happens in the middle of the RMW operatio= n > >> and raises a softirq which is not in @pending and not in the per CPU > >> local softirq pending storage. > >> > > I can't understand the problem described above, could you explain in > > detail. > > Oring a value to a memory location is a Read Modify Write (RMW) > operation. > > x |=3D a; > > translates to pseudo code: > > R1 =3D x // Load content of memory location x into register= R1 > R1 |=3D a // Or value a on R1 > x =3D R1 // Write back result > > So assume: > > x =3D 0 > a =3D 1 > > R1 =3D x --> R1 =3D=3D 0 > R1 |=3D a --> R1 =3D=3D 1 > > interrupt sets bit 1 in x --> x =3D=3D 0x02 > > x =3D R1 --> x =3D=3D 1 > > So you lost the set bit 1, right? Not really what you want. > > >> There is another problem. Assume bit 0 and 1 are pending when the > >> processing starts. Now it breaks out after bit 0 has been handled and > >> stores back bit 1 as pending. Before ksoftirqd runs bit 0 gets raised > >> again. ksoftirqd runs and handles bit 0, which takes more than the > >> timeout. As a result the bit 0 processing can starve all other softirq= s. > >> > > May I use a percpu val to record the order of processing softirq, by th= e order > > val, when it is in ksoftirqd we can process the pending softirq in orde= r. In the > > scenario you described above, before ksoftirqd runs, bit 0 gets raised = again, > > ksoftirqd runs and handles bit 1 by the percpu val. just like a ring. > > Yes, you need something to save information about the not-processed > bits. Keeping track of which bit to process next works, but whether > that's going to result in efficient and simple code is a different > question. > > Thanks, > > tglx > Hi Thomas, I am so sorry, For personal reasons, the modification of this patch was delayed, I will submit the next modified version in these two days, sorry again