From owner-freebsd-arch@freebsd.org Sun Apr 30 09:16:48 2017 Return-Path: Delivered-To: freebsd-arch@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 C95BED57C0F for ; Sun, 30 Apr 2017 09:16:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46E1615FD for ; Sun, 30 Apr 2017 09:16:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v3U9GcrD001984 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 30 Apr 2017 12:16:39 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v3U9GcrD001984 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v3U9GcZY001983; Sun, 30 Apr 2017 12:16:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 30 Apr 2017 12:16:38 +0300 From: Konstantin Belousov To: Drake Talley Cc: freebsd-arch@freebsd.org Subject: Re: sysctl for named posix semaphores Message-ID: <20170430091638.GR1622@kib.kiev.ua> References: <20170429154018.GA3703@kunai.nyc.rr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170429154018.GA3703@kunai.nyc.rr.com> User-Agent: Mutt/1.8.2 (2017-04-18) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Apr 2017 09:16:48 -0000 On Sat, Apr 29, 2017 at 11:40:18AM -0400, Drake Talley wrote: > I'm interested in being able to display information about all active named POSIX > semaphores. I have not been able to find a sane way to do this, and > unless there's something obvious I've missed, There is no way to do this ... > it may be worth > considering building a sysctl or some other interface for accessing this > information. A while back in the mailing list there seems to have been ... be it sysctl or any other word. > some discussion about building out a "semfs" or some other file system > interface akin to /dev/shm in Linux, but there were concerns about the > POSIX compatibility of that approach. > > On a related note in /src/sys/kern/uipc_shm.c there is the following > TODO: > > * (1) Need to export data to a userland tool via a sysctl. Should ipcs(1) > * and ipcrm(1) be expanded or should new tools to manage both POSIX > * kernel semaphores and POSIX shared memory be written? > > > So, it's been acknowledged that a sysctl or some new utility is on the > table, and exporting this data to userland isn't blasphemous, although > perhaps not the most pressing need at the moment. Setting Sys V IPC on > the side, has there been discussion or consideration of similar tools > for POSIX semaphores? No, such discussion does not make sense, see below. > > > > Whether or not it's deemed worth doing, I'd appreciate any info or > references to discussions about this topic since I'm like > to tinker with it on my own if nothing else. The current POSIX semaphores implementation is mostly userspace, see the lib/libc/gen/sem_new.c source file for details. From the birds view, a POSIX semaphore is constructed from the shared mapping of a file in /tmp (presumably tmpfs-backed), and some umtx(2) features to assist in implementing the acquisition and release operations. Kernel does not provide complete abstracted object for semaphores. In other words, there is no way for kernel to enumerate userspace entities which semaphores are. The implementation in sys/kern/uipc_sem.c AKA sem.ko is obsoleted ('legacy') and is provided for ABI compatibility with <= 8.x libc.