From owner-freebsd-bugs Sat Aug 31 18:50:15 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A8A7937B400 for ; Sat, 31 Aug 2002 18:50:02 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DEFBB43E7B for ; Sat, 31 Aug 2002 18:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g811o1JU065503 for ; Sat, 31 Aug 2002 18:50:01 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g811o1RQ065502; Sat, 31 Aug 2002 18:50:01 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0E0837B400 for ; Sat, 31 Aug 2002 18:49:11 -0700 (PDT) Received: from host217-41-34-37.in-addr.btopenworld.com (host217-41-34-37.in-addr.btopenworld.com [217.41.34.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1282343E6A for ; Sat, 31 Aug 2002 18:49:11 -0700 (PDT) (envelope-from dom@host217-41-34-37.in-addr.btopenworld.com) Received: by host217-41-34-37.in-addr.btopenworld.com (Postfix, from userid 1001) id 5419B4F9; Sun, 1 Sep 2002 02:49:22 +0100 (BST) Message-Id: <20020901014922.5419B4F9@host217-41-34-37.in-addr.btopenworld.com> Date: Sun, 1 Sep 2002 02:49:22 +0100 (BST) From: Dominic Marks Reply-To: Dominic Marks To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/42274: Convert defined variable into tuneable as suggested Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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