From owner-freebsd-net@freebsd.org Sat Mar 28 22:52:21 2020 Return-Path: Delivered-To: freebsd-net@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 1714D269815 for ; Sat, 28 Mar 2020 22:52:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48qYrV3Nfzz4bFq; Sat, 28 Mar 2020 22:52:09 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf43.google.com with SMTP id bu9so959792qvb.13; Sat, 28 Mar 2020 15:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g+0aXElG6sVTMSAizXABgrSw3aAa04LoMo3XTdxHeZU=; b=aoyDArWkM8SZ8xXa3VKYAZ/WQ/njY9x4ixTxPq7AfiOWkCP9MoXKk5sTsNRFrMY9ir Ov7dMslJ+ruvbUAjYnSPUrI8F7iktGLPC1IGPSg3+KkylcRAZ+9NCRuOXrugOdezEgKM 1xvX+SZjM3b072LDplLHjA+qbI3rvhGqbENPhE3obSfpZ9toc3KJmb5+2vYze3UDpFyU oJ3LHHSSPyrMmrKsgBZUIYyAT7mFCJBEwLotiU48SqDNY6CBvxJv6fvLY3EZgzb6RSIA yLPFO4CnnedN9Vz76HL7T72f4dR8HwMZU6Cj6qXSS0Ffep50DC7ksjb7IFi3KRu0LPFA bejA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=g+0aXElG6sVTMSAizXABgrSw3aAa04LoMo3XTdxHeZU=; b=ExN62N0FHw+tsOIwpZWo8f/vFVrQ05HV2YDH6JJRqwyDTJW6iP2FH2mu9uQT6hjRxu HbOjdzuWfzcbFcAEJdcBhiyFqYujGtufvg31fZTqD+a//WuvbzkD6o+ChdWwSmZnCjGs 60tMBYa3DPL+7QMJLsAlJK1kf4tgMJDJUKwP5rDdZANC7IbJuSHiU1wEEpnzDNAKwA/8 vYm5u/rXfzrkJ5BWfy6RXLP0iB8+jY8Hz0FeOF7btx+k6EMJ/pPrGsEhUXP5UEhkmTzB aGjy3TDT7BQAblhmcQza2SAH3+bydvIuVLzyahxpOvI6Rai0jUqhRrXx65ZZIEG6s1Nw mNGg== X-Gm-Message-State: ANhLgQ3GoaiA2nrF9ew4JmHBVRsY+Ku0rkMR0/3mTTQxD3As+1v0qu3e PtKWWz0ZkZ3oyX6FVknV2sUvH6HOIi0= X-Google-Smtp-Source: ADFU+vsmr0mOLVlCjgEVr+sI936LbsFVm+eA5wpBOxC/+D1yi9NQcff9bo1fU1Sn2aTy+KIW6IRvcA== X-Received: by 2002:ad4:556e:: with SMTP id w14mr5758482qvy.144.1585435923133; Sat, 28 Mar 2020 15:52:03 -0700 (PDT) Received: from raichu (toroon0560w-lp130-10-174-94-17-182.dsl.bell.ca. [174.94.17.182]) by smtp.gmail.com with ESMTPSA id j20sm6973916qke.44.2020.03.28.15.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 15:52:02 -0700 (PDT) Sender: Mark Johnston Date: Sat, 28 Mar 2020 18:51:57 -0400 From: Mark Johnston To: Eric Joyner Cc: freebsd-net@freebsd.org, Hans Petter Selasky , John Baldwin , shurd , Drew Gallatin , Gleb Smirnoff Subject: Re: Issue with epoch_drain_callbacks and unloading iavf(4) [using iflib] Message-ID: <20200328225150.GA82767@raichu> References: <0e2e97f2-df75-3c6f-9bdd-e8c2ab7bf79e@selasky.org> <20200130030911.GA15281@spy> <20200212222219.GE83892@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 48qYrV3Nfzz4bFq X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=aoyDArWk; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::f43 as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-1.87 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; RBL_SENDERSCORE_FAIL(0.00)[3.4.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.bl.score.senderscore.com:query timed out]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_IN_DNSWL_NONE(0.00)[3.4.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; RBL_BLOCKLISTDE_FAIL(0.00)[3.4.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.bl.blocklist.de:query timed out]; IP_SCORE(-0.17)[ip: (0.01), ipnet: 2607:f8b0::/32(-0.36), asn: 15169(-0.46), country: US(-0.05)]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2020 22:52:21 -0000 On Wed, Mar 11, 2020 at 04:32:40PM -0700, Eric Joyner wrote: > Mark, > > I did get some time to get back and retry this; however your second patch > still doesn't solve the problem. Looking into it a bit, it looks like the > kldunload process isn't hitting the code you've changed; it's hanging in > epoch_wait_preempt() in if_detach_internal(), which is immediately before > epoch_drain_callbacks(). > > I did a kernel dump while it was hanging, and this is the backtrace for the > kldunload process: I see. I think the callback can be made much simpler and avoid the problematic sched_bind() calls. I wrote a patch that allows waiting threads to lend scheduling priority to a preempted thread blocked in an epoch section, based on some code I wrote to implement preemptible SMR sections. If waiting for a running thread, the callback just spins. This might be enough to solve your problem, I posted the two lightly tested patches here: https://reviews.freebsd.org/D24214 https://reviews.freebsd.org/D24215 If we hit a situation where a reader is preempted and then its CPU is hogged by a high-priority kernel thread, this still won't be enough, but I suspect it'll solve your case. Would you be able to test?