From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 12 19:13:22 2010 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 EC75F106564A for ; Sun, 12 Dec 2010 19:13:21 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-fx0-f49.google.com (mail-fx0-f49.google.com [209.85.161.49]) by mx1.freebsd.org (Postfix) with ESMTP id 7D6A28FC19 for ; Sun, 12 Dec 2010 19:13:21 +0000 (UTC) Received: by fxm19 with SMTP id 19so5124924fxm.36 for ; Sun, 12 Dec 2010 11:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:reply-to :in-reply-to:references:date:message-id:subject:from:to:cc :content-type; bh=GRDszQ6eCVd/26ffoAuy746jij4mO1Pvg8jkm8rChm8=; b=ZAh0oQ4UbYgKeEYUIpY31pXFZXsYAjoPSKfStVNPsFNusmsnqUHxC9QwI6+zDDx/2F fxP/Hj72fZQNjuCO2II1JhUPEWWlV20ojEc3njYfJ2rdQWIlhCwQc2wjZ2E9xS/urAsa D11NwmQWSRoVZHPapiFdEdkVugkqYeczt8RZc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=cck5YpMYyfYaznU3o4ooBpcPyZP31800j5DkgC5TiNcT/4LwUPigh6ZEqa6PoyJQj4 /bHAck5M0QHYWbjUOBVY/8TbfU8jARHa7Bc+DP6YExG2PgnFBXD0x2KuWsw+eQxpHaKI cPVBHyo6t5nqqD1IdYGmw1NJeuh3Qw2cXqbXc= MIME-Version: 1.0 Received: by 10.223.53.68 with SMTP id l4mr3589669fag.44.1292179700811; Sun, 12 Dec 2010 10:48:20 -0800 (PST) Received: by 10.223.116.205 with HTTP; Sun, 12 Dec 2010 10:48:20 -0800 (PST) In-Reply-To: References: Date: Sun, 12 Dec 2010 12:48:20 -0600 Message-ID: From: Alan Cox To: Venkatesh Srinivas Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: i386 pmap_zero_page() late sched_pin()? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: alc@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Dec 2010 19:13:22 -0000 On Sun, Dec 12, 2010 at 10:40 AM, Venkatesh Srinivas < vsrinivas@dragonflybsd.org> wrote: > Hi, > > In the i386 pmap's pmap_zero_page(), there is a fragment... > > sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; > mtx_lock(&sysmaps->lock); > * sched_pin(); > /*map the page we mean to zero at sysmaps->CADDR2*/ > pagezero(sysmaps->CADDR2); > sched_unpin(); > > I don't know this bit of code too well, so I don't know if the sched_pin() > being where it is is okay or not. My first reading says its not okay; if a > thread is moved to another CPU before it is able to pin, it will use the > wrong sysmaps structure. Is this the case? Is it alright that the wrong > sysmap structure is used? > > Oh, Nathaniel Filardo (nwf@cs.jhu.edu) first spotted this, not I. > > This isn't a bug. There is nothing about the code that mandates that processor i must always use sysmap entry i. In the unlikely event that the thread migrates from processor X to processor Y before the sched_pin(), the mutex on sysmap entry X will prevent it from being used by processor X until processor Y is done with it. So, it doesn't matter to correctness that the "wrong" sysmap entry is used, and it is extremely unlikely to matter to performance. Alan