From owner-freebsd-arch@FreeBSD.ORG Fri Nov 26 01:44:08 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFCF6106564A for ; Fri, 26 Nov 2010 01:44:08 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 795CC8FC17 for ; Fri, 26 Nov 2010 01:44:08 +0000 (UTC) Received: by iwn39 with SMTP id 39so1750374iwn.13 for ; Thu, 25 Nov 2010 17:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=ovd3qwdqgx4o8HpAXVncPT1cNT8zcktJnjlCvRg4aME=; b=T6cm4quHDanp8hfQzpMM9DJAw8ivBEt5VhIZKDIs7MchNSgFGXNfnUORQUW8bqWmNb /61/zMoc7P7vlKxWPiv4bwa+HJECYSv9NipiV5xL/SOoVeyTyCCgpH23isR7h92qpyBr H3Xe3ctIp3wsfKohq3BNY2OY++6vYppMBNQYk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=XyC3LAD0MYNnSHUYgTcSkswRQ6FJc/DlrUcSR80WvEB7+dXAdUoXT2Evrepz+7mj8I Pve+xM17dqcptCL1/rc6GjKVMv4iVpVfD0eYiiN/XHB9teSB9X2MC58tn4ZUQhstPU68 BbEtNPShvxaElPRqeWTCn98SWtj15NocvwtmA= MIME-Version: 1.0 Received: by 10.231.10.69 with SMTP id o5mr888877ibo.122.1290735847806; Thu, 25 Nov 2010 17:44:07 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.231.21.35 with HTTP; Thu, 25 Nov 2010 17:44:07 -0800 (PST) Date: Thu, 25 Nov 2010 17:44:07 -0800 X-Google-Sender-Auth: X4sZmQVK3i8r6VtSDEwk6LzO4qc Message-ID: From: mdf@FreeBSD.org To: FreeBSD Arch Content-Type: text/plain; charset=ISO-8859-1 Subject: Fixing sysctl LOR X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2010 01:44:08 -0000 My previous thought on the matter was incorrect. This patch (and two small cleanups before it) mean the sysctl lock is no longer held across the call to oid_handler, which means that WITNESS will no longer make entries where sysctl lock is taken before any random lock in the handler. The idea is simple; keep track of the number of threads running the handler so that the oid is not deleted (and sysctl_ctx_free(9) doesn't return) before all threads are drained. It does unfortunately mean that the sysctl lock is only taken in exclusive mode, but since it's held for less time I don't anticipate a significant loss of concurrency. If there is a simple benchmark someone can recommend I'd be happy to check the difference. I would like at some point to also reduce the number of calls to sysctl(2) made by sysctl(8); this would also help performance. Among other things I wonder if eliminating the numerical array to describe an oid would be acceptable; in a few circumstances it would mean longer comparisons (strcmp versus integer comparison) but for many uses it eliminates the name2oid step, and it would also mean there's no longer a need for fixed numbered entries. Cleanup: http://people.freebsd.org/~mdf/0001-Use-the-SYSCTL_CHILDREN-macro-in-kern_sysctl.c-to-he.patch http://people.freebsd.org/~mdf/0002-Slightly-modify-the-logic-in-sysctl_find_oid-to-redu.patch The patch: http://people.freebsd.org/~mdf/0003-Do-not-hold-the-sysctl-lock-across-a-call-to-the-han.patch Thanks, matthew