From owner-freebsd-multimedia@FreeBSD.ORG Fri Jul 19 18:06:18 2013 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 137EC1BF for ; Fri, 19 Jul 2013 18:06:18 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id 904109CF for ; Fri, 19 Jul 2013 18:06:17 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id 9B6801E007B4; Fri, 19 Jul 2013 20:06:09 +0200 (CEST) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.5/8.14.4) with ESMTP id r6JI4sSu027721; Fri, 19 Jul 2013 20:04:54 +0200 (CEST) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.5/8.14.3/Submit) id r6JI4rft027720; Fri, 19 Jul 2013 20:04:53 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Fri, 19 Jul 2013 20:04:53 +0200 To: Hans Petter Selasky Subject: Re: kqueue(2) vs. cuse4bsd? Message-ID: <20130719180453.GA27702@triton8.kn-bremen.de> References: <201307181834.r6IIY35e055755@triton8.kn-bremen.de> <51E844C9.4060106@bitfrost.no> <51E85CFC.3060305@bitfrost.no> <20130719051247.GF26412@funkthat.com> <51E8DEA2.4020506@bitfrost.no> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51E8DEA2.4020506@bitfrost.no> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-multimedia@freebsd.org, Bernhard =?iso-8859-1?Q?Fr=F6hlich?= , Juergen Lock X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jul 2013 18:06:18 -0000 On Fri, Jul 19, 2013 at 08:37:22AM +0200, Hans Petter Selasky wrote: > On 07/19/13 07:12, John-Mark Gurney wrote: > > Hans Petter Selasky wrote this message on Thu, Jul 18, 2013 at 23:24 +0200: > >> Hi, > >> > > > > > Again, the 0 arg to knlist_add says that the cuse_mtx lock has already > > been locked.. either change the arg to 1, or drop the _lock/_unlock()... > > > > New patch attached! Thank you! > > --HPS Hmm this builds on 8.3 but doesn't really work, tvheadend only manages to scan one mux on startup, and eats too much cpu also: PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND 93912 root 35 52 r8 33756K 7216K ucond 3 1:32 41.89% webcamd 93938 nox 13 70 0 80280K 9460K CPU1 1 0:23 17.29% tvheadend For comparison when going back to vdr: (that doesn't use kqueue) 93965 vdr 32 63 19 298M 179M ucond 3 0:02 0.39% vdr 93769 root 28 52 r8 31840K 8284K ucond 2 0:02 0.39% webcamd Thanx! :) Juergen > Index: cuse4bsd_kmod.c > =================================================================== > --- cuse4bsd_kmod.c (revision 2614) > +++ cuse4bsd_kmod.c (working copy) > @@ -1,5 +1,5 @@ > /*- > - * Copyright (c) 2010-2012 Hans Petter Selasky. All rights reserved. > + * Copyright (c) 2010-2013 Hans Petter Selasky. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -134,6 +134,15 @@ > static int cuse_alloc_unit_id[CUSE_DEVICES_MAX]; > static struct cuse_memory cuse_mem[CUSE_ALLOC_UNIT_MAX]; > > +static void cuse_client_kqfilter_detach(struct knote *kn); > +static int cuse_client_kqfilter_event(struct knote *kn, long hint); > + > +static struct filterops cuse_client_kqfilter_ops = { > + .f_isfd = 1, > + .f_detach = cuse_client_kqfilter_detach, > + .f_event = cuse_client_kqfilter_event, > +}; > + > static d_open_t cuse_client_open; > static d_close_t cuse_client_close; > static d_ioctl_t cuse_client_ioctl; > @@ -141,6 +150,7 @@ > static d_write_t cuse_client_write; > static d_poll_t cuse_client_poll; > static d_mmap_t cuse_client_mmap; > +static d_kqfilter_t cuse_client_kqfilter; > > static struct cdevsw cuse_client_devsw = { > .d_version = D_VERSION, > @@ -153,6 +163,7 @@ > .d_write = cuse_client_write, > .d_poll = cuse_client_poll, > .d_mmap = cuse_client_mmap, > + .d_kqfilter = cuse_client_kqfilter, > }; > > static d_open_t cuse_server_open; > @@ -635,6 +646,10 @@ > > cuse_server_free_memory(pcs); > > + seldrain(&pcs->selinfo); > + > + knlist_destroy(&pcs->selinfo.si_note); > + > cuse_unlock(); > > cv_destroy(&pcs->cv); > @@ -662,6 +677,8 @@ > > cv_init(&pcs->cv, "cuse-server-cv"); > > + knlist_init_mtx(&pcs->selinfo.si_note, &cuse_mtx); > + > cuse_lock(); > pcs->refs++; > TAILQ_INSERT_TAIL(&cuse_server_head, pcs, entry); > @@ -1698,3 +1715,38 @@ > > return (0); > } > + > +static void > +cuse_client_kqfilter_detach(struct knote *kn) > +{ > + struct cuse_server *pcs; > + > + cuse_lock(); > + pcs = kn->kn_hook; > + knlist_remove(&pcs->selinfo.si_note, kn, 0); > + cuse_unlock(); > +} > + > +static int > +cuse_client_kqfilter_event(struct knote *kn, long hint) > +{ > + return (1); > +} > + > +static int > +cuse_client_kqfilter(struct cdev *dev, struct knote *kn) > +{ > + struct cuse_client *pcc; > + int error; > + > + error = cuse_client_get(&pcc); > + if (error != 0) > + return (error); > + > + cuse_lock(); > + kn->kn_hook = pcc->server; > + kn->kn_fop = &cuse_client_kqfilter_ops; > + knlist_add(&pcc->server->selinfo.si_note, kn, 0); > + cuse_unlock(); > + return (0); > +}