From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 30 07:54:11 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3EB2A16A4CE for ; Thu, 30 Oct 2003 07:54:11 -0800 (PST) Received: from mta8.adelphia.net (mta8.adelphia.net [68.168.78.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 630BB43F85 for ; Thu, 30 Oct 2003 07:54:10 -0800 (PST) (envelope-from andi_payn@speedymail.org) Received: from [10.1.0.9] ([68.65.235.109]) by mta8.adelphia.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031030155412.XIWF28250.mta8.adelphia.net@[10.1.0.9]> for ; Thu, 30 Oct 2003 10:54:12 -0500 From: andi payn To: freebsd-hackers@freebsd.org Content-Type: text/plain Message-Id: <1067529247.36829.2138.camel@verdammt.falcotronic.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 30 Oct 2003 07:54:07 -0800 Content-Transfer-Encoding: 7bit Subject: kevent and related stuff X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2003 15:54:11 -0000 First, let me mention that I'm not nearly as experienced coding for *BSD as for linux, so I may ask some stupid questions. I've been looking at the fam port, and this has brought up a whole slew of questions. I'm not sure if all of them are appropriate to this list, but I don't know who else to ask, so.... First, some background: On Irix and Linux, fam works by asking the kernel to send it a signal whenever the specified accesses occur. On FreeBSD, since there is no imon interface and no dnotify fcntl, it instead works by periodically stating all of the files it's watching--which is obviously not as good. The fam FAQ suggests that FreeBSD users should adapt fam to use the kevent interface. I looked into kevent, and it seems like there are a number of problems that lead me to suspect that this is a really stupid idea. And yet, I'd assume that someone on the fam team at SGI and/or one of the outside fam developers would know FreeBSD at least as well as me. Therefore, I'm guessing I'm missing something here. So, any ideas anyone can offer would be very helpful. So, here's the questions I have: * I think (but I'm not sure) that kevent doesn't notify at all if the only change to a file is its ATIME. If I'm right, this makes kevent completely useless for fam. Adding a NOTE_ACCESS or something similar would fix this. Since I'm pretty new to FreeBSD: What process do I go through to figure out whether anyone else wants this, whether the interface I've come up with is acceptable, etc.? And, once I write the code, do I submit it as a pr? * The kevent mechanism doesn't monitor directories in a sufficient way to make fam happy. If you change a file in a directory that you're watching, unlike imon or dnotify, kevent won't see anything worth reporting at all. This means that for directory monitoring, kevent is useless as-is. Again, if I wanted to patch kevent to provide this additional notification, would others want this? * When two equivalent events appear in the queue, kevent aggregates them. This means that if there are two updates to a file since the last time you checked, you'll only see the most recent one. For some uses of fam (keeping a folder window up to date), this is what you want; for others (keeping track of how often a file is read), this is useless. The only solution I can think of is to add an additional flag, or some other way to specify that you want duplicated events. * Unlike imon and dnotify, kevent doesn't provide any kind of callback mechanism; instead, you have to poll the queue for events. Would it be useful to specify another flag/parameter that would tell the kernel to signal the monitoring process whenever an event is available? (It would certainly make the fam code easier to write--but if it's not useful anywhere else, that's probably not enough.) * The kevent vnode stuff apparently only works on UFS. And it looks like it would be a major project to port it to other filesystems. Would this be useful for anything other than improving fam? What about a port of the imon kernel interface (and/or the dnotify fcntl) to FreeBSD instead? * The kqueue doesn't appear to have any maximum size. If this is true, the dnotify/fam problem where you get hideous errors from overflowing queues wouldn't be an issue, but you could instead end up wasting massive amounts of memory in the kernel if you didn't get around to reading the queue.... Which is it? Any answers, or pointers to where I can find these answers, would be greatly appreciated.