From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 30 14:44:14 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DBC6D895 for ; Tue, 30 Apr 2013 14:44:14 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 9B82E16F9 for ; Tue, 30 Apr 2013 14:44:14 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id B6258359305 for ; Tue, 30 Apr 2013 16:44:11 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 9D6F428493; Tue, 30 Apr 2013 16:44:11 +0200 (CEST) Date: Tue, 30 Apr 2013 16:44:11 +0200 From: Jilles Tjoelker To: freebsd-hackers@freebsd.org Subject: Re: SystemV IPC. Segment info Message-ID: <20130430144411.GA1002@stack.nl> References: <20130430034940.GA8305@vagner-wrk.bsdway.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130430034940.GA8305@vagner-wrk.bsdway.ru> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Apr 2013 14:44:14 -0000 On Tue, Apr 30, 2013 at 07:49:40AM +0400, Vagner wrote: > Tell me please, may I send this to PR, or this changes is not valid? > > A few weeks ago, I ran into problem, which related to SystemV IPC. > > More than 20 processes attached to a segment shared queue. > > Process-initiator for create segment was killed, as process which > > was accessed to segment last. Segment didn't free memory, but tagged > > it as SHMSEG_REMOVED as the result. This is a reason of memory > > overflow (memory assotiated as shm). Moreover, processes, which was > > attached to this segment did't get a new data. I have one resolve. I > > need to restarted all process, which still attached to segment. But > > this reason have a problem. We haven't list of this processes at > > system. Moreover, struct shmid_ds, which described segment, haven't > > this info too. > > This patch is a resolve of problem. It: > > - added a linked list of structures shmid_pi in struct shmid_ds. PID > > (and last access time) recorded to this struct consistently. Memory > > allocates with ident 'shminfo' for this list of struct shmid_pi. > > - added syscall shminf for get all elements from list shmid_ds. > > - added option [-P] in ipcs(1) for system call shminf. I think it is strange to maintain pids in the VM system. This makes the VM system more complex for little reason (because the information is only needed for monitoring, not normal operation). Perhaps it is possible to do what you want using procstat -v or a slight extension to it. Alternatively, you may find a different way to get rid of your stale worker processes. For example, before invoking shmctl(IPC_RMID), set a flag inside the memory segment that all workers should exit and activate whatever mechanism you use for telling the workers that they need to do something. -- Jilles Tjoelker