Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4514801imm; Tue, 11 Sep 2018 13:08:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYRMUnhgQ8jW2Y/4P1Oqrx3VC4pyXypmqIP/N29/3L4nyLUrerxW+vwC7Y1ZbaXQnvx3iFR X-Received: by 2002:a17:902:47:: with SMTP id 65-v6mr28541890pla.293.1536696490042; Tue, 11 Sep 2018 13:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536696490; cv=none; d=google.com; s=arc-20160816; b=kB00faFnnT0fjkkdrfqGa6SO4emaliBralnATWNPfX7snUsAN8xICXQMTe4SP1IEgu FzZVTfeQlw7q56rdE7mlCAW4osWFv6AAttG9ceuD5aj46OV+PYoi1WqRgvuElg35go6R u3wMhdOEngL0aX82Is6Sou2VMKbsbA6CX+VRLUfF7IqdUvxi56a4bMR/bhM10S6hGSNU hn1uthjOh5/EiYigFYylmx/N87E0dyhY4wzllcRAzR379g06H3LpuU7Wmd4AJlAoOqEx /8eKGU6RdzUfpSBpFonb1x+eLqHb/id4ur8SpOR7mYEUUPy2p2KLKNkeCQJdMpjzCi5h vMvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=12bWM5xbpcE8wvot7dKTA+v6C3IW0HvRqixeaZZGs1A=; b=UEUaQ+ZvzhoV5aAHZKTfz4zPjI9ymFBveg2EDwvLQcCXzac0uQHOl/HM0OcT589qPR WNDKZzH7WpAnOApfZKygnSCuifoEf6CQ5HY258nTOGlAyFLu4SGiqCiQxhX2Hz6lBPUj Zw+bl14OZTNSCtVWBLX8iytwH8QSQdV4NC+OvaJ56LAY8R/Hj6457EaIy/VWK56o7bI3 x+cOsAV6z4TVrPVYgMNxunObZk3WG6hrRfVfz0+de6qf1whkb0+9hBqMiRFL/TvSWkdu T1ja1a5j189aipH65luvGqpQ6fSiQc2Z7kagLJBZqh4YV0FkLGM+r310vYrSm9Z7jgG/ zmNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=q866NSoJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si21902399pla.129.2018.09.11.13.07.55; Tue, 11 Sep 2018 13:08:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=q866NSoJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728018AbeILBGi (ORCPT + 99 others); Tue, 11 Sep 2018 21:06:38 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:52883 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbeILBGh (ORCPT ); Tue, 11 Sep 2018 21:06:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1536696345; x=1568232345; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=jQTZ23SgNKhmVMpyXw8suw05ppQjTGFZ9dEM3MSqxbk=; b=q866NSoJ7bFeFuVZF27K3QR7IuOqbMOzWrATqSu2Lso7Vv+nlym5V06b uVTATHQPv5+tTUODi3PwyDahxcQsMW4VGzPqI4G/zLg432SjhrmkraBeM KxdOlaynbYwj90o/dXueRCkQqxaiQ7vp+jxQDpKZMYSuZqIA1SIl/uWtN faJqzkE4mm97DpE8RITC7hvxzLZn6MnObhNoP+9bbbuje16WpvT3+yOvT EU2j+eyonxJodH8UcR1x2b25BXIPvhzXtmzgxYoQBkMTLVMgzoUXvDpnx blAW2XcB2E74x8ifZrZAo3vBU2GcIzO+Hef2/REd+H7HDPnh705gS0vZm g==; X-IronPort-AV: E=Sophos;i="5.53,361,1531756800"; d="scan'208";a="193728839" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Sep 2018 04:05:43 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 11 Sep 2018 12:52:17 -0700 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 11 Sep 2018 13:05:44 -0700 From: Atish Patra To: palmer@sifive.com, linux-riscv@lists.infradead.org Cc: mark.rutland@arm.com, hch@infradead.org, anup@brainfault.org, atish.patra@wdc.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, Damien.LeMoal@wdc.com, marc.zyngier@arm.com, jeremy.linton@arm.com, gregkh@linuxfoundation.org, jason@lakedaemon.net, catalin.marinas@arm.com, dmitriy@oss-tech.org, ard.biesheuvel@linaro.org Subject: [PATCH v4 10/12] RISC-V: User WRITE_ONCE instead of direct access Date: Tue, 11 Sep 2018 13:05:37 -0700 Message-Id: <1536696339-15204-11-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536696339-15204-1-git-send-email-atish.patra@wdc.com> References: <1536696339-15204-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The secondary harts spin on couple of per cpu variables until both of these are non-zero so it's not necessary to have any ordering here. However, WRITE_ONCE should be used to avoid tearing. Signed-off-by: Atish Patra Reviewed-by: Christoph Hellwig --- arch/riscv/kernel/smpboot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 17e74831..1e478615 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -81,8 +81,9 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle) * the spinning harts that they can continue the boot process. */ smp_mb(); - __cpu_up_stack_pointer[cpu] = task_stack_page(tidle) + THREAD_SIZE; - __cpu_up_task_pointer[cpu] = tidle; + WRITE_ONCE(__cpu_up_stack_pointer[cpu], + task_stack_page(tidle) + THREAD_SIZE); + WRITE_ONCE(__cpu_up_task_pointer[cpu], tidle); while (!cpu_online(cpu)) cpu_relax(); -- 2.7.4