From owner-svn-src-all@freebsd.org Thu Sep 14 20:02:20 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB57AE083AB; Thu, 14 Sep 2017 20:02:20 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B86CA67018; Thu, 14 Sep 2017 20:02:20 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id v8EK2IVH022277 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 14 Sep 2017 13:02:18 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id v8EK2IXj022276; Thu, 14 Sep 2017 13:02:18 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 14 Sep 2017 13:02:18 -0700 From: Gleb Smirnoff To: Steven Hartland Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r323566 - head/sys/kern Message-ID: <20170914200218.GU1055@FreeBSD.org> References: <201709132211.v8DMB6Pp048326@repo.freebsd.org> <4ae03e74-4fc3-d23b-4f14-3329b20b8df0@multiplay.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ae03e74-4fc3-d23b-4f14-3329b20b8df0@multiplay.co.uk> User-Agent: Mutt/1.8.3 (2017-05-23) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Thu, 14 Sep 2017 20:02:21 -0000 Steven, I don't want to MFC that, since that will hurt performance on stable/11 due to ACCEPT_LOCK(). On Thu, Sep 14, 2017 at 08:31:57AM +0100, Steven Hartland wrote: S> Is this something that will be MFC'ed to 11 or is this 12 / CURRENT only? S> S> On 13/09/2017 23:11, Gleb Smirnoff wrote: S> > Author: glebius S> > Date: Wed Sep 13 22:11:05 2017 S> > New Revision: 323566 S> > URL: https://svnweb.freebsd.org/changeset/base/323566 S> > S> > Log: S> > Use soref() in sendfile(2) instead fhold() to reference a socket. S> > S> > The problem is that fdrop() requires syscall context, as it may S> > enter sleep in some cases. The reason to use it in the original S> > non-blocking sendfile implementation, was to avoid use of global S> > ACCEPT_LOCK() on every I/O completion. Now in head sorele() no S> > longer requires this lock. S> > S> > Modified: S> > head/sys/kern/kern_sendfile.c S> > S> > Modified: head/sys/kern/kern_sendfile.c S> > ============================================================================== S> > --- head/sys/kern/kern_sendfile.c Wed Sep 13 21:56:49 2017 (r323565) S> > +++ head/sys/kern/kern_sendfile.c Wed Sep 13 22:11:05 2017 (r323566) S> > @@ -80,7 +80,7 @@ struct sf_io { S> > volatile u_int nios; S> > u_int error; S> > int npages; S> > - struct file *sock_fp; S> > + struct socket *so; S> > struct mbuf *m; S> > vm_page_t pa[]; S> > }; S> > @@ -255,7 +255,7 @@ static void S> > sendfile_iodone(void *arg, vm_page_t *pg, int count, int error) S> > { S> > struct sf_io *sfio = arg; S> > - struct socket *so; S> > + struct socket *so = sfio->so; S> > S> > for (int i = 0; i < count; i++) S> > if (pg[i] != bogus_page) S> > @@ -267,8 +267,6 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i S> > if (!refcount_release(&sfio->nios)) S> > return; S> > S> > - so = sfio->sock_fp->f_data; S> > - S> > if (sfio->error) { S> > struct mbuf *m; S> > S> > @@ -296,8 +294,8 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i S> > CURVNET_RESTORE(); S> > } S> > S> > - /* XXXGL: curthread */ S> > - fdrop(sfio->sock_fp, curthread); S> > + SOCK_LOCK(so); S> > + sorele(so); S> > free(sfio, M_TEMP); S> > } S> > S> > @@ -724,6 +722,7 @@ retry_space: S> > sfio = malloc(sizeof(struct sf_io) + S> > npages * sizeof(vm_page_t), M_TEMP, M_WAITOK); S> > refcount_init(&sfio->nios, 1); S> > + sfio->so = so; S> > sfio->error = 0; S> > S> > nios = sendfile_swapin(obj, sfio, off, space, npages, rhpages, S> > @@ -858,9 +857,8 @@ prepend_header: S> > error = (*so->so_proto->pr_usrreqs->pru_send) S> > (so, 0, m, NULL, NULL, td); S> > } else { S> > - sfio->sock_fp = sock_fp; S> > sfio->npages = npages; S> > - fhold(sock_fp); S> > + soref(so); S> > error = (*so->so_proto->pr_usrreqs->pru_send) S> > (so, PRUS_NOTREADY, m, NULL, NULL, td); S> > sendfile_iodone(sfio, NULL, 0, 0); S> > S> -- Gleb Smirnoff