From owner-svn-src-all@freebsd.org Fri Jan 24 09:25:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FA0F2337CF; Fri, 24 Jan 2020 09:25:05 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 483tym1qYhz3Hdq; Fri, 24 Jan 2020 09:25:03 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [62.141.129.235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 2A6F72601D2; Fri, 24 Jan 2020 10:25:01 +0100 (CET) Subject: Re: svn commit: r357004 - in head/sys: kern sys From: Hans Petter Selasky To: Gleb Smirnoff , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202001230124.00N1OlXi029506@repo.freebsd.org> Message-ID: <23f272a4-c997-a454-19d6-10392713e71f@selasky.org> Date: Fri, 24 Jan 2020 10:24:53 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 483tym1qYhz3Hdq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 2a01:4f8:c17:6c4b::2 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-4.96 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[selasky.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; IP_SCORE(-2.66)[ip: (-9.22), ipnet: 2a01:4f8::/29(-2.52), asn: 24940(-1.55), country: DE(-0.02)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2020 09:25:05 -0000 On 2020-01-23 09:36, Hans Petter Selasky wrote: > On 2020-01-23 02:24, Gleb Smirnoff wrote: >> Author: glebius >> Date: Thu Jan 23 01:24:47 2020 >> New Revision: 357004 >> URL: https://svnweb.freebsd.org/changeset/base/357004 >> >> Log: >>    Enter the network epoch for interrupt handlers of INTR_TYPE_NET. >>    Provide tunable to limit how many times handlers may be executed >>    without reentering epoch. >>    Differential Revision:    https://reviews.freebsd.org/D23242 >> >> Modified: >>    head/sys/kern/kern_intr.c >>    head/sys/sys/interrupt.h >> >> Modified: head/sys/kern/kern_intr.c >> ============================================================================== >> >> --- head/sys/kern/kern_intr.c    Thu Jan 23 01:20:59 2020    (r357003) >> +++ head/sys/kern/kern_intr.c    Thu Jan 23 01:24:47 2020    (r357004) >> @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); >>   #include >>   #include >>   #include >> +#include >>   #include >>   #include >>   #include >> @@ -94,6 +95,9 @@ static int intr_storm_threshold = 0; >>   SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RWTUN, >>       &intr_storm_threshold, 0, >>       "Number of consecutive interrupts before storm protection is >> enabled"); >> +static int intr_epoch_batch = 1000; >> +SYSCTL_INT(_hw, OID_AUTO, intr_epoch_batch, CTLFLAG_RWTUN, >> &intr_epoch_batch, >> +    0, "Maximum interrupt handler executions without re-entering >> epoch(9)"); >>   static TAILQ_HEAD(, intr_event) event_list = >>       TAILQ_HEAD_INITIALIZER(event_list); >>   static struct mtx event_lock; >> @@ -587,6 +591,8 @@ intr_event_add_handler(struct intr_event *ie, >> const ch >>           ih->ih_flags |= IH_MPSAFE; >>       if (flags & INTR_ENTROPY) >>           ih->ih_flags |= IH_ENTROPY; >> +    if (flags & INTR_TYPE_NET) >> +        ih->ih_flags |= IH_NET; >>       /* We can only have one exclusive handler in a event. */ >>       mtx_lock(&ie->ie_lock); >> @@ -1196,11 +1202,12 @@ ithread_execute_handlers(struct proc *p, >> struct intr_e >>   static void >>   ithread_loop(void *arg) >>   { >> +    struct epoch_tracker et; >>       struct intr_thread *ithd; >>       struct intr_event *ie; >>       struct thread *td; >>       struct proc *p; >> -    int wake; >> +    int wake, epoch_count; >>       td = curthread; >>       p = td->td_proc; >> @@ -1235,8 +1242,21 @@ ithread_loop(void *arg) >>            * that the load of ih_need in ithread_execute_handlers() >>            * is ordered after the load of it_need here. >>            */ >> -        while (atomic_cmpset_acq_int(&ithd->it_need, 1, 0) != 0) >> +        if (ie->ie_hflags & IH_NET) { >> +            epoch_count = 0; >> +            NET_EPOCH_ENTER(et); >> +        } >> +        while (atomic_cmpset_acq_int(&ithd->it_need, 1, 0) != 0) { >>               ithread_execute_handlers(p, ie); >> +            if ((ie->ie_hflags & IH_NET) && >> +                ++epoch_count >= intr_epoch_batch) { >> +                NET_EPOCH_EXIT(et); >> +                epoch_count = 0; >> +                NET_EPOCH_ENTER(et); >> +            } >> +        } >> +        if (ie->ie_hflags & IH_NET) >> +            NET_EPOCH_EXIT(et); >>           WITNESS_WARN(WARN_PANIC, NULL, "suspending ithread"); >>           mtx_assert(&Giant, MA_NOTOWNED); Hi Gleb, What you want to do here is right, but how it is implemented is wrong, in my opinion. 1) Remove intr_epoch_batch. Most network drivers use interrupt moderation, and a timeout of 1000 iterations can easily become 1 second under heavly load ! 2) You need to make a new request function for interrupts which take a pointer to an EPOCH and replace that IH_NET in hflags! --HPS