From owner-freebsd-mips@FreeBSD.ORG Wed Feb 19 18:12:59 2014 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BDDF6CEB for ; Wed, 19 Feb 2014 18:12:59 +0000 (UTC) Received: from mail-ig0-f172.google.com (mail-ig0-f172.google.com [209.85.213.172]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 84E6B138E for ; Wed, 19 Feb 2014 18:12:59 +0000 (UTC) Received: by mail-ig0-f172.google.com with SMTP id h3so1596482igd.5 for ; Wed, 19 Feb 2014 10:12:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=bnHhvgBAG3CNSUwNsaaGpkRGK6UaAmTVLr0xzfbllDg=; b=SP9jy6PMS0UTHOT3RVcQo4jcbvNkjmynDsb0KGBnCZGYqCmXzGQ2sYFsx0qT+AIrmf vSIfNdiq1PISeZ/NZgkhQ3/SOiWb8vIJxKLdKbYDVi74GeE6Y5Ggpyegznx8XIxQus0N 6QDErFwKBdmXLLc/AJgjx3BVg3IZs141tkJsCDUx6EFTurPUu9qly/v12XsK9r6UNOOw Qx0lG0U9b30OHjLOCkCNDUdiPdHaYSQXt5wBv5W1GeEZP62pr8OAIvs3PKBVEJXwgclw EltYHrP2wFfIyzfD/4ft49+0hvEARu4zGeFpMnt8gwEpW0YbIFddJJb5uD+HehYCAn/J H9qA== X-Gm-Message-State: ALoCoQnQc/khy1sR+lZPX01xvwwVIpr95N4G3TynfljefUbTO4aSxG9Ed47ZttHQXNHfK/O4b3s2 X-Received: by 10.50.61.147 with SMTP id p19mr2506408igr.49.1392833573135; Wed, 19 Feb 2014 10:12:53 -0800 (PST) Received: from macmini.bsdimp.com (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPSA id pn6sm3231067igb.4.2014.02.19.10.12.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 10:12:52 -0800 (PST) Subject: Re: [RFC] Enable use of UserLocal Register (ULRI) if detected (patches) Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: Date: Wed, 19 Feb 2014 11:12:51 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <092B0786-EA73-44D0-81FC-DFB56B14D4D7@bsdimp.com> To: Robert Watson X-Mailer: Apple Mail (2.1085) Cc: "freebsd-mips@freebsd.org" X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Feb 2014 18:12:59 -0000 On Feb 19, 2014, at 11:01 AM, Robert Watson wrote: > On Wed, 19 Feb 2014, Warner Losh wrote: >=20 >>> For more information about the ULRI see "MIPS Architecture for = Programmers Volume III" section 9.9 UserLocal Register (CP0 Register 4, = Select 2). >>=20 >> Thanks for doing this! >=20 > I would note, BTW, that the current use of TLS in malloc()/free() and = today's MIPS exception handler for TLS implementation do introduce a = very measurable overhead. I'm left wondering if there is something we = can do for unthreaded processes to avoid taking kernel traps on every = memory allocation and free for MIPSes without ULRI. (Note that that = problem is present before Stacey's patch: the reason we added ULRI = support is that our hardware does support ULRI, and we can therefore = avoid that nasty overhead ...) I understand there's work on a new MIPS = ABI that specifies a TLS register not requiring a trap to read on = non-ULRI hardware, but I'm not sure how far that is from being = available. Certainly it will require compiler/OS/etc work before it = becomes useful to us. One could easily have a global, static TLS value that gets set at = startup, and cleared when the first thread is forked. The gettls calls = then become something akin to if (global_tls) return global_tls; else return _get_tls(); without changes to the ABI at all... Warner