From owner-freebsd-current@FreeBSD.ORG Tue Apr 23 21:36:26 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9901060A for ; Tue, 23 Apr 2013 21:36:26 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) by mx1.freebsd.org (Postfix) with ESMTP id 32AD8108B for ; Tue, 23 Apr 2013 21:36:26 +0000 (UTC) Received: by mail-wi0-f173.google.com with SMTP id c10so6682010wiw.6 for ; Tue, 23 Apr 2013 14:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=bJy0hPZBxHoCe5xGdVsruTfwZ4fSsC9NXjEP7IACJ+U=; b=yIrksD4CzJijYIZ16tu9d3/gYS3m+5wlzU8L6GgzKi37FcaEABo+ij5VAfBMdT/ndQ Tgf5/UH2C04cxZ+SjpCeFAO2qD/mj+fSVbqoTzgVYYU30kLhCiIcvxoidMFLMtUD7ffo IdbCy1d/brMVIFfMDtSb5lmVvuk8Cz3FxHkfKkT6iY/dCB6cDKoyzh17lgTqgCx4Jv84 PW83I0uMmL7Q6VlzEVPBVULetj8chtZc+AT1YMuWtbe72VQmXYpT9XUvKEquEy2ebTLo avI+pOt4Qj5fD1VNpeIxMb32hXRWZLR4mn0cgttKRfngD9ob2gZ15nAUD11pYV2ovncX ODVA== X-Received: by 10.194.81.71 with SMTP id y7mr63945232wjx.19.1366752985125; Tue, 23 Apr 2013 14:36:25 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id g9sm263779wix.1.2013.04.23.14.36.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 23 Apr 2013 14:36:23 -0700 (PDT) Date: Tue, 23 Apr 2013 23:36:21 +0200 From: Mateusz Guzik To: Konstantin Belousov Subject: Re: sysvshm: replace Giant with a local sx lock Message-ID: <20130423213621.GB6346@dft-labs.eu> References: <20130423203823.GA6346@dft-labs.eu> <20130423205532.GE67273@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20130423205532.GE67273@kib.kiev.ua> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Apr 2013 21:36:26 -0000 On Tue, Apr 23, 2013 at 11:55:32PM +0300, Konstantin Belousov wrote: > On Tue, Apr 23, 2013 at 10:38:23PM +0200, Mateusz Guzik wrote: > > I would like to replace Giant with a local sx lock in sysvshm code. > > Looked really straightforward so maybe I missed something. > > At very least, the shmget_existing() is no longer functional. > The sx is owned around tsleep(), and thus a progress cannot be made > by other thread, which needs the same sx lock. > > Use of the SHMSEG_REMOVED in the shmget_allocate_segment() does > not make any sense in your patch, since sleeping malloc allocation > owns sx and prevent other threads from finding the segment. > > I did not looked further. Thank you for review, I definitely skimmed too fast. Looks like this code has some bugs as it is already, e.g. kern_shmat does not re-check for NULL p->p_vmspace->vm_shm after malloc. I will respin in a couple of days with a better patch. -- Mateusz Guzik