From owner-freebsd-net@freebsd.org Tue Mar 31 19:15:18 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 A79C62683AC for ; Tue, 31 Mar 2020 19:15:18 +0000 (UTC) (envelope-from ricera10@gmail.com) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (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 48sJtd3kFzz4RNm; Tue, 31 Mar 2020 19:15:05 +0000 (UTC) (envelope-from ricera10@gmail.com) Received: by mail-qt1-f196.google.com with SMTP id i3so19376327qtv.8; Tue, 31 Mar 2020 12:15:04 -0700 (PDT) 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; bh=E6xW8xUpqrFNvLiSiHk0BJhnRSthfwn6rDCDw+SB4CA=; b=oaiKsQdtetCaWXbRujbGc5UKgN/nfRC6waiwVB0FaVbwuAYfErfeSEM/T7RdrNpKqY CWWgOGGp/JtHmvqKp4PwW3cQuBOruOgDGhjCLt70i77UMyBId74d//MuEVFh3mHuxpOo cCpQhYz4Vu+2Jm+kH2JskmLcWbgIvbeIJPueiCREoXmDCqB3+DU9Rzd90WNra6KaRye0 Z+RP6QaV1kDEFIlZxRnsWItNuhAHhQE8RIahrYwITYWdHeB80qTWpnjYpkLH/X7QYHpB iu4G0eCpfjLPr2Nn56825qg7lqohchdpHOsIONgulShGZYXFBXCRhJ2fVkv9FGTQWmr/ azlw== X-Gm-Message-State: ANhLgQ09qQURDsv1OxUHQ9zHcV7nB978+MobSPp+32z5L9OG46Soone3 RPEtnS71UHJKC8cjpsXGjQjRfQ9juuQ= X-Google-Smtp-Source: ADFU+vsrUu4h6YSb/mH5Ur7MSQsm25k1hK/J9bD1IeEEtTZWw1BMcd6cpCvwvBbwUfNuoWiPVtVgjg== X-Received: by 2002:ac8:2f17:: with SMTP id j23mr6887612qta.249.1585682097394; Tue, 31 Mar 2020 12:14:57 -0700 (PDT) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com. [209.85.160.181]) by smtp.gmail.com with ESMTPSA id k15sm14478169qta.74.2020.03.31.12.14.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2020 12:14:56 -0700 (PDT) Received: by mail-qt1-f181.google.com with SMTP id m33so19414443qtb.3; Tue, 31 Mar 2020 12:14:56 -0700 (PDT) X-Received: by 2002:ac8:3488:: with SMTP id w8mr6745242qtb.187.1585682096424; Tue, 31 Mar 2020 12:14:56 -0700 (PDT) MIME-Version: 1.0 References: <0e2e97f2-df75-3c6f-9bdd-e8c2ab7bf79e@selasky.org> <20200130030911.GA15281@spy> <20200212222219.GE83892@raichu> <20200328225150.GA82767@raichu> In-Reply-To: From: Eric Joyner Date: Tue, 31 Mar 2020 12:14:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Issue with epoch_drain_callbacks and unloading iavf(4) [using iflib] To: Mark Johnston Cc: freebsd-net@freebsd.org, Hans Petter Selasky , John Baldwin , shurd , Drew Gallatin , Gleb Smirnoff X-Rspamd-Queue-Id: 48sJtd3kFzz4RNm X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of ricera10@gmail.com designates 209.85.160.196 as permitted sender) smtp.mailfrom=ricera10@gmail.com X-Spamd-Result: default: False [-2.23 / 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)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; IP_SCORE(-0.23)[ip: (-0.02), ipnet: 209.85.128.0/17(-0.64), asn: 15169(-0.45), country: US(-0.05)]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; MIME_TRACE(0.00)[0:+,1:+,2:~]; DMARC_NA(0.00)[freebsd.org]; RWL_MAILSPIKE_GOOD(0.00)[196.160.85.209.rep.mailspike.net : 127.0.0.18]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_IN_DNSWL_NONE(0.00)[196.160.85.209.list.dnswl.org : 127.0.5.0]; RBL_SPAMHAUS_FAIL(0.00)[196.160.85.209.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net:query timed out]; FORGED_SENDER(0.30)[erj@freebsd.org,ricera10@gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[erj@freebsd.org,ricera10@gmail.com]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Tue, 31 Mar 2020 19:15:18 -0000 Mark, I tried out a kernel with the tip of CURRENT with both D24214 and D24215 applied, and I still see the problem. As well, after doing a "sysctl debug.kdb.enter=1" and viewing the stack trace there for kldunload, it appears to be similar to the one I posted in my last post. - Eric On Mon, Mar 30, 2020 at 1:19 PM Eric Joyner wrote: > On Sat, Mar 28, 2020 at 3:52 PM Mark Johnston wrote: > >> 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? >> > > Yeah, I'll try them out. > > - Eric >