From owner-svn-src-head@freebsd.org Tue Dec 6 01:04:32 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD5A3C59F8B; Tue, 6 Dec 2016 01:04:32 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90A75E48; Tue, 6 Dec 2016 01:04:32 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 655BD10AA28; Mon, 5 Dec 2016 20:04:31 -0500 (EST) From: John Baldwin To: src-committers@freebsd.org Cc: svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309589 - head/usr.bin/truss Date: Mon, 05 Dec 2016 16:42:15 -0800 Message-ID: <18568727.ZCvfzOzSEO@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612060039.uB60d0eE075130@repo.freebsd.org> References: <201612060039.uB60d0eE075130@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 05 Dec 2016 20:04:31 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 01:04:32 -0000 On Tuesday, December 06, 2016 12:39:00 AM John Baldwin wrote: > Author: jhb > Date: Tue Dec 6 00:39:00 2016 > New Revision: 309589 > URL: https://svnweb.freebsd.org/changeset/base/309589 > > Log: > Rework syscall structure lookups. > > Avoid always using an O(n^2) loop over known syscall structures with > strcmp() on each system call. Instead, use a per-ABI cache indexed by > the system call number. The first 1024 system calls (which should cover > all of the normal system calls in currently-supported ABIs) use a flat array > indexed by the system call number to find system call structure. For other > system calls, a linked list of structures storing an integer to structure > mapping is stored in the ABI. The linked list isn't very smart, but it > should only be used by buggy applications invoking unknown system calls. > > This also fixes handling of unknown system calls which currently trigger > a NULL pointer dereference. > > Reviewed by: kib > MFC after: 2 weeks I of course forgot: Differential Revision: https://reviews.freebsd.org/D8639 The table + linked-list could perhaps be replaced by a hash table, but I don't quite feel like writing a new hash table from scratch. One option would be to make truss a C++ program and use unordered_map<>. We could then turn the procabi thing into a class which might look a bit nicer (and use constructors to initialize the hash table instead of the inline STAILQ_HEAD_INITIALIZER). -- John Baldwin