From owner-freebsd-arm@FreeBSD.ORG Tue Nov 26 09:36:09 2013 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5D7474E3 for ; Tue, 26 Nov 2013 09:36:09 +0000 (UTC) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1D52E2EF9 for ; Tue, 26 Nov 2013 09:36:08 +0000 (UTC) Received: by mail-vc0-f172.google.com with SMTP id hz11so3658039vcb.31 for ; Tue, 26 Nov 2013 01:36:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=K8uLi8MuuTWBRT11SvV5ijTNvaK2YDdQUojSbW5Cg2Q=; b=Igv7rVywVmdKNNxww7oMrbUkTo9yBlynSkjcMCiYLSCiNEsAgEkkNr+h3ddFIhhcaC sP7qpCVC3rvDpGPXoXmHXQrfJhWp6KGq9KyZdIYMBYEcejzxh/6j9FChTjin3TNHCRyy AIU0Khu8zgtOTXSSxkp5AWmfR8Ka/2v/IjgjW2iQBBZklYTl/XkV6969SI97mL58pBQH Es8mHvGPt9a7F5bihnj0TOtk+aZNMEbPNZ25Bb+e3kwFnL2JfumjfQSDzZXGpBHtNCPU SP5urzruTxXzPRW0rqi3m0QDiVIq9EsNs0DlK14giyK+2x/8P257VB4ckHAhsZ9cSYIa eHuQ== X-Gm-Message-State: ALoCoQmsxL2NQ5Zl8G/LWH44nfUMEv+Lv4EU/MD1lZkKtwBLhJ1avlgaaiZjVb2Ups/Rvd0f4jk6 MIME-Version: 1.0 X-Received: by 10.52.120.105 with SMTP id lb9mr314701vdb.59.1385458562482; Tue, 26 Nov 2013 01:36:02 -0800 (PST) Received: by 10.221.19.6 with HTTP; Tue, 26 Nov 2013 01:36:02 -0800 (PST) In-Reply-To: References: <20131122000457.GA44039@freebsd.org> Date: Tue, 26 Nov 2013 10:36:02 +0100 Message-ID: Subject: Re: arm SMP fix From: Wojciech Macek To: arm@freebsd.org Content-Type: multipart/mixed; boundary=089e013a1bae77ebd904ec113580 X-Content-Filtered-By: Mailman/MimeDel 2.1.16 Cc: Olivier Houchard X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Nov 2013 09:36:09 -0000 --089e013a1bae77ebd904ec113580 Content-Type: text/plain; charset=ISO-8859-1 Hi, Applying the patch is causing a failure on systems with more than 2 cores. get_pcpu() macro is masking cpuid with incorrect value, since the only last two bits of cp15 register contain the right value. Simple fix attached below. Regards, Wojtek 2013/11/25 Svatopluk Kraus > Hi, > > we use another approach to the problem at work for now. So, I have only one > comment. Can be explicitly stated in commit that PCPU_GET() is not needed > to be atomic? Otherwise, it will look that problem with curthread is solved > but similar problem with PCPU_GET() starts up. > > In fact, atomicity of PCPU_GET() must be ensured in code where is used. > > Svatopluk Kraus > > > On Fri, Nov 22, 2013 at 1:04 AM, Olivier Houchard >wrote: > > > Hi all, > > > > Attached is the first draft to a patch that fixes SMP for me, it seems to > > work fine on my Pandaboard. > > The problem is, as it is currently implemented, curthread is basically > > defined as get_pcpu()->pc_curthread. If we get interrupted between the > > moment > > we got the struct pcpu, and the moment we derefence it to get the > curthread > > pointer, and migrated to another core, we would get the wrong curthread, > > and > > that's not good. > > The proposed fix does the following : > > - use the register we used to use for pcpu for curthread > > - get the pcpu address by reading the cpu id from the CPUID register, and > > just use it as an index for the __pcpu array. > > > > It breaks the KBI, which is unfortunate, but I think it is no big deal > for > > arm right now. > > > > Any review, comment, and testing, even on UP boards, would be very > welcome. > > > > Regards, > > > > Olivier > > > > _______________________________________________ > > freebsd-arm@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" > > > _______________________________________________ > freebsd-arm@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" > --089e013a1bae77ebd904ec113580 Content-Type: text/x-patch; charset=US-ASCII; name="pcpu_cpu_mask.patch" Content-Disposition: attachment; filename="pcpu_cpu_mask.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hogxvv6h0 ZGlmZiAtLWdpdCBhL3N5cy9hcm0vaW5jbHVkZS9wY3B1LmggYi9zeXMvYXJtL2luY2x1ZGUvcGNw dS5oCmluZGV4IGQ3MTNkM2QuLjdhNDU5N2QgMTAwNjQ0Ci0tLSBhL3N5cy9hcm0vaW5jbHVkZS9w Y3B1LmgKKysrIGIvc3lzL2FybS9pbmNsdWRlL3BjcHUuaApAQCAtNjMsNyArNjMsNyBAQCBleHRl cm4gc3RydWN0IHBjcHUgKnBjcHVwOwogI2lmIEFSTV9BUkNIXzYgfHwgQVJNX0FSQ0hfN0EKIC8q IG9yIEFSTV9UUF9BRERSRVNTIAltYXJrIFJFTU9WRSBNRSBOT1RFICovCiAKLSNkZWZpbmUgQ1BV X01BU0sgKDB4MTUpCisjZGVmaW5lIENQVV9NQVNLICgweDMpCiAKICNkZWZpbmUgZ2V0X3BjcHUo KSBfX2V4dGVuc2lvbl9fICh7CQkJICAJCVwKIAlpbnQgaWQ7CQkJCQkJCQlcCg== --089e013a1bae77ebd904ec113580--