From owner-freebsd-current@FreeBSD.ORG Sat Mar 21 01:00:49 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6E4374DA; Sat, 21 Mar 2015 01:00:49 +0000 (UTC) Received: from mail-wg0-x22b.google.com (mail-wg0-x22b.google.com [IPv6:2a00:1450:400c:c00::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 135158D8; Sat, 21 Mar 2015 01:00:49 +0000 (UTC) Received: by wgbcc7 with SMTP id cc7so102165266wgb.0; Fri, 20 Mar 2015 18:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yOzA4tTs9EG9FpYpB6Q8LsIKrgipq4PA5GLsmZ2Cevo=; b=kWp2bks7gnv3Z4/QWcCpf8LfUsv7SVzKwkl03s3ClKPwb/4wO3ZIAp8ivSNhEeOzSH xRFGm69cYC/1fBz/9YsNqEbktacZw/9w8kBEofmkaaVERAM8ugQ8gDVL0lrlQefoOW9X kRRJ1sg6yDIgu8bPb92v5eHsboc3oOSWXj0nshxp3Q0TNlv9UrYjkWljabsi8sAcZvRS zg3eYePkMhNOiY3AF18ay6wWUqsVU3yuWPsrs5/WLhxpFjCdnD4aYO3ZHtPMW+azVX6j HTkIQNQB5cFpn5JleIfu2Fnb7ksZgjSxq4j4pvoO1SHTg91UE5ltJOu9xQUTKFG8dqlU U0CA== X-Received: by 10.180.75.233 with SMTP id f9mr654333wiw.5.1426899647587; Fri, 20 Mar 2015 18:00:47 -0700 (PDT) Received: from localhost.localdomain (ip-89-176-114-84.net.upcbroadband.cz. [89.176.114.84]) by mx.google.com with ESMTPSA id q6sm303207wix.3.2015.03.20.18.00.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Mar 2015 18:00:46 -0700 (PDT) From: Mateusz Guzik To: Konstantin Belousov Subject: [PATCH 3/3] proc: use MTX_NEW flag in proc_init Date: Sat, 21 Mar 2015 02:00:40 +0100 Message-Id: <1426899640-6599-4-git-send-email-mjguzik@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1426899640-6599-1-git-send-email-mjguzik@gmail.com> References: <20150320122125.GP2379@kib.kiev.ua> <1426899640-6599-1-git-send-email-mjguzik@gmail.com> Cc: freebsd-current@freebsd.org, jenkins-admin@freebsd.org, Mateusz Guzik X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sat, 21 Mar 2015 01:00:49 -0000 From: Mateusz Guzik This allows us to get rid of bzero which was added specifically to make mtx_init on p_mtx reliable. This also fixes a potential problem where mtx_init on other mutexes could trip over on unitialized memory and fire an assertion. --- sys/kern/kern_proc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index a607d7b1..f72269d 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -225,12 +225,11 @@ proc_init(void *mem, int size, int flags) p = (struct proc *)mem; SDT_PROBE(proc, kernel, init, entry, p, size, flags, 0, 0); p->p_sched = (struct p_sched *)&p[1]; - bzero(&p->p_mtx, sizeof(struct mtx)); - mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK); - mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN); - mtx_init(&p->p_statmtx, "pstatl", NULL, MTX_SPIN); - mtx_init(&p->p_itimmtx, "pitiml", NULL, MTX_SPIN); - mtx_init(&p->p_profmtx, "pprofl", NULL, MTX_SPIN); + mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK | MTX_NEW); + mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN | MTX_NEW); + mtx_init(&p->p_statmtx, "pstatl", NULL, MTX_SPIN | MTX_NEW); + mtx_init(&p->p_itimmtx, "pitiml", NULL, MTX_SPIN | MTX_NEW); + mtx_init(&p->p_profmtx, "pprofl", NULL, MTX_SPIN | MTX_NEW); cv_init(&p->p_pwait, "ppwait"); cv_init(&p->p_dbgwait, "dbgwait"); TAILQ_INIT(&p->p_threads); /* all threads in proc */ -- 2.3.2