Date: Sun, 1 Sep 2002 02:49:22 +0100 (BST) From: Dominic Marks <dominic_marks@btinternet.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/42274: Convert defined variable into tuneable as suggested Message-ID: <20020901014922.5419B4F9@host217-41-34-37.in-addr.btopenworld.com>
next in thread | raw e-mail | index | archive | help
>Number: 42274
>Category: kern
>Synopsis: Convert defined variable into tuneable as suggested
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Aug 31 18:50:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Dominic Marks
>Release: FreeBSD 4.6-STABLE i386
>Organization:
National Physical Laboratory, UK
>Environment:
System: FreeBSD gallium 4.6-STABLE FreeBSD 4.6-STABLE #2:
Sun Sep 1 02:15:28 BST 2002 dom@gallium:/usr/obj/usr/src/sys/GENERIC i386
>Description:
In kern_event.c the following line currently exists:
#define KN_HASHSIZE 64 /* XXX should be tunable */
I have created another sysctl using the same naming scheme which
is used elsewhere in the file which implements (I believe) what
the comment suggests.
>How-To-Repeat:
I have successfully built and tested a 4.6-STABLE kernel with
the small diff below, it seems to work as expected:
> sysctl kern | grep kq_
kern.kq_calloutmax: 4096
kern.kq_hashsize: 128
(the default is still 64, but I wanted to test with a different
size so I modified this in loader.conf)
A test application for kqueue that I have written works as it is
expected to also:
> ./kqtest
im going to make a new kqueue
now i am going to wait for events on that queue
(here it blocks for events as expected)
I have supplied diffs against -CURRENT and -STABLE below.
Thanks.
>Fix:
Against -CURRENT:
Index: kern_event.c
===================================================================
RCS file: /media/cvs/freebsd/src/sys/kern/kern_event.c,v
retrieving revision 1.45
diff -u -3 -p -r1.45 kern_event.c
--- kern_event.c 17 Aug 2002 02:36:16 -0000 1.45
+++ kern_event.c 1 Sep 2002 01:35:26 -0000
@@ -111,8 +111,12 @@ static struct filterops timer_filtops =
static uma_zone_t knote_zone;
static int kq_ncallouts = 0;
static int kq_calloutmax = (4 * 1024);
+static int kq_hashsize = 64;
+
SYSCTL_INT(_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW,
&kq_calloutmax, 0, "Maximum number of callouts allocated for kqueue");
+SYSCTL_INT(_kern, OID_AUTO, kq_hashsize, CTLFLAG_RW, &kq_hashsize, 0,
+ "Size of the KNote hash used by kqueue");
#define KNOTE_ACTIVATE(kn) do { \
kn->kn_status |= KN_ACTIVE; \
@@ -120,7 +124,6 @@ SYSCTL_INT(_kern, OID_AUTO, kq_calloutma
knote_enqueue(kn); \
} while(0)
-#define KN_HASHSIZE 64 /* XXX should be tunable */
#define KN_HASH(val, mask) (((val) ^ (val >> 8)) & (mask))
static int
@@ -960,7 +963,7 @@ knote_attach(struct knote *kn, struct fi
if (! kn->kn_fop->f_isfd) {
if (fdp->fd_knhashmask == 0)
- fdp->fd_knhash = hashinit(KN_HASHSIZE, M_KQUEUE,
+ fdp->fd_knhash = hashinit(kq_hashsize, M_KQUEUE,
&fdp->fd_knhashmask);
list = &fdp->fd_knhash[KN_HASH(kn->kn_id, fdp->fd_knhashmask)];
goto done;
Against -STABLE:
Index: kern_event.c
===================================================================
RCS file: /media/cvs/freebsd/src/sys/kern/kern_event.c,v
retrieving revision 1.2.2.8
diff -u -3 -p -r1.2.2.8 kern_event.c
--- kern_event.c 14 Dec 2001 19:24:42 -0000 1.2.2.8
+++ kern_event.c 1 Sep 2002 01:45:37 -0000
@@ -108,8 +108,13 @@ static struct filterops timer_filtops =
static vm_zone_t knote_zone;
static int kq_ncallouts = 0;
static int kq_calloutmax = (4 * 1024);
-SYSCTL_INT(_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW,
- &kq_calloutmax, 0, "Maximum number of callouts allocated for kqueue");
+static int kq_hashsize = 64;
+
+SYSCTL_INT(_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW, &kq_calloutmax,
+ 0, "Maximum number of callouts allocated for kqueue");
+SYSCTL_INT(_kern, OID_AUTO, kq_hashsize, CTLFLAG_RW, &kq_hashsize, 0,
+ "Size of the KNote hash used by kqueue");
+
#define KNOTE_ACTIVATE(kn) do { \
kn->kn_status |= KN_ACTIVE; \
@@ -117,7 +122,6 @@ SYSCTL_INT(_kern, OID_AUTO, kq_calloutma
knote_enqueue(kn); \
} while(0)
-#define KN_HASHSIZE 64 /* XXX should be tunable */
#define KN_HASH(val, mask) (((val) ^ (val >> 8)) & (mask))
extern struct filterops aio_filtops;
@@ -873,7 +877,7 @@ knote_attach(struct knote *kn, struct fi
if (! kn->kn_fop->f_isfd) {
if (fdp->fd_knhashmask == 0)
- fdp->fd_knhash = hashinit(KN_HASHSIZE, M_KQUEUE,
+ fdp->fd_knhash = hashinit(kq_hashsize, M_KQUEUE,
&fdp->fd_knhashmask);
list = &fdp->fd_knhash[KN_HASH(kn->kn_id, fdp->fd_knhashmask)];
goto done;
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020901014922.5419B4F9>
