Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2851613imm; Tue, 4 Sep 2018 11:01:12 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaFlyXUWUPxDSAt+PGZmIwZLk7IAFos836QfXgSBeD+ZYuNCuIZ97/sbHG8OOvpJ9/X3aIZ X-Received: by 2002:a63:cf09:: with SMTP id j9-v6mr28427699pgg.195.1536084071972; Tue, 04 Sep 2018 11:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536084071; cv=none; d=google.com; s=arc-20160816; b=W+ihubCxWU9pWhFTPMOzTtbgLX59eeu2zfz0umxRSmRwg2IISfBr/YCRH6aI70c99k JtGoZt4SquXNKgCZN49Ce6kjT3m8opRBvouTGQT+OxbO8j5kMOHY4dtcOVX7OV1ise1k kIuS6AkQf408C61uUY3kQZy7pZuRqLBxp4ORSec5VZD75mkPvF1adqQUOqNkkWzkhKs0 pSAmkSMu1Ex2VNzzcpCJBQ1W8qlbxdwFkJoDkhdU6I4XD2NBFBg1ElYjBbPqr5OcmiHC 4WYoCEL2ng5Oc0SC3ZivRz7xNCWu+l+nOP6D3NDQ7sNyJOBMEIDkWiYl95nVq7303sNR 8EtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=/WGmmMGVMaWrHp4aMwGvzepLKKjJRXa1F4kaaAoUkVU=; b=i8x3nYKmokHmiEiul/ZKMXOH7yop2okx88/QOPv6K0KGTxu7XZ05c6gdMpe6q+Eaj3 L6gpKzfO3LsTB2nvtgmkCRWzXEHtfX5DoNvXehSbxR97z5rlj0nrmXTJgWOC1na0Uxvz ePB4csk+0VTiwtKBQftzm5rOxqyQNW+sT9t+kCtMwMv7QmCdJ0x4eWEkUKdWQ/zVrnuL k27b+gKCddYkhRNB6b9knX/zCVUReOIANKVg4fDaXkVsQjTOWi2p1+x/CmPeS8qVLvfU vjrZ7TpjIsgKgZAO0uxg8LIIyo/yYSTOSl4Am2dExu/6Ohibwlx52HzG58QpX+HSwfE2 4y6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=oLrjWxw4; 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 i33-v6si9962432pld.306.2018.09.04.11.00.56; Tue, 04 Sep 2018 11:01: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=oLrjWxw4; 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 S1727682AbeIDWZc (ORCPT + 99 others); Tue, 4 Sep 2018 18:25:32 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41569 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbeIDWZc (ORCPT ); Tue, 4 Sep 2018 18:25:32 -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=1536083962; x=1567619962; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=FuBkKc7mLWWwFvCg5TBYpHiVRZl1zlicDiwT1uEST2k=; b=oLrjWxw4aXBnJPJCqMdLJOdc0feaMtsWIBaun97wacbqCtQS8EOffcxv oFEuZCIYygN3CYeBZxApGSLnay3FtzwQ3diQlD/9Ih1SZvpjOkpzNtlSG 2Oln+0qm1BGAGpU3bhBzwamJUZHb8tj4uIHPX7Of+IORQeUp5mvpoMDQw mtb5Zg1gBHrFzaNc3QYDtQRTgxZxzC1/RSUQz/jSDa0RaZMNPWu3YYjkn 83ylOEEDUwBPRaYOqBd3rQJiOHBnXOUkiO/nYwvhFltoOVTu75CQ0Qg0B EONs8W69sSBQx8ooaXAcuIEUvY9sAjX2jq9wqeHEu1WHmE2whwvvSP7D8 g==; X-IronPort-AV: E=Sophos;i="5.53,329,1531756800"; d="scan'208";a="90583680" 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; 05 Sep 2018 01:59:21 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 04 Sep 2018 10:46:06 -0700 Received: from use204589.ad.shared (HELO [10.86.59.178]) ([10.86.59.178]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2018 10:59:21 -0700 Subject: Re: [PATCH v2 1/3] RISC-V: Add logical CPU indexing for RISC-V To: Christoph Hellwig Cc: "palmer@sifive.com" , "linux-riscv@lists.infradead.org" , "mark.rutland@arm.com" , "anup@brainfault.org" , "tglx@linutronix.de" , "linux-kernel@vger.kernel.org" , "damein@vger.kernel.org" References: <1535445370-19004-1-git-send-email-atish.patra@wdc.com> <1535445370-19004-2-git-send-email-atish.patra@wdc.com> <20180831060352.GA19292@infradead.org> From: Atish Patra Message-ID: <5930c4f2-b091-6f20-ef6d-2358a370482d@wdc.com> Date: Tue, 4 Sep 2018 10:59:20 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180831060352.GA19292@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/30/18 11:03 PM, Christoph Hellwig wrote: > On Tue, Aug 28, 2018 at 01:36:08AM -0700, Atish Patra wrote: >> Currently, both linux cpu id and hardware cpu id are same. >> This is not recommended as it will lead to discontinuous cpu >> indexing in Linux. Moreover, kdump kernel will run from CPU0 >> which would be absent if we follow existing scheme. >> >> Implement a logical mapping between Linux cpu id and hardware >> cpuid to decouple these two. Always mark the boot processor as >> cpu0 and all other cpus get the logical cpu id based on their >> booting order. >> >> Signed-off-by: Atish Patra >> --- >> arch/riscv/include/asm/smp.h | 18 +++++++++++++++++- >> arch/riscv/kernel/setup.c | 2 ++ >> arch/riscv/kernel/smp.c | 19 +++++++++++++++++++ >> 3 files changed, 38 insertions(+), 1 deletion(-) >> >> diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h >> index 36016845..a5c257b3 100644 >> --- a/arch/riscv/include/asm/smp.h >> +++ b/arch/riscv/include/asm/smp.h >> @@ -22,6 +22,13 @@ >> #include >> #include >> >> +#define INVALID_HARTID -1 >> +/* >> + * Mapping between linux logical cpu index and hartid. >> + */ >> +extern unsigned long __cpu_logical_map[NR_CPUS]; >> +#define cpu_logical_map(cpu) __cpu_logical_map[cpu] > > How about naming this cpuid_to_hardid_map to make things a little > more obvious? Sure. Also shouldn't this be signed given your INVALID_HARTID > definition above. > I don't know what I was thinking after adding INVALID_HARTID. I will fix this. >> +static inline int riscv_hartid_to_cpuid(int hartid) { return 0 ; } >> +static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in, >> + struct cpumask *out) { >> + cpumask_set_cpu(cpu_logical_map(0), out); >> +} > > Please use normal coding style even for stubs: > > static inline int riscv_hartid_to_cpuid(int hartid) > { > return 0; > } > > static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in, > struct cpumask *out) > { > cpumask_set_cpu(cpu_logical_map(0), out); > } > >> +unsigned long __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HARTID }; > > Please break the line into the usual format: > > unsigned long __cpu_logical_map[NR_CPUS] = { > [0 ... NR_CPUS-1] = INVALID_HARTID, > }; > ok. Regards, Atish