From owner-freebsd-current Fri Jan 10 5:42:51 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3846037B401; Fri, 10 Jan 2003 05:42:49 -0800 (PST) Received: from smtp04.iprimus.com.au (smtp04.iprimus.com.au [210.50.76.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AB9743F5F; Fri, 10 Jan 2003 05:42:47 -0800 (PST) (envelope-from tim@robbins.dropbear.id.au) Received: from smtp02.iprimus.net.au (210.50.76.70) by smtp04.iprimus.com.au (6.7.010) id 3DF583C3002FB61C; Sat, 11 Jan 2003 00:42:43 +1100 Received: from dilbert.robbins.dropbear.id.au ([203.134.172.21]) by smtp02.iprimus.net.au with Microsoft SMTPSVC(5.0.2195.5600); Sat, 11 Jan 2003 00:42:40 +1100 Received: from dilbert.robbins.dropbear.id.au (h4omihiehuvjaac4@localhost [127.0.0.1]) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6) with ESMTP id h0ADgSlk036451; Sat, 11 Jan 2003 00:42:32 +1100 (EST) (envelope-from tim@dilbert.robbins.dropbear.id.au) Received: (from tim@localhost) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6/Submit) id h0ADgQPU036450; Sat, 11 Jan 2003 00:42:26 +1100 (EST) (envelope-from tim) Date: Sat, 11 Jan 2003 00:42:26 +1100 From: Tim Robbins To: Juli Mallett Cc: current@FreeBSD.org, re@FreeBSD.org Subject: Re: Serious issues with kqueue on sockets on CURRENT. Message-ID: <20030111004226.A36261@dilbert.robbins.dropbear.id.au> References: <20030110013015.A23399@FreeBSD.org> <20030110215736.A31727@dilbert.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030110215736.A31727@dilbert.robbins.dropbear.id.au>; from tjr@FreeBSD.org on Fri, Jan 10, 2003 at 09:57:36PM +1100 X-OriginalArrivalTime: 10 Jan 2003 13:42:41.0492 (UTC) FILETIME=[25A0F140:01C2B8AE] Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Jan 10, 2003 at 09:57:36PM +1100, Tim Robbins wrote: > On Fri, Jan 10, 2003 at 01:30:16AM -0800, Juli Mallett wrote: > > > Lately, the data field for sockets, which holds bytes ready (in the EVFILT_ > > READ case) to be read, is computed to be zero. This means that if you have > > a low watermark which is >0 per the kq, THE EVENT WILL NEVER HAPPEN. Not to > > mention that this means when the event IS triggered properly (if you can > > call it that), it is always said to have =ZERO= bytes ready. > [...] > > I can definitely reproduce this here and also fairly angry about it. > In addition to what you mentioned, fstat() gives an incorrect st_size > result now and it's likely that non-NOTE_LOWAT low watermarks are > firing too early as well. > > Ugly test program @ http://people.freebsd.org/~tjr/kq.c From what I can tell, mbufs with m_type == MT_HEADER can store data as well as those with m_type == MT_DATA. This patch corrects the tests in sbcompress(), sbdrop(), sballoc() and sbfree() so that data stored in MT_HEADER mbufs is not included in sb_ctl. I'd appreciate comments from people who have a good understanding of this code. Index: sys/kern/uipc_socket2.c =================================================================== RCS file: /x/freebsd/src/sys/kern/uipc_socket2.c,v retrieving revision 1.106 diff -u -r1.106 uipc_socket2.c --- sys/kern/uipc_socket2.c 5 Nov 2002 18:52:25 -0000 1.106 +++ sys/kern/uipc_socket2.c 10 Jan 2003 13:33:11 -0000 @@ -705,7 +705,8 @@ (unsigned)m->m_len); n->m_len += m->m_len; sb->sb_cc += m->m_len; - if (m->m_type != MT_DATA) /* XXX: Probably don't need.*/ + if (m->m_type != MT_DATA && m->m_type != MT_HEADER) + /* XXX: Probably don't need.*/ sb->sb_ctl += m->m_len; m = m_free(m); continue; @@ -776,7 +777,7 @@ m->m_len -= len; m->m_data += len; sb->sb_cc -= len; - if (m->m_type != MT_DATA) + if (m->m_type != MT_DATA && m->m_type != MT_HEADER) sb->sb_ctl -= len; break; } Index: sys/sys/socketvar.h =================================================================== RCS file: /x/freebsd/src/sys/sys/socketvar.h,v retrieving revision 1.98 diff -u -r1.98 socketvar.h --- sys/sys/socketvar.h 23 Dec 2002 22:46:47 -0000 1.98 +++ sys/sys/socketvar.h 10 Jan 2003 01:53:51 -0000 @@ -228,7 +228,7 @@ /* adjust counters in sb reflecting allocation of m */ #define sballoc(sb, m) { \ (sb)->sb_cc += (m)->m_len; \ - if ((m)->m_type != MT_DATA) \ + if ((m)->m_type != MT_DATA && (m)->m_type != MT_HEADER) \ (sb)->sb_ctl += (m)->m_len; \ (sb)->sb_mbcnt += MSIZE; \ if ((m)->m_flags & M_EXT) \ @@ -238,7 +238,7 @@ /* adjust counters in sb reflecting freeing of m */ #define sbfree(sb, m) { \ (sb)->sb_cc -= (m)->m_len; \ - if ((m)->m_type != MT_DATA) \ + if ((m)->m_type != MT_DATA && (m)->m_type != MT_HEADER) \ (sb)->sb_ctl -= (m)->m_len; \ (sb)->sb_mbcnt -= MSIZE; \ if ((m)->m_flags & M_EXT) \ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message