Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp223255imm; Thu, 6 Sep 2018 01:08:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbVuVj9XsAZJZUjgmyB6vh5LfrJBuZImj68xJ4ZKTCCBErDYUMMBj4IARru6weUCeZL6Pir X-Received: by 2002:a63:f344:: with SMTP id t4-v6mr1579435pgj.428.1536221291821; Thu, 06 Sep 2018 01:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536221291; cv=none; d=google.com; s=arc-20160816; b=TLI7dkl25WMQzOgP9+WHZfGPaBu+MpBGHkFgjfZrjAk376U+S5cbtHNc7vIpT0cbDr hJKpqEamFYZBnN5i7yA0QBASfgd5TsMiiLjpxy+kQcADFh7YzYfnY8rTEJRbertlifll rqg4W00DqqsBsw/cO5whD4l0nyoAkpkPgWVHnoCd9wDHcxBoDCpNOTxJvTXyITVjseY8 89xLc9HHieUUhSi6PMUEP4CsJiAqwxsVIokqHli+fkHAMCNlvNK0Mnx15Aw1GZJWf021 UVgikq8bwqhDU/vC/0gi67bgDmC56qx7HdKwqwtEskfeYiSRBZGPq77SAHO+IcDFKUQx OBag== 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=3W8FPFm9hTKkQZ0mZufVDrE9yLVTn+9KBU8VAhNKjbg=; b=GS3LuxXaSxeR1mNTv4QZ3tZy/8KVecbBQnZnuS19V/W8M3pt49Ms/bsWMs9hsKabAM Vi3bRzPUtyQyBep4jJ6CndDw6Wg3SpA+7B7Qxh9u7j2uVHKID3U+JKN1ivUZG5DSSqzU mThZs1rdl37ZgS/azL2RUcud1ciOjkHztMJzfrKzV1nJBsl3OZ/b5eNE1JwGLZUPm92F 23R2vgbNrCpk5+zfDAMASei8TWq3ptJyWLr/e/ANbWpr16pq6PvFiqrMfGq3bCvoYbS/ uZE7tkeikSGoVqrpKDut/CoYttHhXFhI5NIaxNy5UceHR+bjXvZ+Fpfx/5YJURrbSirq R2Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=iMC7d6f6; 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 m14-v6si4660423pgc.368.2018.09.06.01.07.56; Thu, 06 Sep 2018 01:08:11 -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=iMC7d6f6; 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 S1728208AbeIFMkU (ORCPT + 99 others); Thu, 6 Sep 2018 08:40:20 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:53561 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728098AbeIFMju (ORCPT ); Thu, 6 Sep 2018 08:39:50 -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=1536221196; x=1567757196; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=uOUYB3c2aXjhey4FK/NTaJ04kB4BoeHIdDxL7BDR9mA=; b=iMC7d6f68GpLv5MVb5I5RPHlb9aEXJCEhIZyV825JzYjGi1sdewA2KC9 QSsH4vDCMigdlxyBLLjq57Q6gPMOeEbijS9CJxGc7DXS/4rJaeyzysfDp AldoMafuTgSYJ89Yp5vnpS0ewDg9iZEyEOpZ2+Gd2tDvLSFJTxa/DfOSF qLV9E/4nC9yTCaXeujFmm0bQFBGoxPp+uAKItFCZjhfz0asGbrUWk9U24 QkxN9UAItLTY9DFSOBwgc2JhhQlJOoNk5iKEg5oJhiiAwwBQ1lD/SJ+tr 4rL1GQvpBg3pS/EjzUJIr7d665hnfwFkU/TEVFIs8uSUxGrI1JMkB5Iml Q==; X-IronPort-AV: E=Sophos;i="5.53,337,1531756800"; d="scan'208";a="186673964" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 06 Sep 2018 16:06:36 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 06 Sep 2018 00:52:14 -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; 06 Sep 2018 01:05:39 -0700 From: Atish Patra To: palmer@sifive.com, linux-riscv@lists.infradead.org, hch@infradead.org, anup@brainfault.org Cc: mark.rutland@arm.com, 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 v3 09/12] RISC-V: User WRITE_ONCE instead of direct access Date: Thu, 6 Sep 2018 01:05:32 -0700 Message-Id: <1536221135-182613-10-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536221135-182613-1-git-send-email-atish.patra@wdc.com> References: <1536221135-182613-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 --- 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