From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752255AbcLGJZ5 (ORCPT ); Wed, 7 Dec 2016 04:25:57 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:28248 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbcLGJZ4 (ORCPT ); Wed, 7 Dec 2016 04:25:56 -0500 Subject: Re: [PATCH 1/5] MIPS: Introduce irq_stack To: "Jason A. Donenfeld" References: <1480685957-18809-1-git-send-email-matt.redfearn@imgtec.com> <1480685957-18809-2-git-send-email-matt.redfearn@imgtec.com> CC: Ralf Baechle , , Thomas Gleixner , Paolo Bonzini , Chris Metcalf , Petr Mladek , LKML , James Hogan , Paul Burton , Aaron Tomlin , Andrew Morton From: Matt Redfearn Message-ID: <09b9fc86-d2ed-6d97-4b46-0d526da68a8c@imgtec.com> Date: Wed, 7 Dec 2016 09:25:53 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.150.130.83] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, On 06/12/16 22:13, Jason A. Donenfeld wrote: > On Fri, Dec 2, 2016 at 2:39 PM, Matt Redfearn wrote: >> +void *irq_stack[NR_CPUS]; > I'm curious why you implemented it this way rather than using > DEFINE_PER_CPU and the related percpu helper functions. Because in the IRQ entry point in assembler we have to look up the address of this CPU's IRQ stack. Doing so with a simple array can be done with fewer instructions than a per-cpu variable. The kernel stack pointer for each CPU is held in a similar array. MIPS does not have a particularly optimized per-cpu implementation with the per-cpu offset being held somewhere easily accessible, so right now it has be looked up from the __per_cpu_offset array, and then applied to the per-cpu pointer. Obviously doing the first lookup is analogous to what I am doing, and the subsequent application to the per-cpu pointer would be additional instructions. Thanks, Matt