From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 6 02:28:13 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03E78106564A for ; Wed, 6 Apr 2011 02:28:13 +0000 (UTC) (envelope-from mrkotfw@gmail.com) Received: from mail-px0-f172.google.com (mail-px0-f172.google.com [209.85.212.172]) by mx1.freebsd.org (Postfix) with ESMTP id D53B18FC0A for ; Wed, 6 Apr 2011 02:28:12 +0000 (UTC) Received: by pxi6 with SMTP id 6so956882pxi.17 for ; Tue, 05 Apr 2011 19:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=Zgx1h6Z1Yuz9EiZ4Q5QES9RuaNVErOTpo3PtP3rIEHc=; b=s05kx3WcmZj0lcspn/O+8iMiubrOkMX37OekmfVUavJvCfPoqIjdPEpS5f1LcXjSix 6+GmC3jCXg1oAPwrgqW/sMAMlrhkW6UELr4eON49qrbSFSnHSLd9UtzMYTftdEtShnWQ I2A/VQkOAK4PtVNVMZ05xpZ/hYCseLkffOVzc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=w/QmUJWxkxjRx7ze4UnQEPHp83bVLPzftINX/P7NOJO9e0ypdRCIbVDVBam7MeDW57 YzoSurc9J8lHtfNrYIpzTs4QXnCZoKf/+/BcM7ADwGx1a7M50NgUATp8/ZzWsLAy2oB6 BakyI6fB4bUZiRJ2MlOqRyD2hVE2u5ccJy04s= Received: by 10.142.218.2 with SMTP id q2mr344348wfg.395.1302055244121; Tue, 05 Apr 2011 19:00:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.64.199 with HTTP; Tue, 5 Apr 2011 19:00:24 -0700 (PDT) From: Israel Jacques Date: Tue, 5 Apr 2011 19:00:24 -0700 Message-ID: To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 Subject: GSoC: Avoiding syscall overhead X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2011 02:28:13 -0000 Hello, I have sent a copy to one of the people listed as technical support (atillio@). My name is Israel Jacques and I'm an undergrad at the University of California, Berkeley. I am interested in working on removing overhead from the 'SETPROCTITLE(3)' library routine. I see that in the ideas page work has already begun to make this optimization. However, searching through the mailing lists I have not found much discussion on it. After looking through the archives (see references), I have some (crude) high level ideas as to how to approach the problem. The idea, as suggested is to have a shared page between the kernel and a userland process. Having such a shared page would avoid having to invoke sysctl() which causes a the large overhead of a context switch. The shared page 1. needs to be pinned as to avoid having it be paged out. 2. needs to stay alive for the entire duration of the process. 3. needs to be unique for every process. Initially, I was thinking that a shared page should be created for ALL processes, but that would expose vital information to all other processes. Furthermore, any other process can alter the information of another process. As suggested in [9], allocating memory and reserving some region of the process address space, pinning it, and setting the correct page permissions (permissions in the PTE?) would be enough to create such a shared page. Though, letting the process know of this page would require a system call. Again, suggested in reference [9] would add a section in the ELF which would then have a global variable of (potentially) a pointer to a struct with the process information. Of course, a process could mistakenly use the pointer to access outside the bounds of the page and cause trouble. Furthermore, checks need to be made to insure that the process itself doesn't corrupt the information in the struct. Also, for every access a mutex would be needed as to avoid possible race conditions between both the kernel and the process. I'll be looking to go through: src/sys/vm src/lib/libc/gen/setproctitle.c src/sys/kern/sysv_shm.c ...and the VM portion of the "4.4BSD" book. (I just received my FreeBSD book today!) References: [1] http://lists.freebsd.org/pipermail/freebsd-hackers/2009-October/029750.html [2] http://lists.freebsd.org/pipermail/freebsd-performance/2006-June/002038.html [3] http://lists.freebsd.org/pipermail/freebsd-stable/2006-October/029983.html [4] http://lists.freebsd.org/pipermail/freebsd-stable/2008-January/039392.html [5] http://lists.freebsd.org/pipermail/freebsd-performance/2008-January/003107.html [6] http://lists.freebsd.org/pipermail/freebsd-hackers/2008-March/023875.html [7] http://lists.freebsd.org/pipermail/freebsd-hackers/2005-November/014452.html [8] http://lists.freebsd.org/pipermail/freebsd-hackers/2011-February/034419.html [9] http://lists.freebsd.org/pipermail/freebsd-hackers/2005-November/014453.html